From 08066659f840e4c191e7ebcdfae419702ea4a99d Mon Sep 17 00:00:00 2001 From: qnqinan Date: Mon, 23 Dec 2019 15:26:44 +0800 Subject: [PATCH] update fetch kernel file in FPGA V2 track and test for refork, test=mobile --- mobile/src/operators/kernel/fpga/V2/fetch_kernel.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mobile/src/operators/kernel/fpga/V2/fetch_kernel.cpp b/mobile/src/operators/kernel/fpga/V2/fetch_kernel.cpp index c6b8f9e852..c761b4dd52 100644 --- a/mobile/src/operators/kernel/fpga/V2/fetch_kernel.cpp +++ b/mobile/src/operators/kernel/fpga/V2/fetch_kernel.cpp @@ -85,12 +85,13 @@ void FetchKernel::Compute(const FetchParam ¶m) { } auto input_address = input->data(); float Si = input->scale[0]; + float scale = Si / 127.0f; const int num_th = 32; fpga::fpga_invalidate(input_address, (input->fpga_data_num) * sizeof(int8_t)); if (input->fpga_data_num < num_th) { for (int idx = 0; idx < product(input->dims()); ++idx) { - outdata_ptr[idx] = input_address[idx] / 127.0 * Si; + outdata_ptr[idx] = input_address[idx] * scale; } fpga::fpga_flush(outdata_ptr, product(input->dims()) * sizeof(float)); return; @@ -101,14 +102,14 @@ void FetchKernel::Compute(const FetchParam ¶m) { auto aligned_ptr = aligned_out->data(); fpga::fpga_invalidate(aligned_ptr, (input->fpga_data_num) * sizeof(float)); for (int idx = 0; idx < input->fpga_data_num; ++idx) { - aligned_ptr[idx] = input_address[idx] / 127.0 * Si; + aligned_ptr[idx] = input_address[idx] * scale; } dealign(aligned_ptr, outdata_ptr, outC, outH, outW); fpga::fpga_flush(outdata_ptr, outC * outH * outW * sizeof(float)); return; } for (int idx = 0; idx < input->fpga_data_num; ++idx) { - outdata_ptr[idx] = input_address[idx] / 127.0 * Si; + outdata_ptr[idx] = input_address[idx] * scale; } fpga::fpga_flush(outdata_ptr, outC * outH * outW * sizeof(float)); } -- GitLab