提交 54575b64 编写于 作者: Z zhaojiaying01

add fetch kernel for CPU

上级 60c3250c
......@@ -18,18 +18,12 @@ namespace operators {
template <typename DeviceType, typename T>
void FetchOp<DeviceType, T>::InferShape() const {
DLOG << "~~~~~~~~~~~~~~!!";
auto x_dims = this->param_.InputX()->dims();
this->param_.Out()->Resize(x_dims);
DLOG << "~~~~~~~~~~~~~~!!!";
}
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 paddle_mobile
......
......@@ -24,7 +24,6 @@ namespace operators {
using std::string;
template <typename DeviceType, typename T>
#ifdef PADDLE_MOBILE_CL
class FetchOp
: public framework::OperatorWithKernel<DeviceType, FetchParam<DeviceType>,
FetchKernel<DeviceType, T>> {
......@@ -35,26 +34,10 @@ class FetchOp
: framework::OperatorWithKernel<DeviceType, FetchParam<DeviceType>,
FetchKernel<DeviceType, T>>(
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 RunImpl() override;
protected:
#ifndef PADDLE_MOBILE_CL
FetchParam<DeviceType> param_;
#endif
};
} // 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
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册