From 67ab96514ca29b81170f2b3f8d39b456b1fc8132 Mon Sep 17 00:00:00 2001 From: Margaret_wangrui Date: Mon, 15 Aug 2022 19:01:42 +0800 Subject: [PATCH] Handling bugs in CombineLikeGraphs. --- mindspore/ccsrc/pipeline/jit/action.cc | 8 ++++---- mindspore/ccsrc/pipeline/jit/parse/data_converter.cc | 4 ++-- mindspore/ccsrc/pipeline/jit/parse/data_converter.h | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mindspore/ccsrc/pipeline/jit/action.cc b/mindspore/ccsrc/pipeline/jit/action.cc index 0252c32e543..7125556d804 100644 --- a/mindspore/ccsrc/pipeline/jit/action.cc +++ b/mindspore/ccsrc/pipeline/jit/action.cc @@ -445,9 +445,9 @@ bool ParseAction(const ResourcePtr &resource) { bool CombineLikeGraphs(const ResourcePtr &resource) { MS_EXCEPTION_IF_NULL(resource); auto &obj_map = parse::data_converter::GetObjGraphs(); - for (auto it : obj_map) { - auto &graphs = it.second; - MS_LOG(DEBUG) << "Start combine like graph:" << it.first << ", size:" << graphs.size(); + for (auto it = obj_map.rbegin(); it != obj_map.rend(); ++it) { + auto &graphs = it->second; + MS_LOG(DEBUG) << "Start combine like graph:" << it->first << ", size:" << graphs.size(); auto fg = graphs[0]; FuncGraphVector func_graphs = {fg}; Cloner cloner(func_graphs, false, false, true, std::make_shared(), @@ -496,7 +496,7 @@ bool CombineLikeGraphs(const ResourcePtr &resource) { const int recursive_level = 4; MS_LOG(DEBUG) << "Combine graph newout:" << out->DebugString(recursive_level); } - MS_LOG(DEBUG) << "End combine graph:" << it.first; + MS_LOG(DEBUG) << "End combine graph:" << it->first; } return true; } diff --git a/mindspore/ccsrc/pipeline/jit/parse/data_converter.cc b/mindspore/ccsrc/pipeline/jit/parse/data_converter.cc index bdb4f2b7a6f..e297aff353d 100644 --- a/mindspore/ccsrc/pipeline/jit/parse/data_converter.cc +++ b/mindspore/ccsrc/pipeline/jit/parse/data_converter.cc @@ -611,14 +611,14 @@ FuncGraphPtr ConvertToFuncGraph(const py::object &obj, const std::string &python namespace data_converter { static mindspore::HashMap object_map_; -static mindspore::HashMap> object_graphs_map_; +static mindspore::OrderedMap> object_graphs_map_; void SetObjGraphValue(const std::string &obj_key, const FuncGraphPtr &data) { object_graphs_map_[obj_key].push_back(data); MS_LOG(DEBUG) << "Set func graph size: " << object_graphs_map_.size(); } -const mindspore::HashMap> &GetObjGraphs() { +const mindspore::OrderedMap> &GetObjGraphs() { MS_LOG(DEBUG) << "Obj graphs size: " << object_graphs_map_.size(); return object_graphs_map_; } diff --git a/mindspore/ccsrc/pipeline/jit/parse/data_converter.h b/mindspore/ccsrc/pipeline/jit/parse/data_converter.h index c9956b394a3..759e6d14fdf 100644 --- a/mindspore/ccsrc/pipeline/jit/parse/data_converter.h +++ b/mindspore/ccsrc/pipeline/jit/parse/data_converter.h @@ -23,6 +23,7 @@ #include #include #include +#include "utils/ordered_map.h" #include "utils/hash_map.h" #include "pipeline/jit/parse/parse_base.h" #include "include/common/utils/python_adapter.h" @@ -37,7 +38,7 @@ bool GetObjectValue(const std::string &obj_key, ValuePtr *const data); void SetObjGraphValue(const std::string &obj_key, const FuncGraphPtr &data); -const mindspore::HashMap> &GetObjGraphs(); +const mindspore::OrderedMap> &GetObjGraphs(); std::vector GetObjKey(const py::object &obj); ResolveTypeDef GetObjType(const py::object &obj);