forked from mindspore-Ecosystem/mindspore
!19542 Support tuple index is negative during TraceTupleCNodeEffectInfo
Merge pull request !19542 from Margaret_wangrui/tuple_index_is_negative_r1.3
This commit is contained in:
commit
984a1fa1ad
|
@ -566,8 +566,17 @@ class SideEffectFinder {
|
|||
// Pop out tuple index.
|
||||
auto top_index = tuple_indexes->top();
|
||||
tuple_indexes->pop();
|
||||
// Follow the tuple item according the index.
|
||||
size_t input_index = static_cast<size_t>(top_index) + 1;
|
||||
size_t input_index = 0;
|
||||
// Support tuple index is negative
|
||||
if (top_index < 0) {
|
||||
if (cnode->size() + top_index < 0) {
|
||||
MS_LOG(EXCEPTION) << "Invalid make_tuple: " << cnode->DebugString() << " index=" << top_index;
|
||||
}
|
||||
input_index = static_cast<size_t>(cnode->size() + top_index);
|
||||
} else {
|
||||
// Follow the tuple item according the index.
|
||||
input_index = static_cast<size_t>(top_index) + 1;
|
||||
}
|
||||
if (input_index >= cnode->size()) {
|
||||
MS_LOG(EXCEPTION) << "Invalid make_tuple: " << cnode->DebugString() << " index=" << top_index;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue