Add leyer test for aten::sub operator (#15406)

This commit is contained in:
Leonard Sikorski 2023-01-31 16:50:05 +01:00 committed by GitHub
parent 12a9621650
commit f66f31a3b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,36 @@
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class TestSub(PytorchLayerTest):
def _prepare_input(self):
return self.input_data
def create_model(self):
class aten_sub(torch.nn.Module):
def forward(self, x, y, alpha: float):
return torch.sub(x, y, alpha=alpha)
ref_net = None
return aten_sub(), ref_net, "aten::sub"
@pytest.mark.parametrize('input_data', [(np.random.randn(2, 3, 4).astype(np.float32),
np.random.randn(2, 3, 4).astype(np.float32),
np.random.randn(1)),
(np.random.randn(4, 2, 3).astype(np.float32),
np.random.randn(1, 2, 3).astype(np.float32),
np.random.randn(1)),])
@pytest.mark.nightly
@pytest.mark.precommit
def test_sub(self, ie_device, precision, ir_version, input_data):
self.input_data = input_data
self._test(*self.create_model(), ie_device, precision, ir_version)