Commit c2e60c6f by Haichen Shen Committed by Leyuan Wang

[Relay][Frontend][Bugfix] Fix bug in converting slice_axis when axis is negative (#2739)

* bug fix

* trigger ci
parent fe060493
...@@ -200,6 +200,9 @@ def _mx_slice_axis(inputs, attrs): ...@@ -200,6 +200,9 @@ def _mx_slice_axis(inputs, attrs):
axis = attrs.get_int("axis") axis = attrs.get_int("axis")
ax_beg = attrs.get_int("begin") ax_beg = attrs.get_int("begin")
ax_end = attrs.get_str("end") ax_end = attrs.get_str("end")
if axis < 0:
axis += len(shape)
assert axis >= 0 and axis < len(shape)
if ax_end == "None": if ax_end == "None":
ax_end = int(shape[axis]) ax_end = int(shape[axis])
else: else:
......
...@@ -352,6 +352,7 @@ def test_forward_slice_axis(): ...@@ -352,6 +352,7 @@ def test_forward_slice_axis():
verify((3, 4), 0, 1, None) verify((3, 4), 0, 1, None)
verify((3, 4), 1, 0, 2) verify((3, 4), 1, 0, 2)
verify((3, 4), 1, -3, -1) verify((3, 4), 1, -3, -1)
verify((3, 4), -1, -3, -1)
if __name__ == '__main__': if __name__ == '__main__':
...@@ -380,4 +381,4 @@ if __name__ == '__main__': ...@@ -380,4 +381,4 @@ if __name__ == '__main__':
test_forward_broadcast_ops() test_forward_broadcast_ops()
test_forward_elemwise_ops() test_forward_elemwise_ops()
test_forward_scalar_ops() test_forward_scalar_ops()
test_forward_slice_axis() test_forward_slice_axis()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment