Files
openvino/tests/layer_tests/pytorch_tests/test_var_mean.py
T
Andrey KashchikhinandIlya Lavrenov b67cff7cd5 [CI] [GHA] Introduce macOS ARM64 as a matrix parameter in the macOS pipeline (#20363)
* add m1 mac pipelines as a matrix parameter

* Update mac.yml

disable java_api because of macos arm64 - Java is not available on macOS arm64 runners

* Update mac.yml

added always condition for all tests

* Update mac.yml

* Update mac.yml

* Update mac.yml

* Update setup.py

temp commit

* Update tools/openvino_dev/setup.py

* use matrix for var

* add mxnet to extras only for x86_64

* skip failing tests

* use xfail for Python tests; add missing filter for transformations tests

* skip CPU func tests on x86_64 mac; skip some tests from CPU func tests on arm mac

* Update mac.yml

* skip tests on mac arm

* skip tests on darwin; apply review

* add more skips for python and c++ tests

* skip tf tests

* skip more tf tests; skip more Python UT stages

* rm alwayses, rm triggers, add nightly trigger

---------

Co-authored-by: Ilya Lavrenov <ilya.lavrenov@intel.com>
2023-10-23 15:06:22 +04:00

71 lines
2.8 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 TestVar(PytorchLayerTest):
def _prepare_input(self):
import numpy as np
return (np.random.randn(1, 3, 224, 224).astype(np.float32),)
def create_model(self, unbiased, dim=None, keepdim=True, two_args_case=True, op_type="var"):
import torch
ops = {
"var": torch.var,
"var_mean": torch.var_mean,
"std": torch.std,
"std_mean": torch.std_mean
}
op = ops[op_type]
class aten_var(torch.nn.Module):
def __init__(self, dim, unbiased, keepdim, op):
super(aten_var, self).__init__()
self.unbiased = unbiased
self.dim = dim
self.keepdim = keepdim
self.op = op
def forward(self, x):
return self.op(x, self.dim, unbiased=self.unbiased, keepdim=self.keepdim)
class aten_var2args(torch.nn.Module):
def __init__(self, unbiased, op):
super(aten_var2args, self).__init__()
self.unbiased = unbiased
self.op = op
def forward(self, x):
return self.op(x, self.unbiased)
ref_net = None
op_name = f"aten::{op_type}"
if two_args_case:
return aten_var2args(unbiased, op), ref_net, op_name
return aten_var(dim, unbiased, keepdim, op), ref_net, op_name
@pytest.mark.nightly
@pytest.mark.precommit
@pytest.mark.parametrize("unbiased", [True, False])
@pytest.mark.parametrize("op_type", ["var", "var_mean", "std", "std_mean"])
@pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64',
reason='Ticket - 122715')
def test_var2args(self, unbiased, op_type, ie_device, precision, ir_version):
self._test(*self.create_model(unbiased, op_type=op_type), ie_device, precision, ir_version)
@pytest.mark.nightly
@pytest.mark.precommit
@pytest.mark.parametrize("unbiased", [False, True])
@pytest.mark.parametrize("dim", [None, 0, 1, 2, 3, -1, -2, (0, 1), (-1, -2), (0, 1, -1), (0, 1, 2, 3)])
@pytest.mark.parametrize("keepdim", [True, False])
@pytest.mark.parametrize("op_type", ["var", "var_mean", "std", "std_mean"])
@pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64',
reason='Ticket - 122715')
def test_var(self, unbiased, dim, keepdim, op_type, ie_device, precision, ir_version):
self._test(*self.create_model(unbiased, dim, keepdim, two_args_case=False, op_type=op_type), ie_device, precision, ir_version)