#38136·openvino

[错误]: [PyTorch 前端] 当步长为负数且省略了起始/结束边界时, aten::slice 的翻译不正确

作者: aryan1234-l创建于 2026年9月14日更新于 2026年9月17日
标签bugsupport_request

Step-by-step reproduction

Append the following test case to tests/layer_tests/pytorch_tests/test_slice.py: ` class TestSliceNegativeStepDefaults(PytorchLayerTest):

def _prepare_input(self):
    return (np.array(range(16), np.float32),)
def create_model(self, case):
    if case == "both_default":
        class aten_slice(torch.nn.Module):
            def forward(self, x):
                return x[::-1]
        return aten_slice(), "aten::slice"
    elif case == "start_default":
        class aten_slice(torch.nn.Module):
            def forward(self, x):
                return x[:5:-1]
        return aten_slice(), "aten::slice"
    elif case == "end_default":
        class aten_slice(torch.nn.Module):
            def forward(self, x):
                return x[10::-1]
        return aten_slice(), "aten::slice"
@pytest.mark.parametrize("case", ["both_default", "start_default", "end_default"])
@pytest.mark.nightly
@pytest.mark.precommit
def test_slice_negative_step_defaults(self, ie_device, precision, ir_version, case):
    self._test(*self.create_model(case), ie_device, precision, ir_version)

`

Run the newly added test via pytest: pytest tests/layer_tests/pytorch_tests/test_slice.py::TestSliceNegativeStepDefaults -v

Relevant log output

内容来源: openvinotoolkit/openvino