提交 71acaff1 编写于 作者: Q qingqing01

Tiny fix

上级 c7e8c1aa
...@@ -30,19 +30,20 @@ static void TransOpArg(const OperatorBase* src_op, OperatorBase* dst_op, ...@@ -30,19 +30,20 @@ static void TransOpArg(const OperatorBase* src_op, OperatorBase* dst_op,
bool is_grad) { bool is_grad) {
const auto& src_inout = const auto& src_inout =
src_type == OpArgType::IN ? src_op->inputs_ : src_op->outputs_; src_type == OpArgType::IN ? src_op->inputs_ : src_op->outputs_;
auto& dst_inout = auto& dst_inout =
dst_type == OpArgType::IN ? dst_op->inputs_ : dst_op->outputs_; dst_type == OpArgType::IN ? dst_op->inputs_ : dst_op->outputs_;
const OpProto& proto = OpRegistry::protos().at(src_op->type_);
const OpProto& proto = OpProtos().at(src_op->type_);
const auto& src_arg_list = const auto& src_arg_list =
src_type == OpArgType::IN ? proto.inputs() : proto.outputs(); src_type == OpArgType::IN ? proto.inputs() : proto.outputs();
for (const auto& arg : src_arg_list) { for (const auto& arg : src_arg_list) {
if (arg.no_gradient() && !is_grad) continue;
std::string src_name = arg.name(); std::string src_name = arg.name();
std::string dst_name = is_grad ? GradVarName(src_name) : src_name; std::string dst_name = is_grad ? GradVarName(src_name) : src_name;
dst_inout[dst_name].reserve(src_inout.at(src_name).size());
for (auto& var_name : src_inout.at(src_name)) { for (auto& var_name : src_inout.at(src_name)) {
std::string s = is_grad ? GradVarName(var_name) std::string s = is_grad ? GradVarName(var_name) : var_name;
: (arg.no_gradient() ? kEmptyVarName : var_name);
dst_inout[dst_name].emplace_back(s); dst_inout[dst_name].emplace_back(s);
} }
} }
......
...@@ -152,7 +152,7 @@ All parameter, weight, gradient are variables in Paddle. ...@@ -152,7 +152,7 @@ All parameter, weight, gradient are variables in Paddle.
//! @note: Be careful! PyBind will return std::string as an unicode, not //! @note: Be careful! PyBind will return std::string as an unicode, not
//! Python str. If you want a str object, you should cast them in Python. //! Python str. If you want a str object, you should cast them in Python.
m.def("get_all_op_protos", []() -> std::vector<py::bytes> { m.def("get_all_op_protos", []() -> std::vector<py::bytes> {
auto &protos = OpRegistry::protos(); auto &protos = OpProtos();
std::vector<py::bytes> ret_values; std::vector<py::bytes> ret_values;
for (auto it = protos.begin(); it != protos.end(); ++it) { for (auto it = protos.begin(); it != protos.end(); ++it) {
PADDLE_ENFORCE(it->second.IsInitialized(), PADDLE_ENFORCE(it->second.IsInitialized(),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册