18.11 CLDepthwiseConvolutionLayer3x3NHWCKernel Test failed
Hi I try to use CLDepthwiseConvolutionLayer3x3NHWCKernel of ACL(18.11) ,but the result is not right. The input shape is : input_w = 150, input_h = 150, input_c = 32 , input_n = 1; info about kernel : kernel_w = 3 kernel_h =3 pad_left = 1 pad_up = 1, stride_x = stride_y = 1;
I set the input datas, weigth datas all equal to be 1.f . But the first data of the result is equal to 2.f. (it should be equal to 4) Can anyone help me. thanks!
Hello @zhangruiopenailab ,
Before looking into this can you provide some code on how you use the library? Could you post the code smippet, build command etc?
Hello Codes:
int n = 1;
int in_w = 150;
int in_h = 150;
int in_c = 32;
int stride_x = 1;
int stride_y = 1;
int pad_left = 1;
int pad_right = 1;
int pad_up = 1;
int pad_down = 1;
int out_w = 150;
int out_h = 150;
int out_c = 32;
int kernel_w = 3;
int kernel_h = 3;
int input_size = in_c * in_h * in_w;
int weight_size = out_c * in_c * kernel_h * kernel_w;
float *input_data = (float*) malloc(input_size * sizeof(float));
float *weight_data = (float*) malloc(weight_size * sizeof(float));
float *output_data = (float*) malloc(input_size * sizeof(float));
CLScheduler::get().default_init();
for (int i = 0; i < input_size;i++)
{
input_data[i] = 1;
}
for (int i = 0; i < weight_size;i++)
{
weight_data[i] = 1;
}
CLTensor *intensor = new CLTensor();
CLTensor *wtensor = new CLTensor();
CLTensor *otensor = new CLTensor();
CLTensor *btensor = NULL;
TensorInfo in_info;
TensorInfo w_info;
TensorInfo out_info;
in_info = TensorInfo(TensorShape(in_c,in_w,in_h,n),1,DataType::F32);
w_info = TensorInfo(TensorShape(in_c,kernel_w,kernel_h,out_c),1,DataType::F32);
in_info = TensorInfo(TensorShape(out_c,out_w,out_h,n),1,DataType::F32);
in_info.set_data_layout(DataLayout::NHWC);
intensor->allocator()->init(in_info);
w_info.set_data_layout(DataLayout::NHWC);
wtensor->allocator()->init(w_info);
out_info.set_data_layout(DataLayout::NHWC);
otensor->allocator()->init(out_info);
ActivationLayerInfo act_info;
//act_info = ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU,6.f);
CLDepthwiseConvolutionLayer3x3* dwconv3x3 = new CLDepthwiseConvolutionLayer3x3();
dwconv3x3->configure(intensor,wtensor,btensor,otensor,
PadStrideInfo(stride_x,stride_y,pad_left,pad_up),1,act_info);
intensor->allocator()->allocate();
wtensor->allocator()->allocate();
otensor->allocator()->allocate();
intensor->map();
void * data = (void*)intensor->buffer();
copy_buffer(data, (void*)input_data, input_size*sizeof(float), DataType::F32, DataType::F32);
intensor->unmap();
wtensor->map();
void * w_data = (void*)wtensor->buffer();
copy_buffer(w_data, (void*)weight_data, weight_size*sizeof(float), DataType::F32, DataType::F32);
wtensor->unmap();
dwconv3x3->run();
CLScheduler::get().sync();
Build Command :
g++ test_depthwise.cpp -std=c++11 -I ../ACL/ -I ../ACL/include/ -L ../ACL/build/ -larm_compute -larm_compute_core -g
Thanks
build ACL :scons Werror=1 -j8 debug=0 neon=0 opencl=1 os=linux arch=arm64-v8a build=native
Hello @zhangruiopenailab,
Where is the copy_buffer function?
Closing for inactivity, feel free to reopen otherwise