forked from mindspore-Ecosystem/mindspore
!29113 modify tensor slice
Merge pull request !29113 from changzherui/mod_tensor_slice
This commit is contained in:
commit
8903571af3
|
@ -596,7 +596,10 @@ def get_slice_stride(index_slice, dim_size):
|
|||
start_default = -1
|
||||
stop_default = -(dim_size + 1)
|
||||
start = start_default if index_slice.start is None else index_slice.start
|
||||
stop = stop_default if index_slice.stop is None else index_slice.stop
|
||||
if index_slice.stop is None:
|
||||
stop = stop_default
|
||||
else:
|
||||
stop = min(stop_default, index_slice.stop) if step >= 0 else max(stop_default, index_slice.stop)
|
||||
return start, stop, step
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue