!40721 fix reshape expander: support shape value 0

Merge pull request !40721 from DeshiChen/0822_reshape
This commit is contained in:
i-robot 2022-08-25 08:46:17 +00:00 committed by Gitee
commit 0ed1fba203
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 9 additions and 0 deletions

View File

@ -57,6 +57,15 @@ class Reshape : public OpDesc {
MS_LOG(INFO) << "Reshape's attr shape is neither Tensor nor ValueTuple. Expand failed";
return {};
}
for (size_t i = 0; i < shape.size(); i++) {
if (shape[i] == 0) {
if (input_x->shape.size() <= i) {
MS_LOG(INFO) << "Reshape's attr shape[" << i << "] is 0, but input's rank is " << input_x->shape.size();
return {};
}
shape[i] = input_x->shape[i];
}
}
auto result = gb.Reshape(input_x, shape);
return {result};
}