提交 d383ae40 编写于 作者: qnqinan's avatar qnqinan 提交者: GitHub

Merge pull request #784 from qnqinan/develop

add quantilization func to fusion_fc and fc_relu kernel closed #783
......@@ -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<FPGA, float>::Init(FusionFcReluParam *param) {
bool relu_enabled = true;
const Tensor *input_x = param->InputX();
auto input_x_ptr = input_x->data<half>();
const Tensor *input_y = param->InputY();
auto input_y_ptr = input_y->data<float>();
Tensor *input_y = param->InputY();
const Tensor *input_z = param->InputZ();
auto input_z_ptr = input_z->data<float>();
Tensor *out = param->Out();
......@@ -39,6 +39,9 @@ bool FusionFcReluKernel<FPGA, float>::Init(FusionFcReluParam *param) {
bs_ptr[i * 2 + 1] = input_z_ptr[i];
}
fpga::quantify_filter(input_y);
auto input_y_ptr = input_y->data<int8_t>();
fpga::ConvArgs convArgs;
convArgs.relu_enabled = relu_enabled;
convArgs.filter_address = (void *)input_y_ptr;
......
......@@ -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<FPGA, float>::Init(FusionFcParam *param) {
bool relu_enabled = false;
const Tensor *input_x = param->InputX();
auto input_x_ptr = input_x->data<half>();
const Tensor *input_y = param->InputY();
auto input_y_ptr = input_y->data<float>();
Tensor *input_y = param->InputY();
const Tensor *input_z = param->InputZ();
auto input_z_ptr = input_z->data<float>();
Tensor *out = param->Out();
......@@ -39,6 +39,9 @@ bool FusionFcKernel<FPGA, float>::Init(FusionFcParam *param) {
bs_ptr[i * 2 + 1] = input_z_ptr[i];
}
fpga::quantify_filter(input_y);
auto input_y_ptr = input_y->data<int8_t>();
fpga::ConvArgs convArgs;
convArgs.relu_enabled = relu_enabled;
convArgs.filter_address = (void *)input_y_ptr;
......@@ -55,11 +58,9 @@ bool FusionFcKernel<FPGA, float>::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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册