diff --git a/src/operators/kernel/fpga/V1/fetch_kernel.cpp b/src/operators/kernel/fpga/V1/fetch_kernel.cpp index a0bd58160acac59c6d3fd5c462c1962204c8448d..fad1e77643a017659bea3c27d4475aea2c00787d 100644 --- a/src/operators/kernel/fpga/V1/fetch_kernel.cpp +++ b/src/operators/kernel/fpga/V1/fetch_kernel.cpp @@ -30,19 +30,20 @@ bool FetchKernel::Init(FetchParam *param) { int outC = 1; int outH = 1; int outW = 1; - if(output->dims().size() == 4){ - outC = output->dims()[1]; - outH = output->dims()[2]; - outW = output->dims()[3]; - }else{//2 - outC = output->dims()[1]; + if (output->dims().size() == 4) { + outC = output->dims()[1]; + outH = output->dims()[2]; + outW = output->dims()[3]; + } else { // 2 + outC = output->dims()[1]; } int unalignedCW = outC * outW; int alignedCW = fpga::align_to_x(unalignedCW, IMAGE_ALIGNMENT); - if(alignedCW != unalignedCW){ - param->aligned_out.Resize(input->dims()); - param->aligned_out.mutable_data(input->dims()); - fpga::fpga_flush(param->aligned_out.data(), outH*unalignedCW*sizeof(float)); + if (alignedCW != unalignedCW) { + param->aligned_out.Resize(input->dims()); + param->aligned_out.mutable_data(input->dims()); + fpga::fpga_flush(param->aligned_out.data(), + outH * unalignedCW * sizeof(float)); } fpga::BypassArgs args = {fpga::DATA_TYPE_FP16}; @@ -101,23 +102,23 @@ void FetchKernel::Compute(const FetchParam ¶m) { int outC = 1; int outH = 1; int outW = 1; - if(output->dims().size() == 4){ - outC = output->dims()[1]; - outH = output->dims()[2]; - outW = output->dims()[3]; - }else{//2 - outC = output->dims()[1]; + if (output->dims().size() == 4) { + outC = output->dims()[1]; + outH = output->dims()[2]; + outW = output->dims()[3]; + } else { // 2 + outC = output->dims()[1]; } fpga::fpga_invalidate(param.fpga_bypass_args.output.address, output->fpga_data_num * sizeof(float)); int unalignedCW = outC * outW; int alignedCW = fpga::align_to_x(unalignedCW, IMAGE_ALIGNMENT); - if(unalignedCW != alignedCW){ - auto aligned_ptr = const_cast(param.aligned_out.data()); - dealign(outdata_ptr, aligned_ptr, outC, outH, outW); - memcpy(outdata_ptr, aligned_ptr, outC * outH * outW * sizeof(float)); - fpga::fpga_flush(outdata_ptr, outC * outH * outW * sizeof(float)); + if (unalignedCW != alignedCW) { + auto aligned_ptr = const_cast(param.aligned_out.data()); + dealign(outdata_ptr, aligned_ptr, outC, outH, outW); + memcpy(outdata_ptr, aligned_ptr, outC * outH * outW * sizeof(float)); + fpga::fpga_flush(outdata_ptr, outC * outH * outW * sizeof(float)); } } template class FetchKernel;