diff --git a/src/operators/kernel/fpga/conv_add_bn_kernel.cpp b/src/operators/kernel/fpga/conv_add_bn_kernel.cpp index c2a6d29ac15296067a6bd6691b619d8cf6ff42bb..152b200cfa88d010bb4c8e8022c01ee3663cc179 100644 --- a/src/operators/kernel/fpga/conv_add_bn_kernel.cpp +++ b/src/operators/kernel/fpga/conv_add_bn_kernel.cpp @@ -37,11 +37,11 @@ bool ConvAddBNKernel::Init(FusionConvAddBNParam *param) { auto bn_scale_ptr = param->InputScale()->data(); auto bn_bias_ptr = param->InputBias()->data(); const float epsilon = param->Epsilon(); - PADDLE_MOBILE_ENFORCE(input->dims()[1] == bias->dims()[0] && + PADDLE_MOBILE_ENFORCE(out->dims()[1] == bias->dims()[0] && bias->dims()[0] == param->InputBias()->dims()[0], - "Image channel should be equal to bias number"); + "Output channel should be equal to bias number"); - const int channel = input->dims()[1]; + const int channel = out->dims()[1]; float *bs_ptr = reinterpret_cast(fpga::fpga_malloc(2 * channel * sizeof(float))); Tensor *new_scale = new Tensor(); diff --git a/src/operators/kernel/fpga/conv_add_bn_relu_kernel.cpp b/src/operators/kernel/fpga/conv_add_bn_relu_kernel.cpp index a6018df987207c92b0e50fa2345367523632ef1e..caa1e94c6bb9b583efb15e181d46c80f0b66c7ff 100644 --- a/src/operators/kernel/fpga/conv_add_bn_relu_kernel.cpp +++ b/src/operators/kernel/fpga/conv_add_bn_relu_kernel.cpp @@ -35,11 +35,11 @@ bool ConvAddBNReluKernel::Init(FusionConvAddBNReluParam *param) { auto bn_scale_ptr = param->InputScale()->data(); auto bn_bias_ptr = param->InputBias()->data(); const float epsilon = param->Epsilon(); - PADDLE_MOBILE_ENFORCE(input->dims()[1] == bias->dims()[0] && + PADDLE_MOBILE_ENFORCE(out->dims()[1] == bias->dims()[0] && bias->dims()[0] == param->InputBias()->dims()[0], - "Image channel should be equal to bias number"); + "Output channel should be equal to bias number"); - const int channel = input->dims()[1]; + const int channel = out->dims()[1]; float *bs_ptr = (float *)fpga::fpga_malloc(2 * channel * sizeof(float)); Tensor *new_scale = new Tensor(); Tensor *new_bias = new Tensor(); diff --git a/src/operators/kernel/fpga/conv_add_relu_kernel.cpp b/src/operators/kernel/fpga/conv_add_relu_kernel.cpp index c5383bf1e9ac6e24a66094be69516fa56e973613..33e55773ad0be4f174916f0e5f066b6eeec1d46e 100644 --- a/src/operators/kernel/fpga/conv_add_relu_kernel.cpp +++ b/src/operators/kernel/fpga/conv_add_relu_kernel.cpp @@ -31,9 +31,9 @@ bool ConvAddReluKernel::Init(FusionConvAddReluParam *param) { Tensor *out = param->Output(); auto out_ptr = out->mutable_data(); - PADDLE_MOBILE_ENFORCE(input->dims()[1] == bias->dims()[0], - "Image channel should be equal to bias number"); - int channel = input->dims()[1]; + PADDLE_MOBILE_ENFORCE(out->dims()[1] == bias->dims()[0], + "Output channel should be equal to bias number"); + int channel = out->dims()[1]; float *bs_ptr = (float *)fpga::fpga_malloc(2 * channel * sizeof(float)); for (int i = 0; i < channel; i++) { bs_ptr[i * 2] = 1; diff --git a/src/operators/kernel/fpga/conv_bn_kernel.cpp b/src/operators/kernel/fpga/conv_bn_kernel.cpp index ee66c951a19a06be77bdbadbc425921db6af64fb..3ad65a254f95bde431efbd3c5995df6cc2295d3d 100644 --- a/src/operators/kernel/fpga/conv_bn_kernel.cpp +++ b/src/operators/kernel/fpga/conv_bn_kernel.cpp @@ -35,10 +35,10 @@ bool ConvBNKernel::Init(FusionConvBNParam *param) { auto bn_scale_ptr = param->InputScale()->data(); auto bn_bias_ptr = param->InputBias()->data(); const float epsilon = param->Epsilon(); - PADDLE_MOBILE_ENFORCE(input->dims()[1] == param->InputBias()->dims()[0], - "Image channel should be equal to bias number"); + PADDLE_MOBILE_ENFORCE(out->dims()[1] == param->InputBias()->dims()[0], + "Output channel should be equal to bias number"); - const int channel = input->dims()[1]; + const int channel = out->dims()[1]; float *bs_ptr = reinterpret_cast(fpga::fpga_malloc(2 * channel * sizeof(float))); Tensor *new_scale = new Tensor(); diff --git a/src/operators/kernel/fpga/conv_bn_relu_kernel.cpp b/src/operators/kernel/fpga/conv_bn_relu_kernel.cpp index f062cdce08790e47f4f5e2a1485412278bbb8bf9..18ef4b4e15e488f01a435d89218992e63873bb14 100644 --- a/src/operators/kernel/fpga/conv_bn_relu_kernel.cpp +++ b/src/operators/kernel/fpga/conv_bn_relu_kernel.cpp @@ -33,10 +33,10 @@ bool ConvBNReluKernel::Init(FusionConvBNReluParam *param) { auto bn_scale_ptr = param->InputScale()->data(); auto bn_bias_ptr = param->InputBias()->data(); const float epsilon = param->Epsilon(); - PADDLE_MOBILE_ENFORCE(input->dims()[1] == param->InputBias()->dims()[0], - "Image channel should be equal to bias number"); + PADDLE_MOBILE_ENFORCE(out->dims()[1] == param->InputBias()->dims()[0], + "Output channel should be equal to bias number"); - const int channel = input->dims()[1]; + const int channel = out->dims()[1]; float *bs_ptr = (float *)fpga::fpga_malloc(2 * channel * sizeof(float)); Tensor *new_scale = new Tensor(); Tensor *new_bias = new Tensor(); diff --git a/src/operators/kernel/fpga/fc_relu_kernel.cpp b/src/operators/kernel/fpga/fc_relu_kernel.cpp index 499ced8d7438cc5f2bdaac79906546577200b47b..fb6a3e7508bf11f0bba1c3e34c065fa63caa2100 100644 --- a/src/operators/kernel/fpga/fc_relu_kernel.cpp +++ b/src/operators/kernel/fpga/fc_relu_kernel.cpp @@ -33,7 +33,7 @@ bool FusionFcReluKernel::Init(FusionFcReluParam *param) { PADDLE_MOBILE_ENFORCE(input_x->dims()[1] == input_y->dims()[0], "Image channel should be equal to weight number"); - int channel = input_x->dims()[1]; + int channel = out->dims()[1]; float *bs_ptr = (float *)fpga::fpga_malloc(2 * channel * sizeof(float)); for (int i = 0; i < channel; i++) { bs_ptr[i * 2] = 1; diff --git a/src/operators/kernel/fpga/fusion_fc_kernel.cpp b/src/operators/kernel/fpga/fusion_fc_kernel.cpp index e269bcb5a3b7f595d13bc0b76c089d480a2ec7a4..5479deb6c19cf085dcea03555e4895d4ad98c4e8 100644 --- a/src/operators/kernel/fpga/fusion_fc_kernel.cpp +++ b/src/operators/kernel/fpga/fusion_fc_kernel.cpp @@ -32,7 +32,7 @@ bool FusionFcKernel::Init(FusionFcParam *param) { PADDLE_MOBILE_ENFORCE(input_x->dims()[1] == input_y->dims()[0], "Image channel should be equal to weight number"); - int channel = input_x->dims()[1]; + int channel = out->dims()[1]; float *bs_ptr = (float *)fpga::fpga_malloc(2 * channel * sizeof(float)); for (int i = 0; i < channel; i++) { bs_ptr[i * 2] = 1; diff --git a/test/net/test_resnet.cpp b/test/net/test_resnet.cpp index 73ac88ef77b0c02545ef55b6493d4681c61c192d..82fdc22763d11d4b06439465d56d0e6fa663a317 100644 --- a/test/net/test_resnet.cpp +++ b/test/net/test_resnet.cpp @@ -17,7 +17,13 @@ limitations under the License. */ #include "../test_include.h" int main() { +#ifdef PADDLE_MOBILE_FPGA + paddle_mobile::PaddleMobile paddle_mobile; +#endif + +#ifdef PADDLE_MOBILE_CPU paddle_mobile::PaddleMobile paddle_mobile; +#endif paddle_mobile.SetThreadNum(4); auto time1 = time(); if (paddle_mobile.Load(g_resnet, true)) {