!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:
i-robot 2021-07-08 01:31:42 +00:00 committed by Gitee
commit 984a1fa1ad
1 changed files with 11 additions and 2 deletions

View File

@ -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;
}