diff --git a/src/fpga/api.cpp b/src/fpga/api.cpp index 10787b915594a12a826a087e5453b2c2e8c03f9a..f10aee5014d8f377ecc8e1735276aebf6418436f 100644 --- a/src/fpga/api.cpp +++ b/src/fpga/api.cpp @@ -311,6 +311,8 @@ int get_aligned_filter_num(int num) { void format_filter(framework::Tensor *filter_tensor, float max_value, int group_num) { + filter_tensor->scale[0] = float(max_value / 127.0); + filter_tensor->scale[1] = float(127.0 / max_value); auto dims = filter_tensor->dims(); auto num = dims[0], channel = dims[1], height = dims[2], width = dims[3]; auto data_ptr = filter_tensor->data(); diff --git a/src/io/executor.cpp b/src/io/executor.cpp index c8d8f52a427bb1ee2b9fa04c9ef09f8e626f11b0..d733231ef03f74eba2f1f2e989a0bad1cf43f161 100644 --- a/src/io/executor.cpp +++ b/src/io/executor.cpp @@ -676,11 +676,11 @@ std::shared_ptr Executor::FetchResult(int id) { to_predict_program_->Block(0); auto &ops = ops_of_block_[*to_predict_block.get()]; - PADDLE_MOBILE_ENFORCE(id < ops.size(), "Index out of range"); - auto last_op = id < 0 ? ops[ops.size() - 1] : ops[id]; - auto output_map = last_op->Outputs(); - std::vector out_keys = last_op->GetOutKeys(); - PADDLE_MOBILE_ENFORCE(!out_keys.empty(), "the last op contains no output"); + PADDLE_MOBILE_ENFORCE(id < (int)ops.size(), "Index out of range"); + auto op = id < 0 ? ops[ops.size() - 1] : ops[id]; + auto output_map = op->Outputs(); + std::vector out_keys = op->GetOutKeys(); + PADDLE_MOBILE_ENFORCE(!out_keys.empty(), "this op contains no output"); auto *output_tensor = framework::GetVarValue( out_keys[0], output_map, *(program_.scope)); return std::make_shared(framework::Tensor(*output_tensor)); diff --git a/src/operators/feed_op.h b/src/operators/feed_op.h index cccd4f52ebdc368e4f68eaf9dc3f25ee3693fdd2..1b36461932798153af60d936dbac91817a4100df 100644 --- a/src/operators/feed_op.h +++ b/src/operators/feed_op.h @@ -50,8 +50,8 @@ class FeedOp : public framework::OperatorBase { void RunImpl() const { auto input = (Tensor *)const_cast(param_.InputX()); - auto input_ptr = input->data(); fpga::format_image(input); + auto input_ptr = input->data(); Tensor *output = param_.Out(); auto output_ptr = output->data(); diff --git a/src/operators/kernel/fpga/concat_kernel.cpp b/src/operators/kernel/fpga/concat_kernel.cpp index 86da2833ed6e1443707054896127e87c0ca297b9..1c48ef021945e6a7b8b53ee946a33b862766deeb 100644 --- a/src/operators/kernel/fpga/concat_kernel.cpp +++ b/src/operators/kernel/fpga/concat_kernel.cpp @@ -47,7 +47,7 @@ bool ConcatKernel::Init(ConcatParam *param) { concatArgs.image_num = (uint32_t)image_num; concatArgs.images_in = images_in; concatArgs.scales_in = scales_in; - concatArgs.image_out = (half *)out->mutable_data(); + concatArgs.image_out = (half *)out->data(); concatArgs.scale_out = out->scale; concatArgs.channel_num = channel_num; concatArgs.height = (uint32_t)height; diff --git a/src/operators/kernel/fpga/softmax_kernel.cpp b/src/operators/kernel/fpga/softmax_kernel.cpp index 7cfd0c7d76c1a8e73955dbec1971d86ceebde259..ef68cc3c33fdc4c0a8537cbb1dd3a49583c6c8b1 100644 --- a/src/operators/kernel/fpga/softmax_kernel.cpp +++ b/src/operators/kernel/fpga/softmax_kernel.cpp @@ -39,8 +39,8 @@ bool SoftmaxKernel::Init(SoftmaxParam *param) { args.image.height = 1; args.image.width = 1; args.image.channels = (uint32_t)input->dims()[1]; - args.output.address = float_input->mutable_data(); - + args.output.address = float_input->data(); + args.output.scale_address = float_input->scale; param->SetFloatInput(float_input); param->SetFpgaArgs(args); return true;