diff --git a/src/framework/cl/cl_image.cpp b/src/framework/cl/cl_image.cpp index 4fc144a73ba3dbbb57d9011f2db40d637f10a89b..fe83f1a6fe260927347449a0d7faedc17f2a2357 100644 --- a/src/framework/cl/cl_image.cpp +++ b/src/framework/cl/cl_image.cpp @@ -183,7 +183,7 @@ Print &operator<<(Print &printer, const CLImage &cl_image) { } i0 += width * H; } - delete[](imageData); + delete (imageData); CL_CHECK_ERRORS(err); } else { @@ -213,14 +213,14 @@ Print &operator<<(Print &printer, const CLImage &cl_image) { } } - delete[](imageData); + delete (imageData); CL_CHECK_ERRORS(err); } for (int i = 0; i < cl_image.numel(); i += stride) { printer << data[i] << " "; } - delete[](data); + delete (data); return printer; } #endif diff --git a/src/framework/executor.cpp b/src/framework/executor.cpp index 22aa7cc98af7eeaed6f01e853136c589e3582b1d..8421c6257320cb2664da91209dc8708255109dfe 100644 --- a/src/framework/executor.cpp +++ b/src/framework/executor.cpp @@ -948,7 +948,7 @@ void Executor::InitMemory() { cl_image->SetTensorData(tensorInput, ddim); delete origin_data; - // paddle_mobile::memory::Free(tensorInput); + paddle_mobile::memory::Free(tensorInput); } else { if (var_desc->Type() == framework::VARTYPE_TYPE_LOD_TENSOR) { auto cl_image = var->template GetMutable(); diff --git a/src/operators/fetch_op.cpp b/src/operators/fetch_op.cpp index 852d5c48fcef57d7f7e06baecc2c1cbb09b5d530..412f0f3182fd65a7464b5169f5cf6f1efc79d4ed 100644 --- a/src/operators/fetch_op.cpp +++ b/src/operators/fetch_op.cpp @@ -22,14 +22,6 @@ void FetchOp::InferShape() const { this->param_.Out()->Resize(x_dims); } -template -void FetchOp::RunImpl() { -#ifdef PADDLE_MOBILE_CL - this->kernel_.Compute(this->param_); -#else - this->param_.Out()->ShareDataWith(*(this->param_.InputX())); -#endif -} } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/fetch_op.h b/src/operators/fetch_op.h index 4e313092ccb9121ebfc307afe1705de466cd6774..c3ef5864f09491326c0d1c214044514bc6f76fa7 100644 --- a/src/operators/fetch_op.h +++ b/src/operators/fetch_op.h @@ -24,7 +24,6 @@ namespace operators { using std::string; template -#ifdef PADDLE_MOBILE_CL class FetchOp : public framework::OperatorWithKernel, FetchKernel> { @@ -35,26 +34,10 @@ class FetchOp : framework::OperatorWithKernel, FetchKernel>( type, inputs, outputs, attrs, scope) {} -#else -class FetchOp : public framework::OperatorBase { - public: - FetchOp(const string &type, const VariableNameMap &inputs, - const VariableNameMap &outputs, const framework::AttributeMap attrs, - std::shared_ptr scope) - : framework::OperatorBase(type, inputs, outputs, attrs, - scope), - param_(inputs, outputs, attrs, *scope) {} - void Init() {} -#endif void InferShape() const override; - void RunImpl() override; - protected: -#ifndef PADDLE_MOBILE_CL - FetchParam param_; -#endif }; } // namespace operators diff --git a/src/operators/kernel/arm/fetch_kernel.cpp b/src/operators/kernel/arm/fetch_kernel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a5f717124855c8b4e1cbb91f9ff015430d5d3f45 --- /dev/null +++ b/src/operators/kernel/arm/fetch_kernel.cpp @@ -0,0 +1,36 @@ +/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ +#ifdef FUSION_CONVADD_OP + +#include "operators/kernel/fetch_kernel.h" + +namespace paddle_mobile { +namespace operators { + +template <> +bool FetchKernel::Init(FetchParam *param) { + return true; +} + +template <> +void FetchKernel::Compute(const FetchParam ¶m) { + param.Out()->ShareDataWith(*(param.InputX())); +} + +template class FetchKernel; + +} // namespace operators +} // namespace paddle_mobile + +#endif diff --git a/src/operators/kernel/fpga/feed_kernel.cpp b/src/operators/kernel/fpga/feed_kernel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c42f3345ea0a01f22766d33341aed558baf51d25 --- /dev/null +++ b/src/operators/kernel/fpga/feed_kernel.cpp @@ -0,0 +1,55 @@ +/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + +#include "operators/kernel/feed_kernel.h" + +namespace paddle_mobile { + namespace operators { + + template <> + bool FeedKernel::Init(FeedParam *param) { + Tensor *output = param->Out(); + fpga::format_fp16_ofm(output); + return true; + } + + template <> + void FeedKernel::Compute(const FeedParam ¶m) { + auto input = reinterpret_cast(const_cast(param.InputX())); + auto input_ptr = input->data(); + fpga::format_image(input); + Tensor *output = param.Out(); + auto output_ptr = output->data(); + + fpga::BypassArgs args = {fpga::DATA_TYPE_FP32}; + + args.input_data_type = fpga::DATA_TYPE_FP32; + args.output_data_type = fpga::DATA_TYPE_FP16; + args.input_layout_type = fpga::LAYOUT_CHW; + args.output_layout_type = fpga::LAYOUT_HWC; + args.image.address = reinterpret_cast(input_ptr); + args.image.channels = (uint32_t)input->dims()[1]; + args.image.height = (uint32_t)input->dims()[2]; + args.image.width = (uint32_t)input->dims()[3]; + args.image.pad_height = 0; + args.image.pad_width = 0; + args.output.address = output_ptr; + args.output.scale_address = output->scale; + fpga::PerformBypass(args); + } + template class FeedKernel; + + } // namespace operators +} // namespace paddle_mobile + diff --git a/src/operators/kernel/mali/feed_kernel.cpp b/src/operators/kernel/mali/feed_kernel.cpp index 34be184d4024a5e1e00fe61f82c0fa4889ffb072..6af6c1a88b8031da4a23dad1d3269935ce81b9a8 100644 --- a/src/operators/kernel/mali/feed_kernel.cpp +++ b/src/operators/kernel/mali/feed_kernel.cpp @@ -23,7 +23,10 @@ bool FeedKernel::Init(FeedParam *param) { } template <> -void FeedKernel::Compute(const FeedParam ¶m) {} +void FeedKernel::Compute(const FeedParam ¶m) { + param.Out()->ShareDataWith(*(param.InputX())); + param.Out()->set_lod(param.InputX()->lod()); +} template class FeedKernel;