提交 32a8b7f6 编写于 作者: Z zhaojiaying01

add fetch kernel for CPU

上级 295c94f4
...@@ -22,14 +22,6 @@ void FetchOp<DeviceType, T>::InferShape() const { ...@@ -22,14 +22,6 @@ void FetchOp<DeviceType, T>::InferShape() const {
this->param_.Out()->Resize(x_dims); this->param_.Out()->Resize(x_dims);
} }
template <typename DeviceType, typename T>
void FetchOp<DeviceType, T>::RunImpl() {
#ifdef PADDLE_MOBILE_CL
this->kernel_.Compute(this->param_);
#else
this->param_.Out()->ShareDataWith(*(this->param_.InputX()));
#endif
}
} // namespace operators } // namespace operators
} // namespace paddle_mobile } // namespace paddle_mobile
......
...@@ -24,7 +24,6 @@ namespace operators { ...@@ -24,7 +24,6 @@ namespace operators {
using std::string; using std::string;
template <typename DeviceType, typename T> template <typename DeviceType, typename T>
#ifdef PADDLE_MOBILE_CL
class FetchOp class FetchOp
: public framework::OperatorWithKernel<DeviceType, FetchParam<DeviceType>, : public framework::OperatorWithKernel<DeviceType, FetchParam<DeviceType>,
FetchKernel<DeviceType, T>> { FetchKernel<DeviceType, T>> {
...@@ -35,26 +34,10 @@ class FetchOp ...@@ -35,26 +34,10 @@ class FetchOp
: framework::OperatorWithKernel<DeviceType, FetchParam<DeviceType>, : framework::OperatorWithKernel<DeviceType, FetchParam<DeviceType>,
FetchKernel<DeviceType, T>>( FetchKernel<DeviceType, T>>(
type, inputs, outputs, attrs, scope) {} type, inputs, outputs, attrs, scope) {}
#else
class FetchOp : public framework::OperatorBase<DeviceType> {
public:
FetchOp(const string &type, const VariableNameMap &inputs,
const VariableNameMap &outputs, const framework::AttributeMap attrs,
std::shared_ptr<framework::Scope> scope)
: framework::OperatorBase<DeviceType>(type, inputs, outputs, attrs,
scope),
param_(inputs, outputs, attrs, *scope) {}
void Init() {}
#endif
void InferShape() const override; void InferShape() const override;
void RunImpl() override;
protected: protected:
#ifndef PADDLE_MOBILE_CL
FetchParam<DeviceType> param_;
#endif
}; };
} // namespace operators } // namespace operators
......
/* 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<CPU, float>::Init(FetchParam<CPU> *param) {
return true;
}
template <>
void FetchKernel<CPU, float>::Compute(const FetchParam<CPU> &param) {
param.Out()->ShareDataWith(*(param.InputX()));
}
template class FetchKernel<CPU, float>;
} // namespace operators
} // namespace paddle_mobile
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册