Browse Source

!13692 Fix the case of negative index in getitem depend reorder pass

From: @ginfung
Reviewed-by: @zh_qh,@hwhewei
Signed-off-by: @zh_qh
pull/13692/MERGE
mindspore-ci-bot Gitee 5 years ago
parent
commit
d5bf6a2666
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      mindspore/ccsrc/frontend/optimizer/irpass/item_tuple_or_list_eliminate.h

+ 4
- 1
mindspore/ccsrc/frontend/optimizer/irpass/item_tuple_or_list_eliminate.h View File

@@ -370,7 +370,10 @@ class GetitemDependReorder : public AnfVisitor {
int64_t idx = idx_value->value();
if (abs->isa<abstract::AbstractTuple>()) {
auto abs_tuple = abs->cast<abstract::AbstractTuplePtr>();
if (LongToSize(idx) >= abs_tuple->elements().size() || idx < 0) {
if (idx < 0) {
idx += abs_tuple->elements().size();
}
if (idx < 0 || LongToSize(idx) >= abs_tuple->elements().size()) {
MS_LOG(EXCEPTION) << "The idx value " << idx << " of tuple_getitem node " << c_->DebugString()
<< " is out of range.";
}


Loading…
Cancel
Save