From d8c3146b874d80cf73d0e0cc231d991cbffd19a0 Mon Sep 17 00:00:00 2001 From: hwjiaorui Date: Fri, 14 Jan 2022 18:08:53 +0800 Subject: [PATCH] fix core dump --- .../ascend/executor/tiling/op_tiling_adapter.cc | 2 +- .../runtime/hardware/ascend/ascend_device_context.cc | 8 ++++---- .../hardware/ascend/ascend_graph_optimization.cc | 2 +- .../hardware/ascend/ascend_graph_optimization.h | 11 ++++------- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/mindspore/ccsrc/runtime/device/ascend/executor/tiling/op_tiling_adapter.cc b/mindspore/ccsrc/runtime/device/ascend/executor/tiling/op_tiling_adapter.cc index 27c067effef..50e623a17db 100644 --- a/mindspore/ccsrc/runtime/device/ascend/executor/tiling/op_tiling_adapter.cc +++ b/mindspore/ccsrc/runtime/device/ascend/executor/tiling/op_tiling_adapter.cc @@ -71,7 +71,7 @@ std::string OpTilingCalculateAdapter::GetOutputName(const CNodePtr &node, size_t std::string OpTilingCalculateAdapter::GetInputName(const CNodePtr &node, size_t index) { MS_EXCEPTION_IF_NULL(node); - if (input_names_.size() < index) { + if (input_names_.size() <= index) { return "unknown_name"; } return input_names_[index]; diff --git a/mindspore/ccsrc/runtime/hardware/ascend/ascend_device_context.cc b/mindspore/ccsrc/runtime/hardware/ascend/ascend_device_context.cc index d2b6929c9f0..611fd2ac871 100644 --- a/mindspore/ccsrc/runtime/hardware/ascend/ascend_device_context.cc +++ b/mindspore/ccsrc/runtime/hardware/ascend/ascend_device_context.cc @@ -319,16 +319,16 @@ std::vector AscendDeviceContext::PartitionGraph( void AscendDeviceContext::UnifyMindIR(const KernelGraphPtr &graph) const { MS_EXCEPTION_IF_NULL(graph); - AscendGraphOptimization::GetInstance().UnifyMindIR(graph); + GetAscendGraphOptimization().UnifyMindIR(graph); } void AscendDeviceContext::OptimizeGraph(const KernelGraphPtr &graph) const { MS_EXCEPTION_IF_NULL(graph); - AscendGraphOptimization::GetInstance().OptimizeGraph(graph); + GetAscendGraphOptimization().OptimizeGraph(graph); } void AscendDeviceContext::SetOperatorInfo(const std::vector &nodes) const { - AscendGraphOptimization::GetInstance().SetOperatorInfo(nodes); + GetAscendGraphOptimization().SetOperatorInfo(nodes); } void AscendDeviceContext::CreateKernel(const std::vector &nodes) const { @@ -618,7 +618,7 @@ bool AscendDeviceContext::IsLoopCountSink(const KernelGraphPtr &graph) const { // kernel by kernel mode interface void AscendDeviceContext::OptimizeSingleOpGraph(const KernelGraphPtr &graph) const { - AscendGraphOptimization::GetInstance().OptimizeSingleOpGraph(graph); + GetAscendGraphOptimization().OptimizeSingleOpGraph(graph); } void AscendDeviceContext::PreprocessBeforeRunSingleOpGraph(const KernelGraphPtr &graph) const { diff --git a/mindspore/ccsrc/runtime/hardware/ascend/ascend_graph_optimization.cc b/mindspore/ccsrc/runtime/hardware/ascend/ascend_graph_optimization.cc index e002a1ee6d1..32f7a4e8102 100644 --- a/mindspore/ccsrc/runtime/hardware/ascend/ascend_graph_optimization.cc +++ b/mindspore/ccsrc/runtime/hardware/ascend/ascend_graph_optimization.cc @@ -34,7 +34,7 @@ namespace mindspore { namespace device { namespace ascend { using AscendAutoMonad = mindspore::session::AscendAutoMonad; - +AscendGraphOptimization GetAscendGraphOptimization() { return AscendGraphOptimization(); } void AscendGraphOptimization::OptimizeGraph(const KernelGraphPtr &graph) { MS_EXCEPTION_IF_NULL(graph); MS_LOG(INFO) << "Status record: start optimize graph. graph id: " << graph->graph_id(); diff --git a/mindspore/ccsrc/runtime/hardware/ascend/ascend_graph_optimization.h b/mindspore/ccsrc/runtime/hardware/ascend/ascend_graph_optimization.h index e311d4f3bce..423cd9017a0 100644 --- a/mindspore/ccsrc/runtime/hardware/ascend/ascend_graph_optimization.h +++ b/mindspore/ccsrc/runtime/hardware/ascend/ascend_graph_optimization.h @@ -26,19 +26,14 @@ namespace device { namespace ascend { class AscendGraphOptimization { public: - static AscendGraphOptimization &GetInstance() { - static AscendGraphOptimization instance; - return instance; - } - void OptimizeGraph(const KernelGraphPtr &graph); void OptimizeSingleOpGraph(const KernelGraphPtr &graph); void SetOperatorInfo(const std::vector &nodes); void UnifyMindIR(const KernelGraphPtr &graph); - - private: AscendGraphOptimization() { graph_manager_ = MakeManager(); } ~AscendGraphOptimization() = default; + + private: AscendGraphOptimization(const AscendGraphOptimization &) = delete; AscendGraphOptimization &operator=(const AscendGraphOptimization &) = delete; // Graph Optimized level-2 interface @@ -70,6 +65,8 @@ class AscendGraphOptimization { // Note: Please clean the set before each use. std::set memo_; }; + +AscendGraphOptimization GetAscendGraphOptimization(); } // namespace ascend } // namespace device } // namespace mindspore