-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
Copy pathtest_stack.py
88 lines (70 loc) · 2.42 KB
/
test_stack.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Copyright (C) 2018-2025 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
@pytest.mark.precommit_torch_export
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
@pytest.mark.precommit_torch_export
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)