!14145 support negative index

From: @youui
Reviewed-by: @zh_qh,@kisnwang
Signed-off-by: @zh_qh
This commit is contained in:
mindspore-ci-bot 2021-03-30 20:30:52 +08:00 committed by Gitee
commit f71699fbfd
2 changed files with 14 additions and 11 deletions

View File

@ -154,17 +154,19 @@ OptPassGroupMap GetOptPassesA(const opt::irpass::OptimizeIRPassLib &irpass) {
opt::OptPassConfig a_after_grad = opt::OptPassConfig({
irpass.inline_without_move_,
});
opt::OptPassConfig a_3 = opt::OptPassConfig({
irpass.arithmetic_simplify2_,
irpass.same_eliminate_,
irpass.check_bprop_eliminate_,
irpass.switch_layer_defer_inline_,
irpass.replace_applicator_,
irpass.mirror_mini_step_elim_,
irpass.virtual_add_elim_,
irpass.row_tensor_add_zeros_like_,
irpass.mini_step_allgather_replace_,
});
opt::OptPassConfig a_3 = opt::OptPassConfig(
{
irpass.arithmetic_simplify2_,
irpass.same_eliminate_,
irpass.check_bprop_eliminate_,
irpass.switch_layer_defer_inline_,
irpass.replace_applicator_,
irpass.mirror_mini_step_elim_,
irpass.virtual_add_elim_,
irpass.row_tensor_add_zeros_like_,
irpass.mini_step_allgather_replace_,
},
false, true);
opt::OptPassConfig virtual_dataset = opt::OptPassConfig({irpass.virtual_dataset_eliminate_});
opt::irpass::ResolveIRPassLib resolve_irpass;

View File

@ -113,6 +113,7 @@ def _tuple_getitem_by_tensor(data, tensor_index):
Outputs:
Type, is the same as the element type of data.
"""
tensor_index = F.select(tensor_index >= 0, tensor_index, tensor_index + len(data))
return _tuple_get_item_tensor(data, tensor_index)