[PT FE]: support aten::hardsigmoid_ (#22865)

### Details:
 - *support aten::hardsigmoid_ (inplace variant)*
enables rtmdet model from mmyolo


### Tickets:
 - *CVS-132283*
This commit is contained in:
Ekaterina Aidova 2024-02-16 17:53:39 +04:00 committed by GitHub
parent 1ec3c5ce99
commit 04d6d3dd66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 38 additions and 0 deletions

View File

@ -428,6 +428,8 @@ const std::map<std::string, CreatorFunction> get_supported_ops_ts() {
{"aten::gru", op::translate_gru},
{"aten::gt", op::translate_1to1_match_2_inputs_align_types<opset10::Greater>},
{"aten::hardsigmoid", op::quantizable_op<op::translate_1to1_match_1_inputs<opset10::HSigmoid>>},
{"aten::hardsigmoid_",
op::quantizable_op<op::inplace_op<op::translate_1to1_match_1_inputs<opset10::HSigmoid>>>},
{"aten::hardswish", op::quantizable_op<op::translate_1to1_match_1_inputs<opset10::HSwish>>},
{"aten::hardswish_", op::quantizable_op<op::inplace_op<op::translate_1to1_match_1_inputs<opset10::HSwish>>>},
{"aten::hardtanh", op::quantizable_op<op::translate_hardtanh>},

View File

@ -0,0 +1,36 @@
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestHardSigmoid(PytorchLayerTest):
def _prepare_input(self, shape, dtype):
import numpy as np
return (np.random.randn(*shape).astype(dtype),)
def create_model(self, inplace):
import torch
import torch.nn.functional as F
class aten_hardsigmoid(torch.nn.Module):
def __init__(self, inplace):
super(aten_hardsigmoid, self).__init__()
self.inplace = inplace
def forward(self, x):
return F.hardsigmoid(x, self.inplace), x
ref_net = None
return aten_hardsigmoid(inplace), ref_net, "aten::hardsigmoid" if not inplace else "aten::hardsigmoid_"
@pytest.mark.nightly
@pytest.mark.precommit
@pytest.mark.parametrize("shape", [[1, 10], [1, 2, 3], [1, 2, 3, 4], [1, 2, 3, 4, 5]])
@pytest.mark.parametrize("dtype", ["float32", "float64"])
@pytest.mark.parametrize("inplace", [True, False])
def test_hardsigmoid(self, shape, dtype, inplace, ie_device, precision, ir_version):
self._test(*self.create_model(inplace), ie_device, precision, ir_version, kwargs_to_prepare_input={"shape": shape, "dtype": dtype})