!30745 Bugfix in ConvertNonscalarTensorToParameter when value is uninitialized

Merge pull request !30745 from DeshiChen/0228_uninit_value
This commit is contained in:
i-robot 2022-03-03 08:27:34 +00:00 committed by Gitee
commit b631a1065e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 4 additions and 3 deletions

View File

@ -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<tensor::TensorPtr>(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;