diff --git a/src/operators/kernel/fpga/fc_relu_kernel.cpp b/src/operators/kernel/fpga/fc_relu_kernel.cpp index 21e334b12b70be1980d9417ed11161143106d1c6..d3683d321c5b31d6e6b3ff96ef8414560fc7ca49 100644 --- a/src/operators/kernel/fpga/fc_relu_kernel.cpp +++ b/src/operators/kernel/fpga/fc_relu_kernel.cpp @@ -14,6 +14,7 @@ limitations under the License. */ #ifdef FUSION_FCRELU_OP #include "operators/kernel/fc_relu_kernel.h" #include "fpga/api/fpga_api.h" +#include "fpga/fpga_quantilization.h" namespace paddle_mobile { namespace operators { @@ -23,8 +24,7 @@ bool FusionFcReluKernel::Init(FusionFcReluParam *param) { bool relu_enabled = true; const Tensor *input_x = param->InputX(); auto input_x_ptr = input_x->data(); - const Tensor *input_y = param->InputY(); - auto input_y_ptr = input_y->data(); + Tensor *input_y = param->InputY(); const Tensor *input_z = param->InputZ(); auto input_z_ptr = input_z->data(); Tensor *out = param->Out(); @@ -39,6 +39,9 @@ bool FusionFcReluKernel::Init(FusionFcReluParam *param) { bs_ptr[i * 2 + 1] = input_z_ptr[i]; } + fpga::quantify_filter(input_y); + auto input_y_ptr = input_y->data(); + fpga::ConvArgs convArgs; convArgs.relu_enabled = relu_enabled; convArgs.filter_address = (void *)input_y_ptr; diff --git a/src/operators/kernel/fpga/fusion_fc_kernel.cpp b/src/operators/kernel/fpga/fusion_fc_kernel.cpp index 505b8768565dc4003152c3493b558448f9d73d04..f0bc5f4a1767b99005725a17ca905d45a8ca5785 100644 --- a/src/operators/kernel/fpga/fusion_fc_kernel.cpp +++ b/src/operators/kernel/fpga/fusion_fc_kernel.cpp @@ -14,6 +14,7 @@ limitations under the License. */ #ifdef FUSION_FC_OP #include "operators/kernel/fusion_fc_kernel.h" +#include "fpga/fpga_quantilization.h" namespace paddle_mobile { namespace operators { @@ -23,8 +24,7 @@ bool FusionFcKernel::Init(FusionFcParam *param) { bool relu_enabled = false; const Tensor *input_x = param->InputX(); auto input_x_ptr = input_x->data(); - const Tensor *input_y = param->InputY(); - auto input_y_ptr = input_y->data(); + Tensor *input_y = param->InputY(); const Tensor *input_z = param->InputZ(); auto input_z_ptr = input_z->data(); Tensor *out = param->Out(); @@ -39,6 +39,9 @@ bool FusionFcKernel::Init(FusionFcParam *param) { bs_ptr[i * 2 + 1] = input_z_ptr[i]; } + fpga::quantify_filter(input_y); + auto input_y_ptr = input_y->data(); + fpga::ConvArgs convArgs; convArgs.relu_enabled = relu_enabled; convArgs.filter_address = (void *)input_y_ptr; @@ -55,11 +58,9 @@ bool FusionFcKernel::Init(FusionFcParam *param) { convArgs.image.width = input_x->dims()[3]; convArgs.image.pad_height = 0; convArgs.image.pad_width = 0; - convArgs.image.scale_address = - input_x->fpga_args().scale_pointer(); // fc input has scale attribute?? + convArgs.image.scale_address = input_x->fpga_args().scale_pointer(); convArgs.output.address = (void *)out_ptr; - convArgs.output.scale_address = - out->fpga_args().scale_pointer(); // fc output has scale attribute?? + convArgs.output.scale_address = out->fpga_args().scale_pointer(); param->SetFpgaArgs(convArgs); return true; }