提交 6285edbb 编写于 作者: F fengjiayi

Fix compile errors

上级 54ef4cda
...@@ -18,9 +18,8 @@ cc_test(scope_test SRCS scope_test.cc DEPS scope) ...@@ -18,9 +18,8 @@ cc_test(scope_test SRCS scope_test.cc DEPS scope)
proto_library(framework_proto SRCS framework.proto) proto_library(framework_proto SRCS framework.proto)
cc_library(var_desc SRCS var_desc.cc DEPS framework_proto)
cc_library(attribute SRCS attribute.cc DEPS framework_proto) cc_library(attribute SRCS attribute.cc DEPS framework_proto)
cc_library(proto_desc SRCS var_desc.cc op_desc.cc block_desc.cc program_desc.cc DEPS attribute)
cc_library(op_proto_maker SRCS op_proto_maker.cc DEPS framework_proto attribute) cc_library(op_proto_maker SRCS op_proto_maker.cc DEPS framework_proto attribute)
cc_test(op_proto_maker_test SRCS op_proto_maker_test.cc DEPS op_proto_maker) cc_test(op_proto_maker_test SRCS op_proto_maker_test.cc DEPS op_proto_maker)
cc_library(op_info SRCS op_info.cc DEPS attribute framework_proto) cc_library(op_info SRCS op_info.cc DEPS attribute framework_proto)
......
...@@ -13,8 +13,7 @@ See the License for the specific language governing permissions and ...@@ -13,8 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#include "paddle/framework/block_desc.h" #include "paddle/framework/block_desc.h"
#include "paddle/framework/op_desc.h" #include "paddle/framework/program_desc.h"
#include "paddle/framework/var_desc.h"
namespace paddle { namespace paddle {
namespace framework { namespace framework {
...@@ -86,5 +85,5 @@ void OpDescBind::SetBlockAttr(const std::string &name, BlockDescBind &block) { ...@@ -86,5 +85,5 @@ void OpDescBind::SetBlockAttr(const std::string &name, BlockDescBind &block) {
BlockDesc *desc = block.RawPtr(); BlockDesc *desc = block.RawPtr();
this->attrs_[name] = desc; this->attrs_[name] = desc;
} }
} } // namespace framework
} } // namespace paddle
\ No newline at end of file
...@@ -14,16 +14,16 @@ limitations under the License. */ ...@@ -14,16 +14,16 @@ limitations under the License. */
#pragma once #pragma once
#include <deque>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "paddle/framework/framework.pb.h" #include "paddle/framework/op_desc.h"
#include "paddle/framework/var_desc.h"
namespace paddle { namespace paddle {
namespace framework { namespace framework {
class ProgramDescBind; class ProgramDescBind;
class OpDescBind;
class VarDescBind;
// Each Protobuf Message, we provide a XXXBind class. In that class, we optimize // Each Protobuf Message, we provide a XXXBind class. In that class, we optimize
// read/write speed. Only when we want the protobuf message, the local changes // read/write speed. Only when we want the protobuf message, the local changes
...@@ -67,5 +67,5 @@ class BlockDescBind { ...@@ -67,5 +67,5 @@ class BlockDescBind {
std::deque<std::unique_ptr<OpDescBind>> ops_; std::deque<std::unique_ptr<OpDescBind>> ops_;
std::unordered_map<std::string, std::unique_ptr<VarDescBind>> vars_; std::unordered_map<std::string, std::unique_ptr<VarDescBind>> vars_;
}; };
} } // namespace framework
} } // namespace paddle
...@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and ...@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#include "paddle/framework/op_desc.h" #include "paddle/framework/op_desc.h"
#include "paddle/frameword/block_desc.h" #include "paddle/framework/block_desc.h"
namespace paddle { namespace paddle {
namespace framework { namespace framework {
...@@ -129,5 +129,5 @@ void OpDescBind::Sync() { ...@@ -129,5 +129,5 @@ void OpDescBind::Sync() {
need_update_ = false; need_update_ = false;
} }
} }
} } // namespace framework
} } // namespace paddle
\ No newline at end of file
...@@ -102,5 +102,5 @@ class OpDescBind { ...@@ -102,5 +102,5 @@ class OpDescBind {
// local changes should be synchronized, need_update_ should be set to true. // local changes should be synchronized, need_update_ should be set to true.
bool need_update_{false}; bool need_update_{false};
}; };
} } // namespace framework
} } // namespace paddle
...@@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ...@@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#include "paddle/farmework/block_desc.h" #include "paddle/framework/program_desc.h"
#include "paddle/framework/programe_desc.h" #include "paddle/framework/block_desc.h"
namespace paddle { namespace paddle {
namespace framework { namespace framework {
...@@ -56,5 +56,5 @@ ProgramDescBind::ProgramDescBind(ProgramDesc *prog) { ...@@ -56,5 +56,5 @@ ProgramDescBind::ProgramDescBind(ProgramDesc *prog) {
blocks_.emplace_back(new BlockDescBind(this, &block)); blocks_.emplace_back(new BlockDescBind(this, &block));
} }
} }
} } // namespace framework
} } // namespace paddle
\ No newline at end of file
...@@ -47,5 +47,5 @@ class ProgramDescBind { ...@@ -47,5 +47,5 @@ class ProgramDescBind {
std::vector<std::unique_ptr<BlockDescBind>> blocks_; std::vector<std::unique_ptr<BlockDescBind>> blocks_;
}; };
} } // namespace framework
} } // namespace paddle
...@@ -32,5 +32,5 @@ std::vector<int64_t> VarDescBind::Shape() const { ...@@ -32,5 +32,5 @@ std::vector<int64_t> VarDescBind::Shape() const {
DataType VarDescBind::DataType() const { DataType VarDescBind::DataType() const {
return desc_.lod_tensor().data_type(); return desc_.lod_tensor().data_type();
} }
} } // namespace framework
} } // namespace paddle
\ No newline at end of file
...@@ -69,5 +69,5 @@ class VarDescBind { ...@@ -69,5 +69,5 @@ class VarDescBind {
private: private:
VarDesc desc_; VarDesc desc_;
}; };
} } // namespace framework
} } // namespace paddle
if(WITH_PYTHON) if(WITH_PYTHON)
cc_library(paddle_pybind SHARED cc_library(paddle_pybind SHARED
SRCS pybind.cc exception.cc protobuf.cc SRCS pybind.cc exception.cc protobuf.cc
DEPS pybind python backward DEPS pybind python backward proto_desc
${GLOB_OP_LIB}) ${GLOB_OP_LIB})
endif(WITH_PYTHON) endif(WITH_PYTHON)
...@@ -94,61 +94,61 @@ struct type_caster<boost::variant<Args...>> ...@@ -94,61 +94,61 @@ struct type_caster<boost::variant<Args...>>
namespace paddle { namespace paddle {
namespace pybind { namespace pybind {
using namespace paddle::framework; // NOLINT
// Bind Methods // Bind Methods
void BindProgramDesc(py::module &m) { void BindProgramDesc(py::module &m) {
py::class_<framework::ProgramDescBind>(m, "ProgramDesc", "") py::class_<ProgramDescBind>(m, "ProgramDesc", "")
.def_static( .def_static("instance",
"instance", []() -> ProgramDescBind * {
[]() -> framework::ProgramDescBind * { return &ProgramDescBind::Instance(&GetProgramDesc());
return &framework::ProgramDescBind::Instance(&GetProgramDesc()); },
}, py::return_value_policy::reference)
py::return_value_policy::reference)
.def_static("__create_program_desc__", .def_static("__create_program_desc__",
[]() -> framework::ProgramDescBind * { []() -> ProgramDescBind * {
// Only used for unit-test // Only used for unit-test
auto *prog_desc = new ProgramDesc; auto *prog_desc = new ProgramDesc;
auto *block = prog_desc->mutable_blocks()->Add(); auto *block = prog_desc->mutable_blocks()->Add();
block->set_idx(0); block->set_idx(0);
block->set_parent_idx(-1); block->set_parent_idx(-1);
return &framework::ProgramDescBind::Instance(prog_desc); return &ProgramDescBind::Instance(prog_desc);
}, },
py::return_value_policy::reference) py::return_value_policy::reference)
.def("append_block", &framework::ProgramDescBind::AppendBlock, .def("append_block", &ProgramDescBind::AppendBlock,
py::return_value_policy::reference) py::return_value_policy::reference)
.def("block", &framework::ProgramDescBind::Block, .def("block", &ProgramDescBind::Block, py::return_value_policy::reference)
py::return_value_policy::reference) .def("__str__", &ProgramDescBind::DebugString)
.def("__str__", &framework::ProgramDescBind::DebugString) .def("num_blocks", &ProgramDescBind::Size);
.def("num_blocks", &framework::ProgramDescBind::Size);
} }
void BindBlockDesc(py::module &m) { void BindBlockDesc(py::module &m) {
py::class_<framework::BlockDescBind>(m, "BlockDesc", "") py::class_<BlockDescBind>(m, "BlockDesc", "")
.def_property_readonly("id", &framework::BlockDescBind::ID) .def_property_readonly("id", &BlockDescBind::ID)
.def_property_readonly("parent", &framework::BlockDescBind::Parent) .def_property_readonly("parent", &BlockDescBind::Parent)
.def("append_op", &framework::BlockDescBind::AppendOp, .def("append_op", &BlockDescBind::AppendOp,
py::return_value_policy::reference) py::return_value_policy::reference)
.def("prepend_op", &framework::BlockDescBind::PrependOp, .def("prepend_op", &BlockDescBind::PrependOp,
py::return_value_policy::reference) py::return_value_policy::reference)
.def("new_var", .def("new_var",
[](framework::BlockDescBind &self, py::bytes byte_name) { [](BlockDescBind &self, py::bytes byte_name) {
std::string name = byte_name; std::string name = byte_name;
return self.NewVar(name); return self.NewVar(name);
}, },
py::return_value_policy::reference) py::return_value_policy::reference)
.def("var", .def("var",
[](framework::BlockDescBind &self, py::bytes byte_name) { [](BlockDescBind &self, py::bytes byte_name) {
std::string name = byte_name; std::string name = byte_name;
return self.Var(name); return self.Var(name);
}, },
py::return_value_policy::reference) py::return_value_policy::reference)
.def("all_vars", &framework::BlockDescBind::AllVars, .def("all_vars", &BlockDescBind::AllVars,
py::return_value_policy::reference) py::return_value_policy::reference)
.def("all_ops", &framework::BlockDescBind::AllOps, .def("all_ops", &BlockDescBind::AllOps,
py::return_value_policy::reference); py::return_value_policy::reference);
} }
void BindVarDsec(py::module &m) { void BindVarDsec(py::module &m) {
py::enum_<framework::DataType>(m, "DataType", "") py::enum_<DataType>(m, "DataType", "")
.value("BOOL", DataType::BOOL) .value("BOOL", DataType::BOOL)
.value("INT16", DataType::INT16) .value("INT16", DataType::INT16)
.value("INT32", DataType::INT32) .value("INT32", DataType::INT32)
...@@ -157,22 +157,21 @@ void BindVarDsec(py::module &m) { ...@@ -157,22 +157,21 @@ void BindVarDsec(py::module &m) {
.value("FP32", DataType::FP32) .value("FP32", DataType::FP32)
.value("FP64", DataType::FP64); .value("FP64", DataType::FP64);
py::class_<framework::VarDescBind>(m, "VarDesc", "") py::class_<VarDescBind>(m, "VarDesc", "")
.def("name", .def("name",
[](const framework::framework::VarDescBind &self) { [](const VarDescBind &self) {
py::bytes name = self.Name(); py::bytes name = self.Name();
return name; return name;
}, },
py::return_value_policy::reference) py::return_value_policy::reference)
.def("set_shape", &framework::VarDescBind::SetShape) .def("set_shape", &VarDescBind::SetShape)
.def("set_data_type", &framework::VarDescBind::SetDataType) .def("set_data_type", &VarDescBind::SetDataType)
.def("shape", &framework::VarDescBind::Shape, .def("shape", &VarDescBind::Shape, py::return_value_policy::reference)
py::return_value_policy::reference) .def("data_type", &VarDescBind::DataType);
.def("data_type", &framework::VarDescBind::DataType);
} }
void BindOpDesc(py::module &m) { void BindOpDesc(py::module &m) {
py::enum_<framework::AttrType>(m, "AttrType", "") py::enum_<AttrType>(m, "AttrType", "")
.value("INT", AttrType::INT) .value("INT", AttrType::INT)
.value("INTS", AttrType::INTS) .value("INTS", AttrType::INTS)
.value("FLOAT", AttrType::FLOAT) .value("FLOAT", AttrType::FLOAT)
...@@ -183,24 +182,24 @@ void BindOpDesc(py::module &m) { ...@@ -183,24 +182,24 @@ void BindOpDesc(py::module &m) {
.value("BOOLS", AttrType::BOOLEANS) .value("BOOLS", AttrType::BOOLEANS)
.value("BLOCK", AttrType::BLOCK); .value("BLOCK", AttrType::BLOCK);
py::class_<framework::OpDescBind> op_desc(m, "OpDesc", ""); py::class_<OpDescBind> op_desc(m, "OpDesc", "");
op_desc.def("type", &framework::OpDescBind::Type) op_desc.def("type", &OpDescBind::Type)
.def("set_type", &framework::OpDescBind::SetType) .def("set_type", &OpDescBind::SetType)
.def("input", &framework::OpDescBind::Input) .def("input", &OpDescBind::Input)
.def("input_names", &framework::OpDescBind::InputNames) .def("input_names", &OpDescBind::InputNames)
.def("set_input", &framework::OpDescBind::SetInput) .def("set_input", &OpDescBind::SetInput)
.def("output", &framework::OpDescBind::Output) .def("output", &OpDescBind::Output)
.def("output_names", &framework::OpDescBind::OutputNames) .def("output_names", &OpDescBind::OutputNames)
.def("set_output", &framework::OpDescBind::SetOutput) .def("set_output", &OpDescBind::SetOutput)
.def("__str__", &framework::OpDescBind::DebugString) .def("__str__", &OpDescBind::DebugString)
.def("__repr__", &framework::OpDescBind::DebugString) .def("__repr__", &OpDescBind::DebugString)
.def("has_attr", &framework::OpDescBind::HasAttr) .def("has_attr", &OpDescBind::HasAttr)
.def("attr_type", &framework::OpDescBind::GetAttrType) .def("attr_type", &OpDescBind::GetAttrType)
.def("attr_names", &framework::OpDescBind::AttrNames) .def("attr_names", &OpDescBind::AttrNames)
.def("set_attr", &framework::OpDescBind::SetAttr) .def("set_attr", &OpDescBind::SetAttr)
.def("attr", &framework::OpDescBind::GetAttr) .def("attr", &OpDescBind::GetAttr)
.def("set_block_attr", &framework::OpDescBind::SetBlockAttr) .def("set_block_attr", &OpDescBind::SetBlockAttr)
.def("get_block_attr", &framework::OpDescBind::GetBlockAttr); .def("get_block_attr", &OpDescBind::GetBlockAttr);
} }
} // namespace pybind } // namespace pybind
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册