Files
openvino/tests/layer_tests/pytorch_tests/test_log.py
Maxim Vafin 994b227b86 Remove None at outputs of the model, improve types handling in frontend (#15258)
* Remove None at outputs of the model, improve types handling in frontend

* Fix py code style

* Add torch dependency in pybind tests

* Fix tests if fe is disabled and add backward type cpnversion

* Move decoder tests to layer tests

* Fix codestyle

* Add comment

* Move tests to separate folder

* Update .ci/azure/linux.yml
2023-01-25 13:28:47 +03:00

48 lines
1.4 KiB
Python

# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestLog(PytorchLayerTest):
def _prepare_input(self, dtype):
import numpy as np
return (np.random.uniform(2, 16, (1, 10)).astype(dtype),)
def create_model(self, op):
import torch
ops = {
"log": torch.log,
"log_": torch.log_,
"log2": torch.log2,
"log2_": torch.log2_
}
op_fn = ops[op]
class aten_log(torch.nn.Module):
def __init__(self, op):
super(aten_log, self).__init__()
self.op = op
def forward(self, x):
return self.op(x)
ref_net = None
return aten_log(op_fn), ref_net, f"aten::{op}"
@pytest.mark.nightly
@pytest.mark.precommit
@pytest.mark.parametrize(("op", "input_dtype"),
[["log", "float32"],
["log", "int32"],
["log_", "float32"],
["log2", "float32"],
["log2", "int32"],
["log2_", "float32"]])
def test_log(self, op, input_dtype, ie_device, precision, ir_version):
self._test(*self.create_model(op), ie_device, precision,
ir_version, kwargs_to_prepare_input={"dtype": input_dtype})