From 0608340a6fdca63cbbcb600ce02408439901bad8 Mon Sep 17 00:00:00 2001 From: qinan Date: Tue, 10 Dec 2019 17:02:36 +0800 Subject: [PATCH] fix a bug in ewadd in FPGA v2, test=mobile close#2574 (#2575) * update proposal and psroipool kernel file in FPGA V2 track * update, test=develop * update FPGA v2 pe cpp file and ew kernel files, test=develop * fix a bug of sigmoid kernel in FPGA v2 track, test=develop * fix bugs of concat, reshape and slice op and add usleep in fpga regpoll, test=develop * add interupt clear operation before op compute in FPGA V2 track, test=develop * fix a bug in ewadd in FPGA v2, test=mobile --- mobile/src/fpga/V2/pe.cpp | 3 ++- .../src/operators/kernel/fpga/V2/elementwise_add_kernel.cpp | 4 ++-- .../operators/kernel/fpga/V2/elementwise_add_relu_kernel.cpp | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/mobile/src/fpga/V2/pe.cpp b/mobile/src/fpga/V2/pe.cpp index a3c179994a..1443888c3f 100755 --- a/mobile/src/fpga/V2/pe.cpp +++ b/mobile/src/fpga/V2/pe.cpp @@ -534,7 +534,8 @@ uint64_t bypass_interrupt = reg_readq(REG_INTERRUPT); (((uint64_t)args.image0.height * 2) << 32); uint64_t image_row_col_padding_down = image_amount_per_row | (image_amount_per_row << 32); - float quantParam = (args.output.scale_address)[0]; + float quantParam = + ((args.image0.scale_address)[0]) / ((args.output.scale_address)[0]); uint32_t* ew_scale = reinterpret_cast(&quantParam); uint64_t ew_scale_mult_factor = (*ew_scale) | ((uint64_t)args.const0 << 32) | ((uint64_t)args.const1 << 40); diff --git a/mobile/src/operators/kernel/fpga/V2/elementwise_add_kernel.cpp b/mobile/src/operators/kernel/fpga/V2/elementwise_add_kernel.cpp index 57ccf9f00d..ab87d71292 100755 --- a/mobile/src/operators/kernel/fpga/V2/elementwise_add_kernel.cpp +++ b/mobile/src/operators/kernel/fpga/V2/elementwise_add_kernel.cpp @@ -33,8 +33,8 @@ bool ElementwiseAddKernel::Init(ElementwiseAddParam *param) { float C1 = Si_1 / So; float C2 = Si_2 / So; fpga::EWAddArgs ewaddArgs = {0}; - ewaddArgs.const0 = fpga::fp32_2_fp16(C1); - ewaddArgs.const1 = fpga::fp32_2_fp16(C2); + ewaddArgs.const0 = 1; + ewaddArgs.const1 = 1; ewaddArgs.relu_enabled = 0; ewaddArgs.image0.address = input_x_ptr; ewaddArgs.image0.channels = (uint32_t)input_x->dims()[1]; diff --git a/mobile/src/operators/kernel/fpga/V2/elementwise_add_relu_kernel.cpp b/mobile/src/operators/kernel/fpga/V2/elementwise_add_relu_kernel.cpp index de60341874..a55a78e566 100755 --- a/mobile/src/operators/kernel/fpga/V2/elementwise_add_relu_kernel.cpp +++ b/mobile/src/operators/kernel/fpga/V2/elementwise_add_relu_kernel.cpp @@ -35,8 +35,8 @@ bool ElementwiseAddReluKernel::Init( float C2 = Si_2 / So; fpga::EWAddArgs ewaddArgs = {0}; ewaddArgs.relu_enabled = 1; - ewaddArgs.const0 = fpga::fp32_2_fp16(C1); - ewaddArgs.const1 = fpga::fp32_2_fp16(C2); + ewaddArgs.const0 = 1; + ewaddArgs.const1 = 1; ewaddArgs.image0.address = input_x_ptr; ewaddArgs.image0.channels = (uint32_t)input_x->dims()[1]; ewaddArgs.image0.scale_address = input_x->scale; -- GitLab