virtual void Fill(Blob<Dtype> *blob) { CHECK_LE(blob->num_axes(), 4) << "Blob must be 4 dim or less to use Gabor filler."; CHECK_EQ(blob->width(), blob->height()) << "Filter must be square in first two dimensions to use Gabor filler."; CHECK_EQ(blob->channels(), 3) << "Blob must have 3 channels to use Gabor filler"; Dtype *data = blob->mutable_cpu_data(); KernelGenerator<Dtype> kernelGenerator(blob->num(), blob->width()); kernelGenerator.generate(); caffe_copy<Dtype>(kernelGenerator.getSizeOfKernelData(), kernelGenerator.getKernelData(), data); /* static bool error = logFilter(kernelGenerator.getSizeOfKernelData(), data); (void) error; */ CHECK_EQ(this->filler_param_.sparse(), -1) << "Sparsity not supported by this Filler."; }
Kernel *makeKernel( cl_device_id device, cl_context context, SolverKgen kernelGenerator, cl_program program, const SubproblemDim *dims, const PGranularity *pgran, const CLBLASKernExtra *extra, const char *buildOpts, cl_int *error) { cl_int err; char *source; ssize_t size; Kernel *kernel; char *log; #ifdef DEBUG_2 printf("Make kernel called\n"); printf("x : %d, y : %d, itemX: %d, itemY: %d\n", dims->x, dims->y, dims->itemX, dims->itemY); printf("PG : wgSize[0] : %d, wgSize[1] : %d, wfSize: %d\n", pgran->wgSize[0], pgran->wgSize[1], pgran->wfSize); #endif kernel = allocKernel(); if (kernel == NULL) { free(source); storeErrorCode(error, CL_OUT_OF_HOST_MEMORY); return NULL; } if (kernelGenerator) { size = kernelGenerator(NULL, 0, dims, pgran, (void*)extra); if (size < 0) { storeErrorCode(error, CL_OUT_OF_HOST_MEMORY); return NULL; } source = calloc(1, size); if (source == NULL) { storeErrorCode(error, CL_OUT_OF_HOST_MEMORY); return NULL; } if (kernelGenerator(source, size, dims, pgran, (void*)extra) != size) { free(source); storeErrorCode(error, CL_OUT_OF_HOST_MEMORY); return NULL; } log = allocBuildLog(); //#define DEBUG_2 #ifdef DEBUG_2 printf("Build Options used %s \n", buildOpts); printf("Source kernel used %s \n", source); #endif #undef DEBUG_2 kernel->program = buildClProgram(source, buildOpts, context, device, log, BUILD_LOG_SIZE, &err); if (err != CL_SUCCESS) { printBuildError(err, device, kernelGenerator, dims, pgran, extra, source, log); freeBuildLog(log); putKernel(NULL, kernel); free(source); storeErrorCode(error, err); return NULL; } else { // #define DEBUG_2 #ifdef DEBUG_2 printf("Kernel compilation succeeded\n"); #endif #undef DEBUG_2 } freeBuildLog(log); free(source); #if !defined(KEEP_CLBLAS_KERNEL_SOURCES) if (err == CL_SUCCESS) { err = dropProgramSource(&kernel->program, context, device); kernel->noSource = 1; } #endif /* !DUMP_CLBLAS_KERNELS */ if (err != CL_SUCCESS) { putKernel(NULL, kernel); storeErrorCode(error, err); return NULL; } } else { kernel->program = program; } kernel->extraSize = sizeof(CLBLASKernExtra); kernel->extra = calloc(1, kernel->extraSize); *(CLBLASKernExtra*)(kernel->extra) = *extra; kernel->dtor = extraDtor; storeErrorCode(error, CL_SUCCESS); return kernel; }