* add arm as a matrix for build job * uncomment * comment * try inside pipeline * check location * another dirs * try to privide correct action path * use corrected action * use newer commit * use newer commit * use newer commit * use newer action commit * add setting * rm from pipeline, adapt action iteslf * add missing deps * enable samples and debian jobs * correct yml * correct image name * correct syntax, use self-hosted option * enable onnx runtime and c++, use newer action * enable Python and CPU Func tests * add missing deps for arm64 * increase timeout for python tests * disable some tests, add more time * skip failing tests * skip speech sample test on arm * dummy chang * skip mxnet mo on arm, run all tests * rm quotes * separate linux x86 and arm64 workflows * rm unused matrix refs, add timeouts * add skips for c++ tests and some Python tests * correct cache keys, extend timeout * skip more python tests * add more skips: for python and CPU func * extend cpu func list with skips * disable cpu func tests and python api 2.0 tests * rm disable job * styling, rm pr trigger, rm always(), rm unnecessary changes * revert * use ifs instead of comments, provide better wording for skips
84 lines
2.7 KiB
Python
84 lines
2.7 KiB
Python
# Copyright (C) 2018-2023 Intel Corporation
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
import platform
|
|
|
|
import pytest
|
|
|
|
from pytorch_layer_test_class import PytorchLayerTest
|
|
|
|
|
|
class TestArgMinArgMax(PytorchLayerTest):
|
|
def _prepare_input(self, dtype="float32"):
|
|
import numpy as np
|
|
a = np.random.randn(1, 3, 10, 10).astype(dtype)
|
|
|
|
return (a.repeat(2).reshape(1, 3, 20, 10),)
|
|
|
|
|
|
def create_model(self, op_type, axes, keep_dims):
|
|
import torch
|
|
op_types = {
|
|
'max': torch.argmax,
|
|
'min': torch.argmin
|
|
}
|
|
|
|
op = op_types[op_type]
|
|
|
|
class aten_argmin_argmax(torch.nn.Module):
|
|
def __init__(self, op):
|
|
super(aten_argmin_argmax, self).__init__()
|
|
self.op = op
|
|
|
|
def forward(self, x):
|
|
return self.op(x)
|
|
|
|
class aten_argmin_argmax_3arg(torch.nn.Module):
|
|
def __init__(self, op, axes, keep_dims):
|
|
super().__init__()
|
|
self.op = op
|
|
self.axes = axes
|
|
self.keep_dims = keep_dims
|
|
|
|
def forward(self, x):
|
|
return self.op(x, self.axes, self.keep_dims)
|
|
|
|
ref_net = None
|
|
if axes is None and keep_dims is None:
|
|
model_cls = aten_argmin_argmax(op)
|
|
else:
|
|
model_cls = aten_argmin_argmax_3arg(op, axes, keep_dims)
|
|
|
|
return model_cls, ref_net, f"aten::arg{op_type}"
|
|
|
|
@pytest.mark.parametrize("axes,keep_dims", [
|
|
(None, None),
|
|
(None, False),
|
|
(None, True),
|
|
(0, False),
|
|
(0, True),
|
|
(1, False),
|
|
(1, True),
|
|
(2, False),
|
|
(2, True),
|
|
(3, False),
|
|
(3, True),
|
|
(-3, False),
|
|
(-3, True),
|
|
(-2, False),
|
|
(-2, True),
|
|
(-1, False),
|
|
(-1, True)])
|
|
@pytest.mark.parametrize("op_type", ['max', 'min'])
|
|
@pytest.mark.parametrize("dtype", ["float32", "int32", "int64"])
|
|
@pytest.mark.nightly
|
|
@pytest.mark.precommit
|
|
@pytest.mark.xfail(condition=platform.system() in ('Darwin', 'Linux') and platform.machine() in ('arm', 'armv7l',
|
|
'aarch64',
|
|
'arm64', 'ARM64'),
|
|
reason='Ticket - 122715')
|
|
def test_argmin_argmax(self, axes, keep_dims, op_type, dtype, ie_device, precision, ir_version):
|
|
self._test(*self.create_model(op_type, axes, keep_dims),
|
|
ie_device, precision, ir_version, trace_model=True,
|
|
kwargs_to_prepare_input={"dtype": dtype})
|