提交 1d2db85e 编写于 作者: E eclipsycn 提交者: GitHub

Merge branch 'develop' into develop

...@@ -32,9 +32,6 @@ namespace paddle_mobile { ...@@ -32,9 +32,6 @@ namespace paddle_mobile {
scope_(scope) { scope_(scope) {
CheckAllInputOutputSet(); CheckAllInputOutputSet();
} }
template <typename Dtype> void OperatorBase<Dtype>::Run() { RunImpl(); }
template <typename Dtype> template <typename Dtype>
void OperatorBase<Dtype>::CheckAllInputOutputSet() const {} void OperatorBase<Dtype>::CheckAllInputOutputSet() const {}
......
...@@ -18,72 +18,37 @@ SOFTWARE. ...@@ -18,72 +18,37 @@ SOFTWARE.
#pragma once #pragma once
#include <map> #include "framework/operator.h"
#include "operators/kernel/pool_kernel.h"
#include "attribute.h"
#include "block_desc.h"
#include "common/type_define.h"
#include "common/types.h"
#include "common/variant.h"
#include "op_info.h"
#include "op_kernel_type.h"
#include "paddle_mobile_object.h"
#include "scope.h"
#include "tensor.h"
#include "variable.h"
namespace paddle_mobile { namespace paddle_mobile {
namespace framework { namespace operators {
template <typename Dtype> class OperatorBase : PaddleMobileObject {
public:
OperatorBase(const std::string &type, const VariableNameMap &inputs,
const VariableNameMap &outputs,
const AttributeMap &attrs,
std::shared_ptr<Scope> scope);
virtual ~OperatorBase() {}
virtual void Run();
const VariableNameMap &Inputs() const { return inputs_; }
const VariableNameMap &Outputs() const { return outputs_; }
const std::string &Type() const { return type_; }
const AttributeMap &Attrs() const { return attrs_; }
protected: using namespace framework;
std::shared_ptr<Scope> scope_;
std::string type_;
VariableNameMap inputs_;
VariableNameMap outputs_;
AttributeMap attrs_;
private:
void CheckAllInputOutputSet() const;
virtual void RunImpl() const = 0;
};
template <typename Dtype> template <typename DeviceType, typename T>
class OperatorWithKernel : public OperatorBase<Dtype> { class ConvOp : public framework::OperatorWithKernel<DeviceType> {
public: public:
OperatorWithKernel(const std::string &type, ConvOp(const std::string &type, const VariableNameMap &inputs,
const VariableNameMap &inputs, const VariableNameMap &outputs,
const VariableNameMap &outputs, const framework::AttributeMap &attrs,
const AttributeMap &attrs, std::shared_ptr<framework::Scope> scope)
std::shared_ptr<Scope> scope) : framework::OperatorWithKernel<DeviceType>(
: OperatorBase<Dtype>(type, inputs, outputs, attrs, scope) {} type, inputs, outputs, attrs, scope),
virtual void InferShape() const = 0; param_(inputs, outputs, attrs, *scope) {}
protected: using framework::OperatorWithKernel<DeviceType>::OperatorWithKernel;
virtual void RunImpl() const = 0; void InferShape() const override;
void Run() const {
operators::ConvKernel<DeviceType, T, ConvParam> kernel;
kernel.Compute(param_);
this->ClearVariables();
}
private: private:
ConvParam param_;
}; };
template <typename Dtype, typename P> } // operators
class OpKernelBase : PaddleMobileObject { } // paddle_mobile
public:
virtual void Compute(const P &para) const = 0;
virtual ~OpKernelBase() = default;
};
} // namespace framework
} // namespace paddle_mobile
...@@ -29,9 +29,6 @@ namespace paddle_mobile { ...@@ -29,9 +29,6 @@ namespace paddle_mobile {
namespace framework { namespace framework {
class Variable : public PaddleMobileObject { class Variable : public PaddleMobileObject {
public: public:
Variable() {}
~Variable() {}
template <typename T> const T *Get() const { template <typename T> const T *Get() const {
return static_cast<const T *>(holder_->Ptr()); return static_cast<const T *>(holder_->Ptr());
} }
......
...@@ -40,12 +40,13 @@ namespace paddle_mobile { ...@@ -40,12 +40,13 @@ namespace paddle_mobile {
using framework::OperatorWithKernel<DeviceType>::OperatorWithKernel; using framework::OperatorWithKernel<DeviceType>::OperatorWithKernel;
void InferShape() const override; void InferShape() const override;
protected: void Run() const {
void RunImpl() const {
operators::ConvKernel<DeviceType, T, ConvParam> kernel; operators::ConvKernel<DeviceType, T, ConvParam> kernel;
kernel.Compute(param_); kernel.Compute(param_);
this->ClearVariables();
} }
private:
ConvParam param_; ConvParam param_;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册