提交 b8831606 编写于 作者: L liuruilong

format files

上级 30d22c55
此差异已折叠。
此差异已折叠。
...@@ -16,8 +16,8 @@ limitations under the License. */ ...@@ -16,8 +16,8 @@ limitations under the License. */
#include <map> #include <map>
#include <string> #include <string>
#include <vector>
#include <unordered_set> #include <unordered_set>
#include <vector>
#include "framework/attribute.h" #include "framework/attribute.h"
#include "framework/scope.h" #include "framework/scope.h"
......
...@@ -15,8 +15,8 @@ limitations under the License. */ ...@@ -15,8 +15,8 @@ limitations under the License. */
#pragma once #pragma once
#include <unordered_map> #include <unordered_map>
#include "common/log.h"
#include "common/enforce.h" #include "common/enforce.h"
#include "common/log.h"
#include "common/variant.h" #include "common/variant.h"
#include "framework/framework.pb-c.h" #include "framework/framework.pb-c.h"
...@@ -27,7 +27,6 @@ class BlockDesc; ...@@ -27,7 +27,6 @@ class BlockDesc;
class Attribute { class Attribute {
public: public:
/* /*
* PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__INT = 0, * PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__INT = 0,
PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__FLOAT = 1, PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__FLOAT = 1,
...@@ -42,7 +41,8 @@ class Attribute { ...@@ -42,7 +41,8 @@ class Attribute {
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE) PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE)
* *
* */ * */
static Attribute GetAttrValue(PaddleMobile__Framework__Proto__OpDesc__Attr *attr_desc) { static Attribute GetAttrValue(
PaddleMobile__Framework__Proto__OpDesc__Attr *attr_desc) {
// std::cout << "begin get attr value" << std::endl; // std::cout << "begin get attr value" << std::endl;
Attribute attr; Attribute attr;
switch (attr_desc->type) { switch (attr_desc->type) {
......
此差异已折叠。
此差异已折叠。
...@@ -33,17 +33,18 @@ std::vector<std::shared_ptr<OpDesc>> BlockDesc::Ops() const { ...@@ -33,17 +33,18 @@ std::vector<std::shared_ptr<OpDesc>> BlockDesc::Ops() const {
return res; return res;
} }
BlockDesc::BlockDesc(PaddleMobile__Framework__Proto__BlockDesc *desc): index_(desc->idx), parent_index_(desc->idx) { BlockDesc::BlockDesc(PaddleMobile__Framework__Proto__BlockDesc *desc)
: index_(desc->idx), parent_index_(desc->idx) {
for (int i = 0; i < desc->n_vars; ++i) { for (int i = 0; i < desc->n_vars; ++i) {
PaddleMobile__Framework__Proto__VarDesc *var_desc = desc->vars[i]; PaddleMobile__Framework__Proto__VarDesc *var_desc = desc->vars[i];
vars_[std::string(var_desc->name)] = std::shared_ptr<VarDesc>(new VarDesc(var_desc)); vars_[std::string(var_desc->name)] =
std::shared_ptr<VarDesc>(new VarDesc(var_desc));
} }
for (int j = 0; j < desc->n_ops; ++j) { for (int j = 0; j < desc->n_ops; ++j) {
PaddleMobile__Framework__Proto__OpDesc *op_desc = desc->ops[j]; PaddleMobile__Framework__Proto__OpDesc *op_desc = desc->ops[j];
ops_.emplace_back(new framework::OpDesc(op_desc)); ops_.emplace_back(new framework::OpDesc(op_desc));
} }
} }
} // namespace framework } // namespace framework
......
...@@ -15,9 +15,9 @@ limitations under the License. */ ...@@ -15,9 +15,9 @@ limitations under the License. */
#pragma once #pragma once
#include "framework/framework.pb-c.h" #include "framework/framework.pb-c.h"
#include "framework/paddle_mobile_object.h"
#include "framework/program/op_desc.h" #include "framework/program/op_desc.h"
#include "framework/program/var_desc.h" #include "framework/program/var_desc.h"
#include "framework/paddle_mobile_object.h"
namespace paddle_mobile { namespace paddle_mobile {
namespace framework { namespace framework {
......
...@@ -15,8 +15,8 @@ limitations under the License. */ ...@@ -15,8 +15,8 @@ limitations under the License. */
#include <string> #include <string>
#include <vector> #include <vector>
#include "program_desc.h"
#include "framework/program/tensor_desc.h" #include "framework/program/tensor_desc.h"
#include "program_desc.h"
namespace paddle_mobile { namespace paddle_mobile {
namespace framework { namespace framework {
...@@ -70,7 +70,6 @@ void ProgramDesc::Description(std::string header) { ...@@ -70,7 +70,6 @@ void ProgramDesc::Description(std::string header) {
} }
} }
} }
} }
#endif #endif
} }
......
/* 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. */
// //
// Created by liuRuiLong on 2018/5/26. // Created by liuRuiLong on 2018/5/26.
// //
......
...@@ -21,26 +21,26 @@ limitations under the License. */ ...@@ -21,26 +21,26 @@ limitations under the License. */
namespace paddle_mobile { namespace paddle_mobile {
namespace framework { namespace framework {
enum VarType_Type{ enum VarType_Type {
VARTYPE_TYPE_BOOL = 0, VARTYPE_TYPE_BOOL = 0,
VARTYPE_TYPE_INT16 = 1, VARTYPE_TYPE_INT16 = 1,
VARTYPE_TYPE_INT32 = 2, VARTYPE_TYPE_INT32 = 2,
VARTYPE_TYPE_INT64 = 3, VARTYPE_TYPE_INT64 = 3,
VARTYPE_TYPE_FP16 = 4, VARTYPE_TYPE_FP16 = 4,
VARTYPE_TYPE_FP32 = 5, VARTYPE_TYPE_FP32 = 5,
VARTYPE_TYPE_FP64 = 6, VARTYPE_TYPE_FP64 = 6,
VARTYPE_TYPE_LOD_TENSOR = 7, VARTYPE_TYPE_LOD_TENSOR = 7,
VARTYPE_TYPE_SELECTED_ROWS = 8, VARTYPE_TYPE_SELECTED_ROWS = 8,
VARTYPE_TYPE_FEED_MINIBATCH = 9, VARTYPE_TYPE_FEED_MINIBATCH = 9,
VARTYPE_TYPE_FETCH_LIST = 10, VARTYPE_TYPE_FETCH_LIST = 10,
VARTYPE_TYPE_STEP_SCOPES = 11, VARTYPE_TYPE_STEP_SCOPES = 11,
VARTYPE_TYPE_STEP_LOD_RANK_TABLE = 12, VARTYPE_TYPE_STEP_LOD_RANK_TABLE = 12,
VARTYPE_TYPE_STEP_LOD_TENSOR_ARRAY = 13, VARTYPE_TYPE_STEP_LOD_TENSOR_ARRAY = 13,
VARTYPE_TYPE_STEP_PLACE_LIST = 14, VARTYPE_TYPE_STEP_PLACE_LIST = 14,
VARTYPE_TYPE_READER = 15, VARTYPE_TYPE_READER = 15,
VARTYPE_TYPE_CHANNEL = 16, VARTYPE_TYPE_CHANNEL = 16,
VARTYPE_TYPE_RAW = 17, VARTYPE_TYPE_RAW = 17,
VARTYPE_TYPE_TUPLE = 18 VARTYPE_TYPE_TUPLE = 18
}; };
class TensorDesc { class TensorDesc {
...@@ -59,17 +59,13 @@ class TensorDesc { ...@@ -59,17 +59,13 @@ class TensorDesc {
data_type_ = (VarType_Type)desc->data_type; data_type_ = (VarType_Type)desc->data_type;
} }
std::vector<int64_t> Dims() const { std::vector<int64_t> Dims() const { return dims_; };
return dims_; VarType_Type DataType() const { return data_type_; }
};
VarType_Type DataType() const {
return data_type_;
}
private: private:
std::vector<int64_t> dims_; std::vector<int64_t> dims_;
VarType_Type data_type_; VarType_Type data_type_;
}; };
} } // namespace framework
} } // namespace paddle_mobile
...@@ -16,8 +16,5 @@ limitations under the License. */ ...@@ -16,8 +16,5 @@ limitations under the License. */
namespace paddle_mobile { namespace paddle_mobile {
namespace framework { namespace framework {} // namespace framework
} // namespace framework
} // namespace paddle_mobile } // namespace paddle_mobile
此差异已折叠。
此差异已折叠。
...@@ -33,7 +33,9 @@ class Loader : PaddleMobileObject { ...@@ -33,7 +33,9 @@ class Loader : PaddleMobileObject {
const framework::Program<Dtype, P> Load(const std::string &dirname); const framework::Program<Dtype, P> Load(const std::string &dirname);
private: private:
void LoadVar(framework::Variable *variable, const framework::VarDesc &var_desc, const std::string &file_path); void LoadVar(framework::Variable *variable,
const framework::VarDesc &var_desc,
const std::string &file_path);
}; };
template <typename Dtype, Precision P = Precision::FP32> template <typename Dtype, Precision P = Precision::FP32>
...@@ -52,7 +54,8 @@ class Executor { ...@@ -52,7 +54,8 @@ class Executor {
protected: protected:
void InitMemory(); void InitMemory();
void LoadMemory(const framework::VarDesc var_desc, framework::LoDTensor *tensor, const std::string &file_path); void LoadMemory(const framework::VarDesc var_desc,
framework::LoDTensor *tensor, const std::string &file_path);
framework::Program<Dtype> program_; framework::Program<Dtype> program_;
std::shared_ptr<framework::ProgramDesc> to_predict_program_; std::shared_ptr<framework::ProgramDesc> to_predict_program_;
void predict(const framework::Tensor &t, int block_id); void predict(const framework::Tensor &t, int block_id);
......
...@@ -116,8 +116,7 @@ inline std::string DataTypeToString(const VarType_Type type) { ...@@ -116,8 +116,7 @@ inline std::string DataTypeToString(const VarType_Type type) {
} }
} }
inline std::ostream &operator<<(std::ostream &out, inline std::ostream &operator<<(std::ostream &out, const VarType_Type &type) {
const VarType_Type &type) {
out << DataTypeToString(type); out << DataTypeToString(type);
return out; return out;
} }
......
...@@ -58,7 +58,6 @@ class Executor4Test : public Executor<DeviceType> { ...@@ -58,7 +58,6 @@ class Executor4Test : public Executor<DeviceType> {
for (std::shared_ptr<BlockDesc> block_desc : blocks) { for (std::shared_ptr<BlockDesc> block_desc : blocks) {
std::vector<std::shared_ptr<OpDesc>> ops = block_desc->Ops(); std::vector<std::shared_ptr<OpDesc>> ops = block_desc->Ops();
for (std::shared_ptr<OpDesc> op : ops) { for (std::shared_ptr<OpDesc> op : ops) {
if (op->Type() == op_type) { if (op->Type() == op_type) {
/// test first meeting op in program /// test first meeting op in program
std::shared_ptr<paddle_mobile::framework::OperatorBase<DeviceType>> std::shared_ptr<paddle_mobile::framework::OperatorBase<DeviceType>>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册