ComputeLibrary icon indicating copy to clipboard operation
ComputeLibrary copied to clipboard

18.11 CLDepthwiseConvolutionLayer3x3NHWCKernel Test failed

Open zhangruiopenailab opened this issue 7 years ago • 5 comments

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!

zhangruiopenailab avatar Dec 24 '18 05:12 zhangruiopenailab

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?

GeorgeARM avatar Dec 24 '18 11:12 GeorgeARM

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

zhangruiopenailab avatar Dec 25 '18 06:12 zhangruiopenailab

build ACL :scons Werror=1 -j8 debug=0 neon=0 opencl=1 os=linux arch=arm64-v8a build=native

zhangruiopenailab avatar Dec 25 '18 08:12 zhangruiopenailab

Hello @zhangruiopenailab, Where is the copy_buffer function?

GeorgeARM avatar Jan 08 '19 16:01 GeorgeARM

Closing for inactivity, feel free to reopen otherwise

ManubARM avatar Feb 08 '19 16:02 ManubARM