diff --git a/paddle/framework/backward.cc b/paddle/framework/backward.cc index 36cc616358e5923b63a365bd8d24eafc980c7cf6..315bdde76d3ffe57b656aa69688def6d274f592c 100644 --- a/paddle/framework/backward.cc +++ b/paddle/framework/backward.cc @@ -31,7 +31,7 @@ static void ForEachVarName(Map& names, T callback) { } static bool AllInSet( - const std::unordered_map>& names, + const std::map>& names, const std::string& suffix, const std::unordered_set& set) { bool all_in_set = true; ForEachVarName(names, [&all_in_set, &set, &suffix](const std::string& n) { diff --git a/paddle/framework/grad_op_builder_test.cc b/paddle/framework/grad_op_builder_test.cc index 85e745322b9b8ad9d73791387644915100e3926b..f54a66110f26053ed5a03e8c3c40de3682647684 100644 --- a/paddle/framework/grad_op_builder_test.cc +++ b/paddle/framework/grad_op_builder_test.cc @@ -68,10 +68,9 @@ REGISTER_GRADIENT_OP(io_ignored, io_ignored_grad, f::NOP); TEST(GradOpBuilder, MutiInOut) { std::shared_ptr test_op(f::OpRegistry::CreateOp( - "mult_io", - {{"In1", {"in1"}}, - {"In2_mult", {"in2_1", "in2_2", "in2_3"}}, - {"In3", {"in3"}}}, + "mult_io", {{"In1", {"in1"}}, + {"In2_mult", {"in2_1", "in2_2", "in2_3"}}, + {"In3", {"in3"}}}, {{"Out1", {"out1"}}, {"Out2_mult", {"out2_1", "out2_2"}}}, {})); std::shared_ptr grad_test_op = f::OpRegistry::CreateGradOp(*test_op); @@ -101,10 +100,9 @@ TEST(GradOpBuilder, MutiInOut) { TEST(GradOpBuilder, IOIgnoredInGradient) { std::shared_ptr test_op(f::OpRegistry::CreateOp( - "io_ignored", - {{"In1", {"in1"}}, - {"In2_mult", {"in2_1", "in2_2"}}, - {"In3_mult", {"in3_1", "in3_2"}}}, + "io_ignored", {{"In1", {"in1"}}, + {"In2_mult", {"in2_1", "in2_2"}}, + {"In3_mult", {"in3_1", "in3_2"}}}, {{"Out1_mult", {"out1_1", "out1_2"}}, {"Out2", {"out2"}}}, {})); std::shared_ptr grad_test_op = f::OpRegistry::CreateGradOp(*test_op); diff --git a/paddle/framework/op_registry.h b/paddle/framework/op_registry.h index f2236e60d8dc118cc5f34df7dc5d1817c21ce595..f6b71a4efdc347b3fcc79dcbdbc1caa708024b20 100644 --- a/paddle/framework/op_registry.h +++ b/paddle/framework/op_registry.h @@ -118,7 +118,7 @@ class OpProtoAndCheckerMaker { class OpRegistry { using OpCreator = std::function; - using VarNameMap = std::unordered_map>; + using VarNameMap = std::map>; public: template diff --git a/paddle/framework/operator.h b/paddle/framework/operator.h index 6dc331b2f0c13cf35fe35cc2aefd73fdd1b93a83..5ed199adc67ba91a37f4568c59864b88fbf02742 100644 --- a/paddle/framework/operator.h +++ b/paddle/framework/operator.h @@ -143,11 +143,11 @@ class OperatorBase { // I (Inputs) // O (Outputs) // OG (Output Gradients) - std::unordered_map> inputs_; + std::map> inputs_; // NOTE: in case of OpGrad, outputs_ contains // IG (Inputs Gradients) - std::unordered_map> outputs_; + std::map> outputs_; AttributeMap attrs_; }; diff --git a/paddle/framework/pybind.cc b/paddle/framework/pybind.cc index 05ed603e1a39d5ac3cc57592f2848f155b2d71fe..07b42c83717652bdf0120b3004f39ac7f7a98d06 100644 --- a/paddle/framework/pybind.cc +++ b/paddle/framework/pybind.cc @@ -57,15 +57,17 @@ void ExposeOperator(ClassType &m) { }) .def("outputs", [](const typename ClassType::type &op) - -> std::unordered_map> { + -> std::map> { return op.outputs_; }) .def("inputs", [](const typename ClassType::type &op) { return op.inputs_; }) .def("__str__", &ClassType::type::DebugString) - .def("no_intermediate_outputs", [](const typename ClassType::type &op) { - return op.OutputVars(false); - }); + .def("no_intermediate_outputs", + [](const typename ClassType::type &op) { + return op.OutputVars(false); + }) + .def("support_gpu", &ClassType::type::SupportGPU); } static size_t UniqueIntegerGenerator() {