!45834 stride slice bug

Merge pull request !45834 from lianliguang/stride_slice
This commit is contained in:
i-robot 2022-11-22 10:59:47 +00:00 committed by Gitee
commit 49fba49aef
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 7 additions and 2 deletions

View File

@ -68,7 +68,13 @@ bool CheckValueType(const AnfNodePtr &input_node, size_t inputs_num) {
}
static bool CheckStridedSlice(const CNodePtr &cnode) {
if (!common::AnfAlgo::HasNodeAttr(kAttrStrides, cnode)) {
// check stride[-1] != 1
if (common::AnfAlgo::HasNodeAttr(kAttrStrides, cnode)) {
auto strides = common::AnfAlgo::GetNodeAttr<std::vector<int64_t>>(cnode, kAttrStrides);
if (!strides.empty() && strides[strides.size() - 1] <= 0) {
return false;
}
} else {
auto inputs = cnode->inputs();
const size_t kInputNum = 5;
if (inputs.size() == kInputNum + IntToSize(1)) {
@ -81,7 +87,6 @@ static bool CheckStridedSlice(const CNodePtr &cnode) {
return CheckValueType(input_node, inputs.size());
}
}
return true;
}