Files
openvino/tests/layer_tests/pytorch_tests/test_leaky_relu.py
T
Maxim Vafin fe1ac700f0 [PT FE] Fix issues in multiple operations (#17418)
* Fix issues in aten::chunk and aten::split_with_sizes replacers

* Fix code style

* Fix compute issue

* Fix code style

* Support 1 chunk

* Fix issues in meshgrid, sqrt, rsqrt and exp operations

* Use Interpolate-11

* Fix unary ops

* Add tests for unary ops

* Fix unary ops tests

* Add changes in utils

* Fix mo test

* Remove extra line

* Fix mo tests for int
2023-05-22 10:35:34 +02:00

37 lines
1.2 KiB
Python

# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestLeakyRelu(PytorchLayerTest):
def _prepare_input(self):
import numpy as np
return (np.random.randn(1, 3, 224, 224).astype(np.float32),)
def create_model(self, alpha, inplace):
import torch
import torch.nn.functional as F
class aten_leaky_relu(torch.nn.Module):
def __init__(self, alpha, inplace):
super(aten_leaky_relu, self).__init__()
self.alpha = alpha
self.inplace = inplace
def forward(self, x):
return x, F.leaky_relu(x, self.alpha, inplace=self.inplace)
ref_net = None
return aten_leaky_relu(alpha, inplace), ref_net, "aten::leaky_relu" if not inplace else "aten::leaky_relu_"
@pytest.mark.parametrize("alpha", [0.01, 1.01, -0.01])
@pytest.mark.parametrize("inplace", [True, False])
@pytest.mark.nightly
@pytest.mark.precommit
def test_leaky_relu(self, alpha, inplace, ie_device, precision, ir_version):
self._test(*self.create_model(alpha, inplace), ie_device, precision, ir_version)