Files
openvino/tests/layer_tests/pytorch_tests/test_stack.py
Mikhail Ryzhov 4078bd9c19 [GHA] Speed up PyTorch Layer unit tests (#20613)
* test

* fixed tests

* typo

* fixed tests

* rest of the tests

* fixed rsub test

* tmp fix

* Revert "tmp fix"

This reverts commit b8bf1e9492e13497895da488612c9a137ef840bc.

* fixed test params

* reset thirdparty/pugixml

* Revert "fixed rsub test"

This reverts commit 9b6be34b8666936e8124b6622fcc5185b640de92.

* fixed typo

* fixed test data

* reset test_rsub

* removed unused param

* reverrted runner

* simplified call

* fixed random

* changed logical to auto mode

* Revert "fixed random"

This reverts commit 8a4f20b24641144f823a7e1f1ff92038634acf32.

* fixed test_all

* replaced random_sample with randn

* fixed rebase issue

* reverted logical splitting

* Update tests/layer_tests/pytorch_tests/test_repeat_interleave.py

Co-authored-by: Maxim Vafin <maxim.vafin@intel.com>

* Update tests/layer_tests/pytorch_tests/test_all.py

Co-authored-by: Maxim Vafin <maxim.vafin@intel.com>

* Apply suggestions from code review

Co-authored-by: Maxim Vafin <maxim.vafin@intel.com>

* fixed merge conflict

---------

Co-authored-by: Maxim Vafin <maxim.vafin@intel.com>
2023-10-26 13:10:51 +04:00

87 lines
2.3 KiB
Python

# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestStack2D(PytorchLayerTest):
def _prepare_input(self):
return self.input_tensors
def create_model(self, dim):
import torch
class aten_stack(torch.nn.Module):
def __init__(self, dim):
super(aten_stack, self).__init__()
self.dim = dim
def forward(self, x, y):
inputs = [x, y]
return torch.stack(inputs, self.dim)
ref_net = None
return aten_stack(dim), ref_net, "aten::stack"
@pytest.mark.parametrize("input_shape",
[
[1, 3, 3],
[4, 4, 2],
[8, 1, 1, 9]
])
@pytest.mark.parametrize("dim", ([
0, 1, 2,
]))
@pytest.mark.nightly
@pytest.mark.precommit
def test_stack2D(self, input_shape, dim, ie_device, precision, ir_version):
self.input_tensors = [
np.random.randn(*input_shape).astype(np.float32),
np.random.randn(*input_shape).astype(np.float32),
]
self._test(*self.create_model(dim), ie_device, precision, ir_version)
class TestStack3D(PytorchLayerTest):
def _prepare_input(self):
return self.input_tensors
def create_model(self, dim):
import torch
class aten_stack(torch.nn.Module):
def __init__(self, dim):
super(aten_stack, self).__init__()
self.dim = dim
def forward(self, x, y, z):
inputs = [x, y, z]
return torch.stack(inputs, self.dim)
ref_net = None
return aten_stack(dim), ref_net, "aten::stack"
@pytest.mark.parametrize("input_shape",
[
[1, 3, 3],
[4, 4, 2],
[8, 1, 1, 9]
])
@pytest.mark.parametrize("dim", ([
0, 1, 2,
]))
@pytest.mark.nightly
@pytest.mark.precommit
def test_stack3D(self, input_shape, dim, ie_device, precision, ir_version):
self.input_tensors = [
np.random.randn(*input_shape).astype(np.float32),
np.random.randn(*input_shape).astype(np.float32),
np.random.randn(*input_shape).astype(np.float32)
]
self._test(*self.create_model(dim), ie_device, precision, ir_version)