!29109 Fix Core Dump after RuntimeError

Merge pull request !29109 from hwjiaorui/segmentation-fault
This commit is contained in:
i-robot 2022-01-17 01:21:50 +00:00 committed by Gitee
commit 68189870e4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 10 additions and 13 deletions

View File

@ -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];

View File

@ -319,16 +319,16 @@ std::vector<GraphSegmentPtr> 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<CNodePtr> &nodes) const {
AscendGraphOptimization::GetInstance().SetOperatorInfo(nodes);
GetAscendGraphOptimization().SetOperatorInfo(nodes);
}
void AscendDeviceContext::CreateKernel(const std::vector<CNodePtr> &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 {

View File

@ -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();

View File

@ -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<CNodePtr> &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<KernelGraphPtr> memo_;
};
AscendGraphOptimization GetAscendGraphOptimization();
} // namespace ascend
} // namespace device
} // namespace mindspore