提交 df8ad667 编写于 作者: W wangliu

modify code style

上级 5a152298
...@@ -22,8 +22,8 @@ SOFTWARE. ...@@ -22,8 +22,8 @@ SOFTWARE.
namespace paddle_mobile { namespace paddle_mobile {
namespace framework { namespace framework {
template <typename Dtype> template <typename Dtype>
OperatorBase<Dtype>::OperatorBase(const std::string &type, OperatorBase<Dtype>::OperatorBase(const std::string &type,
const VariableNameMap &inputs, const VariableNameMap &inputs,
const VariableNameMap &outputs, const VariableNameMap &outputs,
const AttributeMap &attrs, const AttributeMap &attrs,
...@@ -31,12 +31,12 @@ OperatorBase<Dtype>::OperatorBase(const std::string &type, ...@@ -31,12 +31,12 @@ OperatorBase<Dtype>::OperatorBase(const std::string &type,
: type_(type), inputs_(inputs), outputs_(outputs), attrs_(attrs), : type_(type), inputs_(inputs), outputs_(outputs), attrs_(attrs),
scope_(scope) { scope_(scope) {
CheckAllInputOutputSet(); CheckAllInputOutputSet();
} }
template <typename Dtype> template <typename Dtype>
void OperatorBase<Dtype>::CheckAllInputOutputSet() const {} void OperatorBase<Dtype>::CheckAllInputOutputSet() const {}
template class OperatorBase<CPU>; template class OperatorBase<CPU>;
template class OperatorWithKernel<CPU>; template class OperatorWithKernel<CPU>;
} // namespace framework } // namespace framework
} // namespace paddle_mobile } // namespace paddle_mobile
...@@ -22,18 +22,19 @@ SOFTWARE. ...@@ -22,18 +22,19 @@ SOFTWARE.
#include "operators/kernel/pool_kernel.h" #include "operators/kernel/pool_kernel.h"
namespace paddle_mobile { namespace paddle_mobile {
namespace operators { namespace operators {
using namespace framework; using namespace framework;
template <typename DeviceType, typename T> template <typename DeviceType, typename T>
class ConvOp : public framework::OperatorWithKernel<DeviceType> { class ConvOp : public framework::OperatorWithKernel<DeviceType> {
public: public:
ConvOp(const std::string &type, const VariableNameMap &inputs, ConvOp(const std::string &type, const VariableNameMap &inputs,
const VariableNameMap &outputs, const framework::AttributeMap &attrs, const VariableNameMap &outputs,
const framework::AttributeMap &attrs,
std::shared_ptr<framework::Scope> scope) std::shared_ptr<framework::Scope> scope)
: framework::OperatorWithKernel<DeviceType>(type, inputs, outputs, attrs, : framework::OperatorWithKernel<DeviceType>(
scope), type, inputs, outputs, attrs, scope),
param_(inputs, outputs, attrs, *scope) {} param_(inputs, outputs, attrs, *scope) {}
using framework::OperatorWithKernel<DeviceType>::OperatorWithKernel; using framework::OperatorWithKernel<DeviceType>::OperatorWithKernel;
...@@ -45,9 +46,9 @@ public: ...@@ -45,9 +46,9 @@ public:
this->ClearVariables(); this->ClearVariables();
} }
private: private:
ConvParam param_; ConvParam param_;
}; };
} // operators } // operators
} // paddle_mobile } // paddle_mobile
...@@ -26,9 +26,9 @@ SOFTWARE. ...@@ -26,9 +26,9 @@ SOFTWARE.
#include <typeinfo> #include <typeinfo>
namespace paddle_mobile { namespace paddle_mobile {
namespace framework { namespace framework {
class Variable : public PaddleMobileObject { class Variable : public PaddleMobileObject {
public: public:
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,7 +40,8 @@ public: ...@@ -40,7 +40,8 @@ public:
template <typename T> T *GetMutable() { template <typename T> T *GetMutable() {
if (!IsType<T>()) { if (!IsType<T>()) {
if (*Name() == "pixel") { if (*Name() == "pixel") {
// std::cout << " reset " << *Name() << std::endl; // std::cout << " reset " << *Name() <<
// std::endl;
} }
holder_.reset(new PlaceholderImp<T>(new T())); holder_.reset(new PlaceholderImp<T>(new T()));
} }
...@@ -50,11 +51,12 @@ public: ...@@ -50,11 +51,12 @@ public:
template <typename T> bool IsType() const { template <typename T> bool IsType() const {
if (holder_) { if (holder_) {
// printf("not null \n"); // printf("not null \n");
printf(" holder type : %s, this type %s \n", holder_->Type().name(), printf(" holder type : %s, this type %s \n",
typeid(T).name()); holder_->Type().name(), typeid(T).name());
} }
// std::cout << " " << holder_->Type() << " " << typeid(T) << // std::cout << " " << holder_->Type() << " " <<
// typeid(T) <<
// std::endl; // std::endl;
return holder_ != nullptr && holder_->Type() == typeid(T); return holder_ != nullptr && holder_->Type() == typeid(T);
} }
...@@ -65,7 +67,7 @@ public: ...@@ -65,7 +67,7 @@ public:
void SetName(const std::string *name) { name_ = name; } void SetName(const std::string *name) { name_ = name; }
private: private:
struct Placeholder { struct Placeholder {
Placeholder() = default; Placeholder() = default;
virtual ~Placeholder() = default; virtual ~Placeholder() = default;
...@@ -89,6 +91,6 @@ private: ...@@ -89,6 +91,6 @@ private:
std::unique_ptr<Placeholder> holder_; std::unique_ptr<Placeholder> holder_;
friend class Scope; friend class Scope;
const std::string *name_; const std::string *name_;
}; };
} // namespace framework } // namespace framework
} // namespace paddle_mobile } // namespace paddle_mobile
...@@ -22,18 +22,19 @@ SOFTWARE. ...@@ -22,18 +22,19 @@ SOFTWARE.
#include "operators/kernel/conv_kernel.h" #include "operators/kernel/conv_kernel.h"
namespace paddle_mobile { namespace paddle_mobile {
namespace operators { namespace operators {
using namespace framework; using namespace framework;
template <typename DeviceType, typename T> template <typename DeviceType, typename T>
class ConvOp : public framework::OperatorWithKernel<DeviceType> { class ConvOp : public framework::OperatorWithKernel<DeviceType> {
public: public:
ConvOp(const std::string &type, const VariableNameMap &inputs, ConvOp(const std::string &type, const VariableNameMap &inputs,
const VariableNameMap &outputs, const framework::AttributeMap &attrs, const VariableNameMap &outputs,
const framework::AttributeMap &attrs,
std::shared_ptr<framework::Scope> scope) std::shared_ptr<framework::Scope> scope)
: framework::OperatorWithKernel<DeviceType>(type, inputs, outputs, attrs, : framework::OperatorWithKernel<DeviceType>(
scope), type, inputs, outputs, attrs, scope),
param_(inputs, outputs, attrs, *scope) {} param_(inputs, outputs, attrs, *scope) {}
using framework::OperatorWithKernel<DeviceType>::OperatorWithKernel; using framework::OperatorWithKernel<DeviceType>::OperatorWithKernel;
...@@ -45,9 +46,9 @@ public: ...@@ -45,9 +46,9 @@ public:
this->ClearVariables(); this->ClearVariables();
} }
private: private:
ConvParam param_; ConvParam param_;
}; };
} // operators } // operators
} // paddle_mobile } // paddle_mobile
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册