diff --git a/src/framework/cl/cl_image.h b/src/framework/cl/cl_image.h index 1c5da6146d484e9aaa712da019d5573d116fe0e5..b8645a42989765656c43c73c04da500c9606cae1 100644 --- a/src/framework/cl/cl_image.h +++ b/src/framework/cl/cl_image.h @@ -61,6 +61,7 @@ class CLImage { PADDLE_MOBILE_THROW_EXCEPTION( " empty image tensor data shouldn't have value"); } + DLOG << " init empty image "; InitCLImage(context, nullptr, dim); initialized_ = true; } diff --git a/src/operators/kernel/cl/conv_add_bn_relu_kernel.cpp b/src/operators/kernel/cl/conv_add_bn_relu_kernel.cpp index 29b13b6abc3943ff23ce3f5a98962ecb4d9c2d7a..6b16039f155828c221b0936db7056a153b7568bb 100644 --- a/src/operators/kernel/cl/conv_add_bn_relu_kernel.cpp +++ b/src/operators/kernel/cl/conv_add_bn_relu_kernel.cpp @@ -24,9 +24,16 @@ namespace operators { template <> bool ConvAddBNReluKernel::Init( FusionConvAddBNReluParam *param) { + PADDLE_MOBILE_ENFORCE( + param->Filter()->dims()[2] == param->Filter()->dims()[3] && + param->Paddings()[0] == param->Paddings()[1], + "need equal"); + + param->Filter()->InitCLImage(cl_helper_.CLContext()); + param->Bias()->InitCLImage(cl_helper_.CLContext()); + // const CL *mean = param->InputMean(); const framework::CLImage *mean = param->InputMean(); - const framework::CLImage *variance = param->InputVariance(); const framework::CLImage *scale = param->InputScale(); const framework::CLImage *bias = param->InputBias(); @@ -52,9 +59,6 @@ bool ConvAddBNReluKernel::Init( new_bias_ptr[i] = bias_ptr[i] - mean_ptr[i] * inv_std_ptr[i] * scale_ptr[i]; } - delete[](new_scale_ptr); - delete[](new_bias_ptr); - framework::CLImage *new_scale = new framework::CLImage(); new_scale->SetTensorData(new_scale_ptr, variance->dims()); @@ -68,6 +72,9 @@ bool ConvAddBNReluKernel::Init( param->SetNewScale(new_scale); param->SetNewBias(new_bias); + delete[](new_scale_ptr); + delete[](new_bias_ptr); + PADDLE_MOBILE_ENFORCE( param->Filter()->dims()[2] == param->Filter()->dims()[3] && param->Paddings()[0] == param->Paddings()[1], diff --git a/src/operators/kernel/cl/conv_add_kernel.cpp b/src/operators/kernel/cl/conv_add_kernel.cpp index b5fd82c47a9af4fc383cfe276d08dfb365b6bff3..ac36e70ed793ee000602114eb690780235b7d858 100644 --- a/src/operators/kernel/cl/conv_add_kernel.cpp +++ b/src/operators/kernel/cl/conv_add_kernel.cpp @@ -25,6 +25,9 @@ bool ConvAddKernel::Init(FusionConvAddParam *param) { param->Filter()->dims()[2] == param->Filter()->dims()[3] && param->Paddings()[0] == param->Paddings()[1], "need equal"); + param->Filter()->InitCLImage(cl_helper_.CLContext()); + param->Bias()->InitCLImage(cl_helper_.CLContext()); + int offset = static_cast(param->Filter()->dims()[2]) / 2 - static_cast(param->Paddings()[1]); param->SetOffset(offset); diff --git a/src/operators/kernel/cl/conv_kernel.cpp b/src/operators/kernel/cl/conv_kernel.cpp index 83861446850989d3e5bee043ca5f37008fb973aa..63c1776f832843ad36f7f1e209dd380d93c7440b 100644 --- a/src/operators/kernel/cl/conv_kernel.cpp +++ b/src/operators/kernel/cl/conv_kernel.cpp @@ -26,19 +26,18 @@ bool ConvKernel::Init(ConvParam *param) { param->Paddings()[0] == param->Paddings()[1], "need equal"); + param->Filter()->InitCLImage(cl_helper_.CLContext()); + int offset = static_cast(param->Filter()->dims()[2]) / 2 - static_cast(param->Paddings()[1]); param->SetOffset(offset); DLOG << " init helper: " << &cl_helper_; DLOG << " conv kernel add kernel ~ "; - DLOG << " width of one block: " << param->Filter()->WidthOfOneBlock(); DLOG << " height of one block: " << param->Filter()->HeightOfOneBlock(); - DLOG << " filter dims: " << param->Filter()->dims(); - if (param->Filter()->WidthOfOneBlock() == 1 && param->Filter()->HeightOfOneBlock() == 1) { diff --git a/src/operators/kernel/cl/depthwise_conv_kernel.cpp b/src/operators/kernel/cl/depthwise_conv_kernel.cpp index 99b5a714d6e2d5d6951b800f8f2cdc56c9241e79..dcb95b4c6a9c42ff8c08f83611fc89aebc6efdfa 100644 --- a/src/operators/kernel/cl/depthwise_conv_kernel.cpp +++ b/src/operators/kernel/cl/depthwise_conv_kernel.cpp @@ -27,6 +27,7 @@ bool DepthwiseConvKernel::Init(ConvParam *param) { param->Filter()->dims()[2] == param->Filter()->dims()[3] && param->Paddings()[0] == param->Paddings()[1], "need equal"); + param->Filter()->InitCLImage(cl_helper_.CLContext()); int offset = static_cast(param->Filter()->dims()[2]) / 2 - static_cast(param->Paddings()[1]); param->SetOffset(offset);