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

Fix compile errors

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