From 7c808ee79221bcf840cb2e039838b24d7c0a40f2 Mon Sep 17 00:00:00 2001 From: yujianfeng Date: Sat, 27 Nov 2021 15:06:49 +0800 Subject: [PATCH] Add some bprop mindir files --- .../ccsrc/frontend/optimizer/ad/kprim.cc | 86 ++++-- .../transform/express_ir/mindir_exporter.cc | 8 +- mindspore/ccsrc/utils/primitive_utils.cc | 12 +- .../core/load_mindir/anf_model_parser.cc | 10 +- mindspore/ops/_grad/grad_array_ops.py | 12 + mindspore/ops/_grad/grad_comm_ops.py | 1 + mindspore/ops/_grad/grad_math_ops.py | 24 ++ mindspore/ops/_grad/grad_nn_ops.py | 6 + mindspore/ops/_grad/grad_other_ops.py | 2 + mindspore/ops/_grad/grad_quant_ops.py | 1 + .../ApproximateEqual_bprop.mindir | 2 +- .../ops/bprop_mindir/Argmax_bprop.mindir | 2 +- .../ops/bprop_mindir/Argmin_bprop.mindir | 2 +- .../ops/bprop_mindir/AssignAdd_bprop.mindir | 2 +- .../ops/bprop_mindir/AssignSub_bprop.mindir | 2 +- .../ops/bprop_mindir/Assign_bprop.mindir | 2 +- .../BNTrainingReduce_bprop.mindir | 2 +- .../ops/bprop_mindir/Broadcast_bprop.mindir | 2 +- mindspore/ops/bprop_mindir/DType_bprop.mindir | 10 + .../ops/bprop_mindir/Depend_bprop.mindir | 12 + .../bprop_mindir/DropoutDoMask_bprop.mindir | 2 +- .../bprop_mindir/DropoutGenMask_bprop.mindir | 2 +- .../bprop_mindir/DynamicShape_bprop.mindir | 10 + mindspore/ops/bprop_mindir/Equal_bprop.mindir | 2 +- .../ops/bprop_mindir/FloorDiv_bprop.mindir | 14 + .../bprop_mindir/GreaterEqual_bprop.mindir | 2 +- .../ops/bprop_mindir/Greater_bprop.mindir | 2 +- mindspore/ops/bprop_mindir/IOU_bprop.mindir | 2 +- .../ops/bprop_mindir/Identity_bprop.mindir | 2 +- .../ops/bprop_mindir/IsFinite_bprop.mindir | 2 +- mindspore/ops/bprop_mindir/IsInf_bprop.mindir | 10 + mindspore/ops/bprop_mindir/IsNan_bprop.mindir | 10 + .../ops/bprop_mindir/LessEqual_bprop.mindir | 2 +- mindspore/ops/bprop_mindir/Less_bprop.mindir | 2 +- .../ops/bprop_mindir/LinSpace_bprop.mindir | 2 +- mindspore/ops/bprop_mindir/Load_bprop.mindir | 12 + .../ops/bprop_mindir/LogicalAnd_bprop.mindir | 2 +- .../ops/bprop_mindir/LogicalNot_bprop.mindir | 2 +- .../ops/bprop_mindir/LogicalOr_bprop.mindir | 2 +- .../ops/bprop_mindir/Maximum_bprop.mindir | Bin 0 -> 924 bytes .../ops/bprop_mindir/Minimum_bprop.mindir | Bin 0 -> 924 bytes .../ops/bprop_mindir/NotEqual_bprop.mindir | 2 +- .../ops/bprop_mindir/OneHot_bprop.mindir | 2 +- .../ops/bprop_mindir/OnesLike_bprop.mindir | 2 +- mindspore/ops/bprop_mindir/Range_bprop.mindir | 2 +- mindspore/ops/bprop_mindir/Rank_bprop.mindir | 10 + .../ops/bprop_mindir/ReLUV2_bprop.mindir | Bin 0 -> 932 bytes mindspore/ops/bprop_mindir/ReLU_bprop.mindir | 11 +- .../ops/bprop_mindir/ReduceAll_bprop.mindir | 2 +- .../ops/bprop_mindir/ReduceAny_bprop.mindir | 2 +- .../ops/bprop_mindir/ReluGrad_bprop.mindir | 18 ++ mindspore/ops/bprop_mindir/Round_bprop.mindir | 2 +- .../ops/bprop_mindir/ScatterMax_bprop.mindir | Bin 0 -> 888 bytes .../ops/bprop_mindir/Select_bprop.mindir | 31 ++ mindspore/ops/bprop_mindir/Shape_bprop.mindir | 10 + mindspore/ops/bprop_mindir/Sign_bprop.mindir | 2 +- .../ops/bprop_mindir/Switch_bprop.mindir | 27 ++ .../ops/bprop_mindir/TruncateDiv_bprop.mindir | 14 + .../bprop_mindir/TupleGetItem_bprop.mindir | 18 ++ .../ops/bprop_mindir/UpdateState_bprop.mindir | 14 + .../ops/bprop_mindir/ZerosLike_bprop.mindir | 2 +- mindspore/ops/bprop_mindir/generate_mindir.py | 17 +- .../bprop_mindir/stop_gradient_bprop.mindir | 10 + .../ut/python/optimizer/test_bprop_mindir.py | 286 +++++++++++++++++- tests/vm_impl/array_ops_vm_impl.py | 1 + tests/vm_impl/nn_ops_vm_impl.py | 1 + tests/vm_impl/vm_impl_function.py | 23 -- 67 files changed, 691 insertions(+), 102 deletions(-) create mode 100644 mindspore/ops/bprop_mindir/DType_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/Depend_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/DynamicShape_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/FloorDiv_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/IsInf_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/IsNan_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/Load_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/Maximum_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/Minimum_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/Rank_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/ReLUV2_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/ReluGrad_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/ScatterMax_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/Select_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/Shape_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/Switch_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/TruncateDiv_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/TupleGetItem_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/UpdateState_bprop.mindir create mode 100644 mindspore/ops/bprop_mindir/stop_gradient_bprop.mindir delete mode 100644 tests/vm_impl/vm_impl_function.py diff --git a/mindspore/ccsrc/frontend/optimizer/ad/kprim.cc b/mindspore/ccsrc/frontend/optimizer/ad/kprim.cc index 38f3ad45107..3cd7fac3efe 100644 --- a/mindspore/ccsrc/frontend/optimizer/ad/kprim.cc +++ b/mindspore/ccsrc/frontend/optimizer/ad/kprim.cc @@ -93,13 +93,17 @@ mindspore::HashSet GetSerializableBpropList() { } auto ops_list = serializable_bprop_ops_attr.cast(); - for (size_t i = 0; i < ops_list.size(); ++i) { - auto prim_adapter = ops_list[i].cast(); - if (prim_adapter == nullptr) { - MS_LOG(EXCEPTION) << "The python obj in serializable bprop list should be a Primitive, but it is " - << py::str(ops_list[i]); + for (auto op : ops_list) { + if (py::isinstance(op)) { + serializable_bprop_list.insert(op.cast()); + continue; } - serializable_bprop_list.insert(prim_adapter->name()); + py::object prim_name = op.attr("__name__"); + if (!py::isinstance(prim_name)) { + MS_LOG(WARNING) << "The name of obj " << py::str(op) << " to be exported to mindir should be a string"; + continue; + } + serializable_bprop_list.insert(prim_name.cast()); } return serializable_bprop_list; } @@ -185,20 +189,23 @@ FuncGraphPtr ImportBpropFromMindIR(const PrimitivePtr &prim) { } MindIRLoader mindir_loader; auto bprop_fg = mindir_loader.LoadMindIR(bprop_mindir_realpath.value()); + if (bprop_fg == nullptr) { + MS_LOG(WARNING) << "Failed to load the bprop mindir " << bprop_mindir_realpath.value(); + return nullptr; + } if (!CheckBpropHash(bprop_fg->bprop_hash())) { MS_LOG(EXCEPTION) << "The bprop mindir files are not up to date."; } return bprop_fg; } -void ExportBpropToMindIR(const PrimitivePtr &prim, const FuncGraphPtr &func_graph) { - MS_EXCEPTION_IF_NULL(prim); +void ExportBpropToMindIR(const std::string &prim_name, const FuncGraphPtr &func_graph) { std::string bprop_dir = GetBpropDir(); auto bprop_mindir_path = bprop_dir + kBpropMindIRDir; std::optional bprop_mindir_realpath = - Common::CreatePrefixPath(bprop_mindir_path + prim->name() + kBpropMindIRSuffix, true); + Common::CreatePrefixPath(bprop_mindir_path + prim_name + kBpropMindIRSuffix, true); if (!bprop_mindir_realpath.has_value()) { - MS_LOG(ERROR) << "Failed to get the realpath of bprop mindir: " << bprop_mindir_path << prim->name() + MS_LOG(ERROR) << "Failed to get the realpath of bprop mindir: " << bprop_mindir_path << prim_name << kBpropMindIRSuffix; return; } @@ -214,7 +221,7 @@ void ExportBpropToMindIR(const PrimitivePtr &prim, const FuncGraphPtr &func_grap return; } if (!fg_model->SerializeToOstream(&fout)) { - MS_LOG(ERROR) << "Failed to cache the bprop of op \"" << prim->name() << "\" to file \"" + MS_LOG(ERROR) << "Failed to cache the bprop of op \"" << prim_name << "\" to file \"" << bprop_mindir_realpath.value() << "\"."; fout.close(); return; @@ -286,45 +293,62 @@ std::string GetBpropFileHash(const py::function &fn) { } return ""; } + +bool NeedExportBpropMindIR(const std::string &prim_name, const std::string ¤t_hash) { + static std::string bprop_mindir_path = GetBpropDir() + kBpropMindIRDir; + std::optional bprop_mindir_realpath = + FileUtils::GetRealPath(common::SafeCStr(bprop_mindir_path + prim_name + kBpropMindIRSuffix)); + bool bprop_cache_file_exists = bprop_mindir_realpath.has_value() && Common::FileExists(bprop_mindir_realpath.value()); + if (!bprop_cache_file_exists) { + return true; + } + MindIRLoader mindir_loader; + auto bprop_fg = mindir_loader.LoadMindIR(bprop_mindir_realpath.value()); + if (bprop_fg == nullptr) { + MS_LOG(WARNING) << "Failed to load the bprop mindir " << bprop_mindir_realpath.value(); + return true; + } + return bprop_fg->bprop_hash() != current_hash; +} #endif } // namespace #ifndef _WIN32 -// Given a python primitive, export a mindir file from the bprop defined in python. +// Given a python primitive or string, export a mindir file from the bprop defined in python. void KPrim::ExportBpropMindir(const py::object &obj) { - auto prim_adapter = obj.cast(); - if (prim_adapter == nullptr) { - MS_LOG(EXCEPTION) << "The python obj to be exported to bprop mindir should be a Primitive, but it is " - << py::str(obj); + std::string prim_name; + if (!py::isinstance(obj)) { + py::object obj_name = obj.attr("__name__"); + if (!py::isinstance(obj_name)) { + MS_LOG(EXCEPTION) << "The name of obj " << py::str(obj) << " to be exported to mindir should be a string"; + } + prim_name = obj_name.cast(); + } else { + prim_name = obj.cast(); } - auto prim = prim_adapter->attached_primitive(); - if (prim == nullptr) { - prim = std::make_shared(obj, prim_adapter); - prim_adapter->set_attached_primitive(prim); - } - // Get the bprop function from python. - py::function fn = prim->cast()->GetBpropFunction(); - if (py::isinstance(fn)) { - fn = GetBpropFunction(prim->name()); - } + py::function fn = GetBpropFunctionByObj(obj); if (!fn || py::isinstance(fn)) { - MS_LOG(EXCEPTION) << "Fail to find bprop function for " << prim->name() << "."; + MS_LOG(EXCEPTION) << "Fail to find bprop function for " << prim_name << "."; } std::string bprop_hash = GetBpropFileHash(fn); if (bprop_hash.empty()) { - MS_LOG(EXCEPTION) << "Fail to get the file hash for " << prim->name(); + MS_LOG(EXCEPTION) << "Fail to get the file hash for " << prim_name; + } + // If the bprop file hash has not changed, we don't need to export a new mindir. + if (!NeedExportBpropMindIR(prim_name, bprop_hash)) { + return; } // Parse and resolve. auto func_graph = parse::ParsePythonCode(fn); if (func_graph == nullptr) { - MS_LOG(EXCEPTION) << "Fail to parse bprop function for " << prim->name() << "."; + MS_LOG(EXCEPTION) << "Fail to parse bprop function for " << prim_name << "."; } auto res = std::make_shared(); (void)parse::ResolveFuncGraph(func_graph, res); func_graph->set_bprop_hash(bprop_hash); - ExportBpropToMindIR(prim, func_graph); + ExportBpropToMindIR(prim_name, func_graph); } #endif @@ -383,7 +407,7 @@ FuncGraphPtr KPrim::GetBprop(const PrimitivePtr &prim, const pipeline::ResourceB std::string bprop_hash = GetBpropFileHash(fn); if (!bprop_hash.empty()) { func_graph->set_bprop_hash(bprop_hash); - ExportBpropToMindIR(prim, func_graph); + ExportBpropToMindIR(prim->name(), func_graph); } } #endif diff --git a/mindspore/ccsrc/transform/express_ir/mindir_exporter.cc b/mindspore/ccsrc/transform/express_ir/mindir_exporter.cc index 825ee2bec66..87c3eb66cdf 100644 --- a/mindspore/ccsrc/transform/express_ir/mindir_exporter.cc +++ b/mindspore/ccsrc/transform/express_ir/mindir_exporter.cc @@ -619,7 +619,13 @@ bool IrExportBuilder::BuildCNode(const CNodePtr &node, mind_ir::GraphProto *cons // Add primitive attrs if (IsValueNode(op)) { auto prim = GetValueNode(op); - for (auto attr : prim->attrs()) { + if (prim->isa()) { + auto func = prim->cast()->function(); + if (func != nullptr && func->isa()) { + prim = func->cast(); + } + } + for (const auto &attr : prim->attrs()) { MS_LOG(DEBUG) << "attr: " << attr.first << " " << attr.second->DumpText() << " " << attr.second->type_name(); auto iter = g_export_attr_blacklist.find(attr.first); if (iter != g_export_attr_blacklist.end()) { diff --git a/mindspore/ccsrc/utils/primitive_utils.cc b/mindspore/ccsrc/utils/primitive_utils.cc index 59db1c276de..95656fe9d30 100644 --- a/mindspore/ccsrc/utils/primitive_utils.cc +++ b/mindspore/ccsrc/utils/primitive_utils.cc @@ -65,13 +65,15 @@ py::tuple ConvertDatatoPyTuple(const VectorRef &args) { } py::function GetComputeFunctionWithoutPyObj(const std::string &name) { - static const std::string module = "tests.vm_impl.vm_impl_function"; - py::module mod = py::module::import(common::SafeCStr(module)); - if (!py::hasattr(mod, common::SafeCStr(name))) { + static const std::string vm_module = "mindspore.ops.vm_impl_registry"; + static const std::string get_vm_impl_fn = "get_vm_impl_fn"; + py::function get_fn = parse::python_adapter::GetPyFn(vm_module, get_vm_impl_fn); + if (py::isinstance(get_fn)) { + MS_LOG(DEBUG) << "Failed to get the function 'get_vm_impl_fn'"; return py::none(); } - py::object fn = mod.attr(common::SafeCStr(name)); - return fn; + py::function vm_fn = get_fn(py::str(name)); + return vm_fn; } BaseRef RunComputeFunctionWithoutPyObj(const PrimitivePtr &prim, const VectorRef &args) { diff --git a/mindspore/core/load_mindir/anf_model_parser.cc b/mindspore/core/load_mindir/anf_model_parser.cc index d35047e6a50..200f6775908 100644 --- a/mindspore/core/load_mindir/anf_model_parser.cc +++ b/mindspore/core/load_mindir/anf_model_parser.cc @@ -947,13 +947,21 @@ AnfNodePtr MSANFModelParser::BuildOperatorNode(const mind_ir::NodeProto &node_pr } } MS_EXCEPTION_IF_NULL(prim); + auto prim_to_add_attr = prim; + if (prim->isa()) { + auto func = prim->cast()->function(); + if (func != nullptr && func->isa()) { + prim_to_add_attr = func->cast(); + prim_to_add_attr->set_attr("is_load", MakeValue(true)); + } + } for (int i = 0; i < node_proto.attribute_size(); ++i) { const mind_ir::AttributeProto &attr_proto = node_proto.attribute(i); // CNode abstract if (attr_proto.ref_attr_name().find("shape:") != string::npos) { continue; } - if (!GetAttrValueForCNode(prim, attr_proto)) { + if (!GetAttrValueForCNode(prim_to_add_attr, attr_proto)) { MS_LOG(ERROR) << "Parser prim: " << node_type << " attributes error : " << attr_proto.DebugString(); return nullptr; } diff --git a/mindspore/ops/_grad/grad_array_ops.py b/mindspore/ops/_grad/grad_array_ops.py index 0e4ebc071cb..bcfe28e746d 100644 --- a/mindspore/ops/_grad/grad_array_ops.py +++ b/mindspore/ops/_grad/grad_array_ops.py @@ -74,6 +74,7 @@ def get_bprop_zeros(self): @bprop_getters.register(P.DType) +@bprop_getters.register(P.DType.__name__) def get_bprop_dtype(self): """Generate bprop for DType""" @@ -134,6 +135,7 @@ def get_bprop_cast(self): @bprop_getters.register(P.Shape) +@bprop_getters.register(P.Shape.__name__) def get_bprop_shape(self): """Generate bprop for Shape""" @@ -144,6 +146,7 @@ def get_bprop_shape(self): @bprop_getters.register(P.DynamicShape) +@bprop_getters.register(P.DynamicShape.__name__) def get_bprop_dynamicshape(self): """Generate bprop for Shape""" @@ -167,6 +170,7 @@ def get_bprop_split(self): @bprop_getters.register(P.Rank) +@bprop_getters.register(P.Rank.__name__) def get_bprop_rank(self): """Generate bprop for Rank""" @@ -620,6 +624,7 @@ def get_bprop_sort(self): @bprop_getters.register(P.Identity) +@bprop_getters.register(P.Identity.__name__) def get_bprop_identity(self): """Generate bprop for Identity""" @@ -630,6 +635,7 @@ def get_bprop_identity(self): @bprop_getters.register(inner.Range) +@bprop_getters.register(inner.Range.__name__) def get_bprop_range(self): """Generate bprop for Range""" @@ -714,6 +720,7 @@ def get_bprop_eye(self): @bprop_getters.register(P.Select) +@bprop_getters.register(P.Select.__name__) def get_bprop_select(self): """Generate bprop for Select""" select = P.Select() @@ -725,6 +732,7 @@ def get_bprop_select(self): @bprop_getters.register(P.OnesLike) +@bprop_getters.register(P.OnesLike.__name__) def get_bprop_oneslike(self): """Generate bprop for OnesLike""" @@ -735,6 +743,7 @@ def get_bprop_oneslike(self): @bprop_getters.register(P.ZerosLike) +@bprop_getters.register(P.ZerosLike.__name__) def get_bprop_zeroslike(self): """Generate bprop for ZerosLike""" @@ -830,6 +839,7 @@ def get_bprop_tensor_scatter_add(self): @bprop_getters.register(P.ScatterMax) +@bprop_getters.register(P.ScatterMax.__name__) def get_bprop_scatter_max(self): """Generate bprop for ScatterMax""" gather = P.Gather() @@ -841,6 +851,7 @@ def get_bprop_scatter_max(self): @bprop_getters.register(P.Argmax) +@bprop_getters.register(P.Argmax.__name__) def get_bprop_argmax(self): """Generate bprop for Argmax""" @@ -851,6 +862,7 @@ def get_bprop_argmax(self): @bprop_getters.register(P.Argmin) +@bprop_getters.register(P.Argmin.__name__) def get_bprop_argmin(self): """Generate bprop for Argmin""" diff --git a/mindspore/ops/_grad/grad_comm_ops.py b/mindspore/ops/_grad/grad_comm_ops.py index 424ae096732..42e5ba396a5 100644 --- a/mindspore/ops/_grad/grad_comm_ops.py +++ b/mindspore/ops/_grad/grad_comm_ops.py @@ -217,6 +217,7 @@ def get_bprop_mirror_micro_step_operator(self): @bprop_getters.register(Broadcast) +@bprop_getters.register(Broadcast.__name__) def get_bprop_broad_cast(self): """Generate bprop for Broadcast.""" diff --git a/mindspore/ops/_grad/grad_math_ops.py b/mindspore/ops/_grad/grad_math_ops.py index 5a0eb3af675..ff97bca112a 100755 --- a/mindspore/ops/_grad/grad_math_ops.py +++ b/mindspore/ops/_grad/grad_math_ops.py @@ -374,6 +374,7 @@ def get_bprop_ceil(self): @bprop_getters.register(P.FloorDiv) +@bprop_getters.register(P.FloorDiv.__name__) def get_bprop_floordiv(self): """Grad definition for `FloorDiv` operation.""" @@ -396,6 +397,7 @@ def get_bprop_floormod(self): @bprop_getters.register(P.TruncateDiv) +@bprop_getters.register(P.TruncateDiv.__name__) def get_bprop_truncate_div(self): """Grad definition for `TruncateDiv` operation.""" @@ -647,6 +649,7 @@ def get_bprop_expm1(self): @bprop_getters.register(P.Minimum) +@bprop_getters.register(P.Minimum.__name__) def get_bprop_minimum(self): """Grad definition for `Minimum` operation.""" input_grad = G.MinimumGrad() @@ -659,6 +662,7 @@ def get_bprop_minimum(self): @bprop_getters.register(P.Maximum) +@bprop_getters.register(P.Maximum.__name__) def get_bprop_maximum(self): """Grad definition for `Maximum` operation.""" input_grad = G.MaximumGrad() @@ -768,6 +772,7 @@ def get_bprop_cumprod(self): @bprop_getters.register(P.ReduceAll) +@bprop_getters.register(P.ReduceAll.__name__) def get_bprop_reduceall(self): """Grad definition for `ReduceAll` operation.""" @@ -778,6 +783,7 @@ def get_bprop_reduceall(self): @bprop_getters.register(P.ReduceAny) +@bprop_getters.register(P.ReduceAny.__name__) def get_bprop_reduceany(self): """Grad definition for `ReduceAny` operation.""" @@ -862,6 +868,7 @@ def get_bprop_reduce_mean(self): @bprop_getters.register(P.IsFinite) +@bprop_getters.register(P.IsFinite.__name__) def get_bprop_isfinite(self): """Grad definition for `IsFinite` operation.""" @@ -872,6 +879,7 @@ def get_bprop_isfinite(self): @bprop_getters.register(P.IsNan) +@bprop_getters.register(P.IsNan.__name__) def get_bprop_isnan(self): """Grad definition for `IsNan` operation.""" @@ -882,6 +890,7 @@ def get_bprop_isnan(self): @bprop_getters.register(P.IsInf) +@bprop_getters.register(P.IsInf.__name__) def get_bprop_isinf(self): """Grad definition for `IsInf` operation.""" @@ -892,6 +901,7 @@ def get_bprop_isinf(self): @bprop_getters.register(P.Equal) +@bprop_getters.register(P.Equal.__name__) def get_bprop_equal(self): """Grad definition for `Equal` operation.""" @@ -902,6 +912,7 @@ def get_bprop_equal(self): @bprop_getters.register(P.NotEqual) +@bprop_getters.register(P.NotEqual.__name__) def get_bprop_not_equal(self): """Grad definition for `NotEqual` operation.""" @@ -912,6 +923,7 @@ def get_bprop_not_equal(self): @bprop_getters.register(P.ApproximateEqual) +@bprop_getters.register(P.ApproximateEqual.__name__) def get_bprop_approximate_equal(self): """Grad definition for `ApproximateEqual` operation.""" @@ -922,6 +934,7 @@ def get_bprop_approximate_equal(self): @bprop_getters.register(P.Greater) +@bprop_getters.register(P.Greater.__name__) def get_bprop_greater(self): """Grad definition for `Greater` operation.""" @@ -932,6 +945,7 @@ def get_bprop_greater(self): @bprop_getters.register(P.GreaterEqual) +@bprop_getters.register(P.GreaterEqual.__name__) def get_bprop_greater_equal(self): """Grad definition for `GreaterEqual` operation.""" @@ -942,6 +956,7 @@ def get_bprop_greater_equal(self): @bprop_getters.register(P.Less) +@bprop_getters.register(P.Less.__name__) def get_bprop_less(self): """Grad definition for `Less` operation.""" @@ -952,6 +967,7 @@ def get_bprop_less(self): @bprop_getters.register(P.LessEqual) +@bprop_getters.register(P.LessEqual.__name__) def get_bprop_less_equal(self): """Grad definition for `LessEqual` operation.""" @@ -962,6 +978,7 @@ def get_bprop_less_equal(self): @bprop_getters.register(P.LogicalNot) +@bprop_getters.register(P.LogicalNot.__name__) def get_bprop_logical_not(self): """Grad definition for `LogicalNot` operation.""" @@ -972,6 +989,7 @@ def get_bprop_logical_not(self): @bprop_getters.register(P.LogicalAnd) +@bprop_getters.register(P.LogicalAnd.__name__) def get_bprop_logical_and(self): """Grad definition for `LogicalAnd` operation.""" @@ -982,6 +1000,7 @@ def get_bprop_logical_and(self): @bprop_getters.register(P.LogicalOr) +@bprop_getters.register(P.LogicalOr.__name__) def get_bprop_logical_or(self): """Grad definition for `LogicalOr` operation.""" @@ -1022,6 +1041,7 @@ def get_bprop_npu_clear_float_status(self): @bprop_getters.register(P.AssignAdd) +@bprop_getters.register(P.AssignAdd.__name__) def get_bprop_assign_add(self): """Grad definition for `AssignAdd` operation.""" @@ -1032,6 +1052,7 @@ def get_bprop_assign_add(self): @bprop_getters.register(P.AssignSub) +@bprop_getters.register(P.AssignSub.__name__) def get_bprop_assign_sub(self): """Grad definition for `AssignSub` operation.""" @@ -1282,6 +1303,7 @@ def get_bprop_scalar_addn(self): @bprop_getters.register(P.Sign) +@bprop_getters.register(P.Sign.__name__) def get_bprop_sign(self): """Generate bprop for Sign""" @@ -1292,6 +1314,7 @@ def get_bprop_sign(self): @bprop_getters.register(P.Round) +@bprop_getters.register(P.Round.__name__) def get_bprop_round(self): """Generate bprop for Round""" @@ -1417,6 +1440,7 @@ def get_bprop_inv(self): @bprop_getters.register(P.LinSpace) +@bprop_getters.register(P.LinSpace.__name__) def get_bprop_lin_space(self): """Grad definition for `LinSpace` operation.""" diff --git a/mindspore/ops/_grad/grad_nn_ops.py b/mindspore/ops/_grad/grad_nn_ops.py index fb5d1e902d8..0da6e9158bf 100755 --- a/mindspore/ops/_grad/grad_nn_ops.py +++ b/mindspore/ops/_grad/grad_nn_ops.py @@ -352,6 +352,7 @@ def get_bprop_avg_pool_3d_grad(self): @bprop_getters.register(P.DropoutGenMask) +@bprop_getters.register(P.DropoutGenMask.__name__) def get_bprop_dropout_gen_mask(self): """Grad definition for `DropoutGenMask` operation.""" @@ -362,6 +363,7 @@ def get_bprop_dropout_gen_mask(self): @bprop_getters.register(P.DropoutDoMask) +@bprop_getters.register(P.DropoutDoMask.__name__) def get_bprop_dropout_do_mask(self): """Grad definition for `DropoutDoMask` operation.""" do_mask = P.DropoutDoMask() @@ -425,6 +427,7 @@ def get_bprop_mul_no_nan(self): @bprop_getters.register(P.ReLU) +@bprop_getters.register(P.ReLU.__name__) def get_bprop_relu(self): """Grad definition for `ReLU` operation.""" input_grad = G.ReluGrad() @@ -437,6 +440,7 @@ def get_bprop_relu(self): @bprop_getters.register(G.ReluGrad) +@bprop_getters.register(G.ReluGrad.__name__) def get_bprop_relu_grad(self): """Grad definition for `ReLUGrad` operation.""" input_grad = G.ReluGrad() @@ -461,6 +465,7 @@ def get_bprop_relu6(self): @bprop_getters.register(P.ReLUV2) +@bprop_getters.register(P.ReLUV2.__name__) def get_bprop_relu_v2(self): """Grad definition for `ReLUV2` operation.""" input_grad = G.ReluGradV2() @@ -811,6 +816,7 @@ def get_bprop_resize_bilinear(self): @bprop_getters.register(P.OneHot) +@bprop_getters.register(P.OneHot.__name__) def get_bprop_onehot(self): """Grad definition for `OneHot` operation.""" diff --git a/mindspore/ops/_grad/grad_other_ops.py b/mindspore/ops/_grad/grad_other_ops.py index 93f7b855b61..01bda287de5 100644 --- a/mindspore/ops/_grad/grad_other_ops.py +++ b/mindspore/ops/_grad/grad_other_ops.py @@ -25,6 +25,7 @@ from .grad_base import bprop_getters @bprop_getters.register(P.Assign) +@bprop_getters.register(P.Assign.__name__) def get_bprop_assign(self): """Generate bprop for Assign""" @@ -43,6 +44,7 @@ def get_bprop_invert_permutation(self): @bprop_getters.register(P.IOU) +@bprop_getters.register(P.IOU.__name__) def get_bprop_iou(self): """Generate bprop for IOU""" diff --git a/mindspore/ops/_grad/grad_quant_ops.py b/mindspore/ops/_grad/grad_quant_ops.py index a335c2163e6..6ce7c161ca5 100644 --- a/mindspore/ops/_grad/grad_quant_ops.py +++ b/mindspore/ops/_grad/grad_quant_ops.py @@ -137,6 +137,7 @@ def get_bprop_batchnormfold(self): @bprop_getters.register(P.BNTrainingReduce) +@bprop_getters.register(P.BNTrainingReduce.__name__) def get_bprop_bn_training_reduce(self): """Generate bprop for BNTrainingReduce for Ascend""" diff --git a/mindspore/ops/bprop_mindir/ApproximateEqual_bprop.mindir b/mindspore/ops/bprop_mindir/ApproximateEqual_bprop.mindir index fa8ca8653b6..fece3b19695 100644 --- a/mindspore/ops/bprop_mindir/ApproximateEqual_bprop.mindir +++ b/mindspore/ops/bprop_mindir/ApproximateEqual_bprop.mindir @@ -15,4 +15,4 @@ bprop.33:x* bprop.33:y* bprop.33:out* bprop.33:dout2 -bprop.33:[CNode]36:3:@83b099bc427dfabe31c75a63fd6095a27e90066e420c1a3d0680c5db9e31f905P \ No newline at end of file +bprop.33:[CNode]36:3:@5ef58541543bde1e2825be6f527f29db9de3ef5a82bee9759d6cb85f92271c90P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/Argmax_bprop.mindir b/mindspore/ops/bprop_mindir/Argmax_bprop.mindir index 61900e9c5fb..c49ba92b5a7 100644 --- a/mindspore/ops/bprop_mindir/Argmax_bprop.mindir +++ b/mindspore/ops/bprop_mindir/Argmax_bprop.mindir @@ -9,4 +9,4 @@ s bprop.14:x* bprop.14:out* bprop.14:dout2 -bprop.14:[CNode]16:2:@03ba727554b68f632a7320602b4ab4649b05556a1aac96ba69a106bd541d09bbP \ No newline at end of file +bprop.14:[CNode]16:2:@c8a644cc520f380808ab8a19d3b5f795ef28e37966296c6941e187e7de28f9d7P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/Argmin_bprop.mindir b/mindspore/ops/bprop_mindir/Argmin_bprop.mindir index 5b5a442e3fa..ffed28b2df5 100644 --- a/mindspore/ops/bprop_mindir/Argmin_bprop.mindir +++ b/mindspore/ops/bprop_mindir/Argmin_bprop.mindir @@ -9,4 +9,4 @@ s bprop.17:x* bprop.17:out* bprop.17:dout2 -bprop.17:[CNode]19:2:@03ba727554b68f632a7320602b4ab4649b05556a1aac96ba69a106bd541d09bbP \ No newline at end of file +bprop.17:[CNode]19:2:@c8a644cc520f380808ab8a19d3b5f795ef28e37966296c6941e187e7de28f9d7P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/AssignAdd_bprop.mindir b/mindspore/ops/bprop_mindir/AssignAdd_bprop.mindir index dced938f869..02f9baffe38 100644 --- a/mindspore/ops/bprop_mindir/AssignAdd_bprop.mindir +++ b/mindspore/ops/bprop_mindir/AssignAdd_bprop.mindir @@ -15,4 +15,4 @@ bprop.22:x* bprop.22:y* bprop.22:out* bprop.22:dout2 -bprop.22:[CNode]25:3:@83b099bc427dfabe31c75a63fd6095a27e90066e420c1a3d0680c5db9e31f905P \ No newline at end of file +bprop.22:[CNode]25:3:@5ef58541543bde1e2825be6f527f29db9de3ef5a82bee9759d6cb85f92271c90P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/AssignSub_bprop.mindir b/mindspore/ops/bprop_mindir/AssignSub_bprop.mindir index 80884db42cf..dbe54dc48f0 100644 --- a/mindspore/ops/bprop_mindir/AssignSub_bprop.mindir +++ b/mindspore/ops/bprop_mindir/AssignSub_bprop.mindir @@ -15,4 +15,4 @@ bprop.26:x* bprop.26:y* bprop.26:out* bprop.26:dout2 -bprop.26:[CNode]29:3:@83b099bc427dfabe31c75a63fd6095a27e90066e420c1a3d0680c5db9e31f905P \ No newline at end of file +bprop.26:[CNode]29:3:@5ef58541543bde1e2825be6f527f29db9de3ef5a82bee9759d6cb85f92271c90P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/Assign_bprop.mindir b/mindspore/ops/bprop_mindir/Assign_bprop.mindir index 2baa010dbfe..96c3e68e0af 100644 --- a/mindspore/ops/bprop_mindir/Assign_bprop.mindir +++ b/mindspore/ops/bprop_mindir/Assign_bprop.mindir @@ -12,4 +12,4 @@ bprop.61:x* bprop.61:y* bprop.61:out* bprop.61:dout2 -bprop.61:[CNode]63:2:@d600ac5742fbd8dc8b4b041517ce58e1beec6270a8d533616d7cfd5b4b178b15P \ No newline at end of file +bprop.61:[CNode]63:2:@95e1589c91520e66f639d339cd47d91fc97beeb20be68b44d08ebcf9a49136a9P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/BNTrainingReduce_bprop.mindir b/mindspore/ops/bprop_mindir/BNTrainingReduce_bprop.mindir index c998248024b..ac47224fb02 100644 --- a/mindspore/ops/bprop_mindir/BNTrainingReduce_bprop.mindir +++ b/mindspore/ops/bprop_mindir/BNTrainingReduce_bprop.mindir @@ -9,4 +9,4 @@ s bprop.68:x* bprop.68:out* bprop.68:dout2 -bprop.68:[CNode]70:2:@565f906930f68ca2413e9ad958d105e129e717cd183b95d11d65a8b0b030fc0dP \ No newline at end of file +bprop.68:[CNode]70:2:@1e27cd67c72e444d4887e7d7ea00adeb8aff74c5b46357b5181815a61af42ff7P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/Broadcast_bprop.mindir b/mindspore/ops/bprop_mindir/Broadcast_bprop.mindir index 94fca38022e..bfe7d8c57b6 100644 --- a/mindspore/ops/bprop_mindir/Broadcast_bprop.mindir +++ b/mindspore/ops/bprop_mindir/Broadcast_bprop.mindir @@ -6,4 +6,4 @@ l bprop.20:x* bprop.20:out* bprop.20:dout2 -bprop.20:[CNode]21:1:@96c75d48466ae9dd2ae51ee64181426e1bf1c36337f7c6cf3bdd01083bfb1a6eP \ No newline at end of file +bprop.20:[CNode]21:1:@db34e8b984a28af03c6bc0c939187dcb77745f31a9e4555ef7ad6abe300eda8bP \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/DType_bprop.mindir b/mindspore/ops/bprop_mindir/DType_bprop.mindir new file mode 100644 index 00000000000..dba3238874d --- /dev/null +++ b/mindspore/ops/bprop_mindir/DType_bprop.mindir @@ -0,0 +1,10 @@ + +0.1.0 MindSpore*1.6.0: + + bprop.116:xbprop.116:[CNode]117:1bprop.116:[CNode]117:1"!S-Prim-hyper_map[zeros_like_leaf]:.Default/S-Prim-hyper_map[zeros_like_leaf]-op84 +y +bprop.116:[CNode]117:1bprop.116:[CNode]118:2bprop.116:[CNode]118:2"S-Prim-MakeTuple:Default/S-Prim-MakeTuple-op85 bprop.116* + bprop.116:x* + bprop.116:out* +bprop.116:dout2 +bprop.116:[CNode]118:2:@c8a644cc520f380808ab8a19d3b5f795ef28e37966296c6941e187e7de28f9d7P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/Depend_bprop.mindir b/mindspore/ops/bprop_mindir/Depend_bprop.mindir new file mode 100644 index 00000000000..5add53230d6 --- /dev/null +++ b/mindspore/ops/bprop_mindir/Depend_bprop.mindir @@ -0,0 +1,12 @@ + +0.1.0 MindSpore*1.6.0: + +bprop_depend.177:ybprop_depend.177:[CNode]178:1bprop_depend.177:[CNode]178:1"!S-Prim-hyper_map[zeros_like_leaf]:/Default/S-Prim-hyper_map[zeros_like_leaf]-op130 + +bprop_depend.177:dout +bprop_depend.177:[CNode]178:1bprop_depend.177:[CNode]179:2bprop_depend.177:[CNode]179:2"S-Prim-MakeTuple:Default/S-Prim-MakeTuple-op131bprop_depend.177* +bprop_depend.177:x* +bprop_depend.177:y* +bprop_depend.177:out* +bprop_depend.177:dout2 +bprop_depend.177:[CNode]179:2:@a6c407ad6a3b57190d3702d6a45031d13b97bb6952735edf94fb36f73dbff6cdP \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/DropoutDoMask_bprop.mindir b/mindspore/ops/bprop_mindir/DropoutDoMask_bprop.mindir index 44febc3eb7a..be1bc9895ea 100644 --- a/mindspore/ops/bprop_mindir/DropoutDoMask_bprop.mindir +++ b/mindspore/ops/bprop_mindir/DropoutDoMask_bprop.mindir @@ -17,4 +17,4 @@ bprop.111:keep_prob* bprop.111:out* bprop.111:dout2 -bprop.111:[CNode]115:4:@ff3ca86129a77e54496a41a353e9f6355edfba79f3c040cf990522596d638b7fP \ No newline at end of file +bprop.111:[CNode]115:4:@96ae3f8192e3c91377a1d29c2b21ca1b074919e769ac3f2760f56b9db1b17d94P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/DropoutGenMask_bprop.mindir b/mindspore/ops/bprop_mindir/DropoutGenMask_bprop.mindir index 5771d04e0a3..bb7821092c7 100644 --- a/mindspore/ops/bprop_mindir/DropoutGenMask_bprop.mindir +++ b/mindspore/ops/bprop_mindir/DropoutGenMask_bprop.mindir @@ -11,4 +11,4 @@ bprop.51:keep_prob* bprop.51:out* bprop.51:dout2 -bprop.51:[CNode]54:3:@ff3ca86129a77e54496a41a353e9f6355edfba79f3c040cf990522596d638b7fP \ No newline at end of file +bprop.51:[CNode]54:3:@96ae3f8192e3c91377a1d29c2b21ca1b074919e769ac3f2760f56b9db1b17d94P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/DynamicShape_bprop.mindir b/mindspore/ops/bprop_mindir/DynamicShape_bprop.mindir new file mode 100644 index 00000000000..132070e1567 --- /dev/null +++ b/mindspore/ops/bprop_mindir/DynamicShape_bprop.mindir @@ -0,0 +1,10 @@ + +0.1.0 MindSpore*1.6.0: + + bprop.122:xbprop.122:[CNode]123:1bprop.122:[CNode]123:1"!S-Prim-hyper_map[zeros_like_leaf]:.Default/S-Prim-hyper_map[zeros_like_leaf]-op88 +y +bprop.122:[CNode]123:1bprop.122:[CNode]124:2bprop.122:[CNode]124:2"S-Prim-MakeTuple:Default/S-Prim-MakeTuple-op89 bprop.122* + bprop.122:x* + bprop.122:out* +bprop.122:dout2 +bprop.122:[CNode]124:2:@c8a644cc520f380808ab8a19d3b5f795ef28e37966296c6941e187e7de28f9d7P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/Equal_bprop.mindir b/mindspore/ops/bprop_mindir/Equal_bprop.mindir index 569caa0ced4..b88aa5115f1 100644 --- a/mindspore/ops/bprop_mindir/Equal_bprop.mindir +++ b/mindspore/ops/bprop_mindir/Equal_bprop.mindir @@ -15,4 +15,4 @@ bprop.71:x* bprop.71:y* bprop.71:out* bprop.71:dout2 -bprop.71:[CNode]74:3:@83b099bc427dfabe31c75a63fd6095a27e90066e420c1a3d0680c5db9e31f905P \ No newline at end of file +bprop.71:[CNode]74:3:@5ef58541543bde1e2825be6f527f29db9de3ef5a82bee9759d6cb85f92271c90P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/FloorDiv_bprop.mindir b/mindspore/ops/bprop_mindir/FloorDiv_bprop.mindir new file mode 100644 index 00000000000..a76f5175b38 --- /dev/null +++ b/mindspore/ops/bprop_mindir/FloorDiv_bprop.mindir @@ -0,0 +1,14 @@ + +0.1.0 MindSpore*1.6.0: + + bprop.143:xbprop.143:[CNode]144:1bprop.143:[CNode]144:1"!S-Prim-hyper_map[zeros_like_leaf]:/Default/S-Prim-hyper_map[zeros_like_leaf]-op104 + + bprop.143:ybprop.143:[CNode]145:2bprop.143:[CNode]145:2"!S-Prim-hyper_map[zeros_like_leaf]:/Default/S-Prim-hyper_map[zeros_like_leaf]-op105 + +bprop.143:[CNode]144:1 +bprop.143:[CNode]145:2bprop.143:[CNode]146:3bprop.143:[CNode]146:3"S-Prim-MakeTuple:Default/S-Prim-MakeTuple-op106 bprop.143* + bprop.143:x* + bprop.143:y* + bprop.143:out* +bprop.143:dout2 +bprop.143:[CNode]146:3:@5ef58541543bde1e2825be6f527f29db9de3ef5a82bee9759d6cb85f92271c90P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/GreaterEqual_bprop.mindir b/mindspore/ops/bprop_mindir/GreaterEqual_bprop.mindir index d06a71aa7f7..65c5d765488 100644 --- a/mindspore/ops/bprop_mindir/GreaterEqual_bprop.mindir +++ b/mindspore/ops/bprop_mindir/GreaterEqual_bprop.mindir @@ -15,4 +15,4 @@ bprop.83:x* bprop.83:y* bprop.83:out* bprop.83:dout2 -bprop.83:[CNode]86:3:@83b099bc427dfabe31c75a63fd6095a27e90066e420c1a3d0680c5db9e31f905P \ No newline at end of file +bprop.83:[CNode]86:3:@5ef58541543bde1e2825be6f527f29db9de3ef5a82bee9759d6cb85f92271c90P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/Greater_bprop.mindir b/mindspore/ops/bprop_mindir/Greater_bprop.mindir index 2a9848e6ed4..c3de074768b 100644 --- a/mindspore/ops/bprop_mindir/Greater_bprop.mindir +++ b/mindspore/ops/bprop_mindir/Greater_bprop.mindir @@ -15,4 +15,4 @@ bprop.79:x* bprop.79:y* bprop.79:out* bprop.79:dout2 -bprop.79:[CNode]82:3:@83b099bc427dfabe31c75a63fd6095a27e90066e420c1a3d0680c5db9e31f905P \ No newline at end of file +bprop.79:[CNode]82:3:@5ef58541543bde1e2825be6f527f29db9de3ef5a82bee9759d6cb85f92271c90P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/IOU_bprop.mindir b/mindspore/ops/bprop_mindir/IOU_bprop.mindir index d8520084d55..d45df9645db 100644 --- a/mindspore/ops/bprop_mindir/IOU_bprop.mindir +++ b/mindspore/ops/bprop_mindir/IOU_bprop.mindir @@ -15,4 +15,4 @@ bprop.64:x* bprop.64:y* bprop.64:out* bprop.64:dout2 -bprop.64:[CNode]67:3:@d600ac5742fbd8dc8b4b041517ce58e1beec6270a8d533616d7cfd5b4b178b15P \ No newline at end of file +bprop.64:[CNode]67:3:@95e1589c91520e66f639d339cd47d91fc97beeb20be68b44d08ebcf9a49136a9P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/Identity_bprop.mindir b/mindspore/ops/bprop_mindir/Identity_bprop.mindir index 897ecd2efe7..4a615d8d2b5 100644 --- a/mindspore/ops/bprop_mindir/Identity_bprop.mindir +++ b/mindspore/ops/bprop_mindir/Identity_bprop.mindir @@ -5,4 +5,4 @@ f bprop.3:x* bprop.3:out* bprop.3:dout2 -bprop.3:[CNode]4:1:@03ba727554b68f632a7320602b4ab4649b05556a1aac96ba69a106bd541d09bbP \ No newline at end of file +bprop.3:[CNode]4:1:@c8a644cc520f380808ab8a19d3b5f795ef28e37966296c6941e187e7de28f9d7P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/IsFinite_bprop.mindir b/mindspore/ops/bprop_mindir/IsFinite_bprop.mindir index 9f2174afaa1..658f7d323c2 100644 --- a/mindspore/ops/bprop_mindir/IsFinite_bprop.mindir +++ b/mindspore/ops/bprop_mindir/IsFinite_bprop.mindir @@ -9,4 +9,4 @@ s bprop.30:x* bprop.30:out* bprop.30:dout2 -bprop.30:[CNode]32:2:@83b099bc427dfabe31c75a63fd6095a27e90066e420c1a3d0680c5db9e31f905P \ No newline at end of file +bprop.30:[CNode]32:2:@5ef58541543bde1e2825be6f527f29db9de3ef5a82bee9759d6cb85f92271c90P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/IsInf_bprop.mindir b/mindspore/ops/bprop_mindir/IsInf_bprop.mindir new file mode 100644 index 00000000000..a12d1f9d6be --- /dev/null +++ b/mindspore/ops/bprop_mindir/IsInf_bprop.mindir @@ -0,0 +1,10 @@ + +0.1.0 MindSpore*1.6.0: + + bprop.164:xbprop.164:[CNode]165:1bprop.164:[CNode]165:1"!S-Prim-hyper_map[zeros_like_leaf]:/Default/S-Prim-hyper_map[zeros_like_leaf]-op120 +z +bprop.164:[CNode]165:1bprop.164:[CNode]166:2bprop.164:[CNode]166:2"S-Prim-MakeTuple:Default/S-Prim-MakeTuple-op121 bprop.164* + bprop.164:x* + bprop.164:out* +bprop.164:dout2 +bprop.164:[CNode]166:2:@5ef58541543bde1e2825be6f527f29db9de3ef5a82bee9759d6cb85f92271c90P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/IsNan_bprop.mindir b/mindspore/ops/bprop_mindir/IsNan_bprop.mindir new file mode 100644 index 00000000000..3b3b69a6c76 --- /dev/null +++ b/mindspore/ops/bprop_mindir/IsNan_bprop.mindir @@ -0,0 +1,10 @@ + +0.1.0 MindSpore*1.6.0: + + bprop.161:xbprop.161:[CNode]162:1bprop.161:[CNode]162:1"!S-Prim-hyper_map[zeros_like_leaf]:/Default/S-Prim-hyper_map[zeros_like_leaf]-op118 +z +bprop.161:[CNode]162:1bprop.161:[CNode]163:2bprop.161:[CNode]163:2"S-Prim-MakeTuple:Default/S-Prim-MakeTuple-op119 bprop.161* + bprop.161:x* + bprop.161:out* +bprop.161:dout2 +bprop.161:[CNode]163:2:@5ef58541543bde1e2825be6f527f29db9de3ef5a82bee9759d6cb85f92271c90P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/LessEqual_bprop.mindir b/mindspore/ops/bprop_mindir/LessEqual_bprop.mindir index bea23a60589..08a1c69b650 100644 --- a/mindspore/ops/bprop_mindir/LessEqual_bprop.mindir +++ b/mindspore/ops/bprop_mindir/LessEqual_bprop.mindir @@ -15,4 +15,4 @@ bprop.91:x* bprop.91:y* bprop.91:out* bprop.91:dout2 -bprop.91:[CNode]94:3:@83b099bc427dfabe31c75a63fd6095a27e90066e420c1a3d0680c5db9e31f905P \ No newline at end of file +bprop.91:[CNode]94:3:@5ef58541543bde1e2825be6f527f29db9de3ef5a82bee9759d6cb85f92271c90P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/Less_bprop.mindir b/mindspore/ops/bprop_mindir/Less_bprop.mindir index db6c61a0c9f..f069d79cd0f 100644 --- a/mindspore/ops/bprop_mindir/Less_bprop.mindir +++ b/mindspore/ops/bprop_mindir/Less_bprop.mindir @@ -15,4 +15,4 @@ bprop.87:x* bprop.87:y* bprop.87:out* bprop.87:dout2 -bprop.87:[CNode]90:3:@83b099bc427dfabe31c75a63fd6095a27e90066e420c1a3d0680c5db9e31f905P \ No newline at end of file +bprop.87:[CNode]90:3:@5ef58541543bde1e2825be6f527f29db9de3ef5a82bee9759d6cb85f92271c90P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/LinSpace_bprop.mindir b/mindspore/ops/bprop_mindir/LinSpace_bprop.mindir index 8f28b7dbfe2..7229689ffcb 100644 --- a/mindspore/ops/bprop_mindir/LinSpace_bprop.mindir +++ b/mindspore/ops/bprop_mindir/LinSpace_bprop.mindir @@ -15,4 +15,4 @@ bprop.46:num* bprop.46:out* bprop.46:dout2 -bprop.46:[CNode]50:4:@83b099bc427dfabe31c75a63fd6095a27e90066e420c1a3d0680c5db9e31f905P \ No newline at end of file +bprop.46:[CNode]50:4:@5ef58541543bde1e2825be6f527f29db9de3ef5a82bee9759d6cb85f92271c90P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/Load_bprop.mindir b/mindspore/ops/bprop_mindir/Load_bprop.mindir new file mode 100644 index 00000000000..127f1d873be --- /dev/null +++ b/mindspore/ops/bprop_mindir/Load_bprop.mindir @@ -0,0 +1,12 @@ + +0.1.0 MindSpore*1.6.0: + +bprop_load.194:u_monadbprop_load.194:[CNode]195:1bprop_load.194:[CNode]195:1"!S-Prim-hyper_map[zeros_like_leaf]:/Default/S-Prim-hyper_map[zeros_like_leaf]-op143 + +bprop_load.194:dout +bprop_load.194:[CNode]195:1bprop_load.194:[CNode]196:2bprop_load.194:[CNode]196:2"S-Prim-MakeTuple:Default/S-Prim-MakeTuple-op144bprop_load.194* +bprop_load.194:param* +bprop_load.194:u_monad* +bprop_load.194:out* +bprop_load.194:dout2 +bprop_load.194:[CNode]196:2:@a6c407ad6a3b57190d3702d6a45031d13b97bb6952735edf94fb36f73dbff6cdP \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/LogicalAnd_bprop.mindir b/mindspore/ops/bprop_mindir/LogicalAnd_bprop.mindir index d5da7f51ebf..2b6deddf7c0 100644 --- a/mindspore/ops/bprop_mindir/LogicalAnd_bprop.mindir +++ b/mindspore/ops/bprop_mindir/LogicalAnd_bprop.mindir @@ -15,4 +15,4 @@ bprop.95:x* bprop.95:y* bprop.95:out* bprop.95:dout2 -bprop.95:[CNode]98:3:@83b099bc427dfabe31c75a63fd6095a27e90066e420c1a3d0680c5db9e31f905P \ No newline at end of file +bprop.95:[CNode]98:3:@5ef58541543bde1e2825be6f527f29db9de3ef5a82bee9759d6cb85f92271c90P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/LogicalNot_bprop.mindir b/mindspore/ops/bprop_mindir/LogicalNot_bprop.mindir index 12205e0b0dc..817326da1d4 100644 --- a/mindspore/ops/bprop_mindir/LogicalNot_bprop.mindir +++ b/mindspore/ops/bprop_mindir/LogicalNot_bprop.mindir @@ -9,4 +9,4 @@ s bprop.40:x* bprop.40:out* bprop.40:dout2 -bprop.40:[CNode]42:2:@83b099bc427dfabe31c75a63fd6095a27e90066e420c1a3d0680c5db9e31f905P \ No newline at end of file +bprop.40:[CNode]42:2:@5ef58541543bde1e2825be6f527f29db9de3ef5a82bee9759d6cb85f92271c90P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/LogicalOr_bprop.mindir b/mindspore/ops/bprop_mindir/LogicalOr_bprop.mindir index c4793b4517f..5b5f7c4a599 100644 --- a/mindspore/ops/bprop_mindir/LogicalOr_bprop.mindir +++ b/mindspore/ops/bprop_mindir/LogicalOr_bprop.mindir @@ -15,4 +15,4 @@ bprop.99:x* bprop.99:y* bprop.99:out* bprop.99:dout2 -bprop.99:[CNode]102:3:@83b099bc427dfabe31c75a63fd6095a27e90066e420c1a3d0680c5db9e31f905P \ No newline at end of file +bprop.99:[CNode]102:3:@5ef58541543bde1e2825be6f527f29db9de3ef5a82bee9759d6cb85f92271c90P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/Maximum_bprop.mindir b/mindspore/ops/bprop_mindir/Maximum_bprop.mindir new file mode 100644 index 0000000000000000000000000000000000000000..905ce33d58e60f8288cec2404ced806f2c197fab GIT binary patch literal 924 zcmb7?!E3@W6vo$sZf5ADhapbJ=&@keMAJ4o4IFrK2##H3jMS!5R&A-R)SbruzWq&O zRZ6wB!gdPZd*S8#y?mgeDo|0y+Q?a26WbO#xU5U>9=XjTH@rWd+x2`1`(P+GrZ3xRsXL=x(9*@gTdqR34CNb8**)Ak zJ2G+(*5CvbC=3)2mlRXfE@-Kdnw|5|3HgF{3J__12Y`&v<6nju-4 zZp_pVp|bp|22gbJ?*Li`ASK+f z{V!9l{{?`+r;v#acO;|vz|t6DqLs#o*QMt6yUjQD7zZvR*EtWz+s@j>o>$&D1!{?2wSXgV>GalK`n!_9=~Gh X$YRVGV1xGOmX2)$p#hv5>O}Yf`NR_E literal 0 HcmV?d00001 diff --git a/mindspore/ops/bprop_mindir/NotEqual_bprop.mindir b/mindspore/ops/bprop_mindir/NotEqual_bprop.mindir index 0e32efe7540..2c6b4fe9769 100644 --- a/mindspore/ops/bprop_mindir/NotEqual_bprop.mindir +++ b/mindspore/ops/bprop_mindir/NotEqual_bprop.mindir @@ -15,4 +15,4 @@ bprop.75:x* bprop.75:y* bprop.75:out* bprop.75:dout2 -bprop.75:[CNode]78:3:@83b099bc427dfabe31c75a63fd6095a27e90066e420c1a3d0680c5db9e31f905P \ No newline at end of file +bprop.75:[CNode]78:3:@5ef58541543bde1e2825be6f527f29db9de3ef5a82bee9759d6cb85f92271c90P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/OneHot_bprop.mindir b/mindspore/ops/bprop_mindir/OneHot_bprop.mindir index dd9fd5e9ce9..c619d3cb4c8 100644 --- a/mindspore/ops/bprop_mindir/OneHot_bprop.mindir +++ b/mindspore/ops/bprop_mindir/OneHot_bprop.mindir @@ -19,4 +19,4 @@ bprop.55:off_value* bprop.55:out* bprop.55:dout2 -bprop.55:[CNode]60:5:@ff3ca86129a77e54496a41a353e9f6355edfba79f3c040cf990522596d638b7fP \ No newline at end of file +bprop.55:[CNode]60:5:@96ae3f8192e3c91377a1d29c2b21ca1b074919e769ac3f2760f56b9db1b17d94P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/OnesLike_bprop.mindir b/mindspore/ops/bprop_mindir/OnesLike_bprop.mindir index ae428f3cf16..0df67921e88 100644 --- a/mindspore/ops/bprop_mindir/OnesLike_bprop.mindir +++ b/mindspore/ops/bprop_mindir/OnesLike_bprop.mindir @@ -7,4 +7,4 @@ n bprop.8:x* bprop.8:out* bprop.8:dout2 -bprop.8:[CNode]10:2:@03ba727554b68f632a7320602b4ab4649b05556a1aac96ba69a106bd541d09bbP \ No newline at end of file +bprop.8:[CNode]10:2:@c8a644cc520f380808ab8a19d3b5f795ef28e37966296c6941e187e7de28f9d7P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/Range_bprop.mindir b/mindspore/ops/bprop_mindir/Range_bprop.mindir index e45f1e13b9c..ca637c20145 100644 --- a/mindspore/ops/bprop_mindir/Range_bprop.mindir +++ b/mindspore/ops/bprop_mindir/Range_bprop.mindir @@ -7,4 +7,4 @@ l bprop.5:x* bprop.5:out* bprop.5:dout2 -bprop.5:[CNode]7:2:@03ba727554b68f632a7320602b4ab4649b05556a1aac96ba69a106bd541d09bbP \ No newline at end of file +bprop.5:[CNode]7:2:@c8a644cc520f380808ab8a19d3b5f795ef28e37966296c6941e187e7de28f9d7P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/Rank_bprop.mindir b/mindspore/ops/bprop_mindir/Rank_bprop.mindir new file mode 100644 index 00000000000..c4d7217f5c9 --- /dev/null +++ b/mindspore/ops/bprop_mindir/Rank_bprop.mindir @@ -0,0 +1,10 @@ + +0.1.0 MindSpore*1.6.0: + + bprop.125:xbprop.125:[CNode]126:1bprop.125:[CNode]126:1"!S-Prim-hyper_map[zeros_like_leaf]:.Default/S-Prim-hyper_map[zeros_like_leaf]-op90 +y +bprop.125:[CNode]126:1bprop.125:[CNode]127:2bprop.125:[CNode]127:2"S-Prim-MakeTuple:Default/S-Prim-MakeTuple-op91 bprop.125* + bprop.125:x* + bprop.125:out* +bprop.125:dout2 +bprop.125:[CNode]127:2:@c8a644cc520f380808ab8a19d3b5f795ef28e37966296c6941e187e7de28f9d7P \ No newline at end of file diff --git a/mindspore/ops/bprop_mindir/ReLUV2_bprop.mindir b/mindspore/ops/bprop_mindir/ReLUV2_bprop.mindir new file mode 100644 index 0000000000000000000000000000000000000000..5e4eb95366c8defec6e77679bddca746199ab22e GIT binary patch literal 932 zcmb7C!AiqG6f|J9U2UxaMXD(D7}~hIsaba~3JP9SM8$)p$R^oJFim2z5$QoZ`M>^w zZ7hvV(}Tx(Z+G6zn+HlzM>1{$VNQ@pkRwvJvwrt%GLACT zSWs`)?%FqzJ7_-(=}IwRd*`Ch6Hgw_*4sgdFwPqxaMlQcMMjhYBd?&E37zvnpjyw` z10KIH+?cEUOS=KS6|i6lV2)b-yXJRhG;+APIa$xG@REy&I}cccV0~mHOyrZ#2O@r4 z`9;I6Ns5*s4adCC#h~DP)tBKuQ-j##~ERL`0Sb{gl+J zJVBRzfIe2ArW0G(MV(Nz5clZLopZh`(y~luTHT||I1R65mLqL3(={#ed!PI?$cu%{ zGifqsEL1}rV9|ZOlcr~%vk+&@aRuu=qW9lj53llgIlTEUF`q9%PFI*`#XN~`ah@PV zGhu$h2&$y~@ZZ*9Cb>_}yC>7HkW^S-@AVpW|L`nJixSe3z9Fq|53Q$9R_!8y1ah&i zt$X8u{CG-Ec5%Y2Dm95oW4M-pFKjIVrT5!)taB)DFsBxIrY@3IIZt7U#bkd|tzOmk zF5;q`u068BY;bQJ(hG7Nr+*!gki)W=9MmhB?7>}Jtln$RugBPf^~>2z6TJrQjjac= zocuEW0rJRRiB4B(wRE^}v~-l-@6>cI;TFGCGC}dSVQ~9Jd1RLQS+^^rZF0OV#2tO9 zSs(3^&aS7DA(Tj;llD$i{As6|+dkDMRF1{Rzz26U3WBk1MUHQ&2Npgs9y*J0 y: + return x + return y + + x = Tensor(np.array([3]), mstype.float32) + y = Tensor(np.array([2]), mstype.float32) + switch_net = SwitchNet() + grad = GradNet(switch_net) + grad.compile(x, y) + + +def test_update_state(): + """ + Feature: Bprop pre-compilation. + Description: Compile the backward graph for the update_state op. + Expectation: Load the bprop mindir successfully. + """ + + class UpdateStateNet(nn.Cell): + def __init__(self): + super(UpdateStateNet, self).__init__() + self.assign_add = P.AssignAdd() + self.variable = Parameter(initializer(1, [1], mstype.int64), name="global_step") + + def construct(self, x): + return self.assign_add(self.variable, x) + + value = Tensor(np.ones([1]).astype(np.int64) * 100) + update_state = UpdateStateNet() + grad = GradNet(update_state) + grad.compile(value) + + +def test_load(): + """ + Feature: Bprop pre-compilation. + Description: Compile the backward graph for the load op. + Expectation: Load the bprop mindir successfully. + """ + + class LoadNet(nn.Cell): + def __init__(self): + super(LoadNet, self).__init__() + self.add = P.Add() + self.variable = Parameter(initializer(1, [1], mstype.int64), name="global_step") + + def construct(self, x): + return self.add(self.variable, x) + + value = Tensor(np.ones([1]).astype(np.int64) * 100) + load = LoadNet() + grad = GradNet(load) + grad.compile(value) + + +def test_floor_div(): + """ + Feature: Bprop pre-compilation. + Description: Compile the backward graph for the floor_div op. + Expectation: Load the bprop mindir successfully. + """ + x = Tensor(np.array([2, 4, -1]), mstype.int32) + y = Tensor(np.array([3, 3, 3]), mstype.int32) + floor_div = Net(P.FloorDiv()) + grad = GradNet(floor_div) + grad.compile(x, y) + + +def test_truncate_div(): + """ + Feature: Bprop pre-compilation. + Description: Compile the backward graph for the truncate_div op. + Expectation: Load the bprop mindir successfully. + """ + x = Tensor(np.array([2, 4, -1]), mstype.int32) + y = Tensor(np.array([3, 3, 3]), mstype.int32) + truncate_div = Net(P.TruncateDiv()) + grad = GradNet(truncate_div) + grad.compile(x, y) + + +def test_minimum(): + """ + Feature: Bprop pre-compilation. + Description: Compile the backward graph for the minimum op. + Expectation: Load the bprop mindir successfully. + """ + x = Tensor(np.array([1.0, 5.0, 3.0]), mstype.float32) + y = Tensor(np.array([4.0, 2.0, 6.0]), mstype.float32) + minimum = Net(P.Minimum()) + grad = GradNet(minimum) + grad.compile(x, y) + + +def test_maximum(): + """ + Feature: Bprop pre-compilation. + Description: Compile the backward graph for the maximum op. + Expectation: Load the bprop mindir successfully. + """ + x = Tensor(np.array([1.0, 5.0, 3.0]), mstype.float32) + y = Tensor(np.array([4.0, 2.0, 6.0]), mstype.float32) + maximum = Net(P.Maximum()) + grad = GradNet(maximum) + grad.compile(x, y) + + +def test_is_nan(): + """ + Feature: Bprop pre-compilation. + Description: Compile the backward graph for the is_nan op. + Expectation: Load the bprop mindir successfully. + """ + x = Tensor(np.array([np.log(-1), 1, np.log(0)]), mstype.float32) + is_nan = Net(P.IsNan()) + grad = GradNet(is_nan) + grad.compile(x) + + +def test_is_inf(): + """ + Feature: Bprop pre-compilation. + Description: Compile the backward graph for the is_inf op. + Expectation: Load the bprop mindir successfully. + """ + x = Tensor(np.array([np.log(-1), 1, np.log(0)]), mstype.float32) + is_inf = Net(P.IsInf()) + grad = GradNet(is_inf) + grad.compile(x) + + +def test_relu_v2(): + """ + Feature: Bprop pre-compilation. + Description: Compile the backward graph for the relu_v2 op. + Expectation: Load the bprop mindir successfully. + """ + x = Tensor(np.array([[[[1, -2], [-3, 4]], [[-5, 6], [7, -8]]]]), mstype.float32) + relu_v2 = Net(P.ReLUV2()) + grad = GradNet(relu_v2) + grad.compile(x) diff --git a/tests/vm_impl/array_ops_vm_impl.py b/tests/vm_impl/array_ops_vm_impl.py index 8fb5f3c53fe..3e6b810f1d9 100644 --- a/tests/vm_impl/array_ops_vm_impl.py +++ b/tests/vm_impl/array_ops_vm_impl.py @@ -268,6 +268,7 @@ def vm_impl_sum(self): @vm_impl_getters.register(P.Select) +@vm_impl_getters.register(P.Select.__name__) def vm_impl_select(self): """Generate vm_impl function for Select""" diff --git a/tests/vm_impl/nn_ops_vm_impl.py b/tests/vm_impl/nn_ops_vm_impl.py index 5918e12440e..b0b53f4cc53 100644 --- a/tests/vm_impl/nn_ops_vm_impl.py +++ b/tests/vm_impl/nn_ops_vm_impl.py @@ -220,6 +220,7 @@ def vm_impl_fused_batch_norm_grad(self): @vm_impl_getters.register(G.ReluGrad) +@vm_impl_getters.register(G.ReluGrad.__name__) def vm_impl_relu_grad(self): """Generate vm_impl function for ReluGrad""" diff --git a/tests/vm_impl/vm_impl_function.py b/tests/vm_impl/vm_impl_function.py deleted file mode 100644 index 3311ed2b3a5..00000000000 --- a/tests/vm_impl/vm_impl_function.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2021 Huawei Technologies Co., Ltd -# -# 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. -# ============================================================================ -"""Generate vm_impl function for nn ops without python object""" -from mindspore.common.tensor import Tensor -from .vm_interface import vm - -def ReluGrad(y_backprop, x): - x = x.asnumpy() - y_backprop = y_backprop.asnumpy() - y_backprop = vm.relu_grad(x.copy()) * y_backprop - return Tensor(y_backprop)