From 4ebeb23dddc48ec3c4b4397672c86d814b3f3374 Mon Sep 17 00:00:00 2001 From: dayschan Date: Wed, 2 Mar 2022 15:27:07 +0800 Subject: [PATCH] bugfix in ConvertNonscalarTensorToParameter when value is uninitialized. --- .../backend/optimizer/graph_kernel/core/graph_builder.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mindspore/ccsrc/backend/optimizer/graph_kernel/core/graph_builder.cc b/mindspore/ccsrc/backend/optimizer/graph_kernel/core/graph_builder.cc index 02ba6ec3fcc..5e1dcd9a811 100644 --- a/mindspore/ccsrc/backend/optimizer/graph_kernel/core/graph_builder.cc +++ b/mindspore/ccsrc/backend/optimizer/graph_kernel/core/graph_builder.cc @@ -110,10 +110,11 @@ bool ConvertNonscalarTensorToParameter(const FuncGraphPtr &fg, AnfNodePtrList *c for (size_t i = 1; i < inputs.size(); ++i) { const auto &tnode = inputs[i]; auto tensor = GetValueNode(tnode); - if (tensor == nullptr || tensor->DataSize() == 1) { - continue; + if (tensor == nullptr) continue; + // data is nullptr means uninitialized. + if (tensor->data().const_data() == nullptr || tensor->DataSize() > 1) { + (void)value_nodes.insert(tnode); } - (void)value_nodes.insert(tnode); } } if (value_nodes.empty()) return false;