Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

1.1 KB
Raw Blame
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

import pytest

from pytorch_layer_test_class import PytorchLayerTest


class TestConstantPadND(PytorchLayerTest):
    def _prepare_input(self):
        return (self.random.randn(2, 5, 3, 4),)

    def create_model(self, pad, value):

        import torch
        class aten_constant_pad_nd(torch.nn.Module):
            def __init__(self, pad=None, value=None):
                super().__init__()
                self.pad = pad
                self.value = value

            def forward(self, x):
                return torch.constant_pad_nd(x, self.pad, self.value)

        return aten_constant_pad_nd(pad, value), "aten::constant_pad_nd"

    @pytest.mark.parametrize(("pad", "value"),
                             [((1,1,1,1), 0),((0,2,0,2), -1.0),((3,1,5,2), 0.5),((0,0,0,0), 0),])

    @pytest.mark.precommit
    @pytest.mark.precommit_torch_export
    @pytest.mark.precommit_fx_backend
    def test_constant_pad_nd(self, pad, value, ie_device, precision, ir_version):
        self._test(*self.create_model(pad, value),
                   ie_device, precision, ir_version)