Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[PT FE] Add conversion of ErfInv op (#35036)

Katarzyna Mitrusa3c8daea9fc5
diff --git a/src/frontends/pytorch/src/op_table.cpp b/src/frontends/pytorch/src/op_table.cpp
index a40612908f8..0f018836755 100644
--- a/src/frontends/pytorch/src/op_table.cpp
+++ b/src/frontends/pytorch/src/op_table.cpp
@@ -5,6 +5,7 @@
#include "op_table.hpp"
#include "common_translators.hpp"
+#include "openvino/op/erfinv.hpp"
#include "openvino/opsets/opset10.hpp"
#include "utils.hpp"
#include "utils_quantize.hpp"
@@ -511,6 +512,8 @@ const std::unordered_map<std::string, CreatorFunction> get_supported_ops_ts() {
{"aten::equal", op::translate_1to1_match_2_inputs_align_types<opset10::Equal>},
{"aten::erf", op::translate_erf},
{"aten::erfc", op::translate_erfc},
+ {"aten::erfinv",
+ op::optional_out<op::translate_1to1_match_1_inputs_with_fp32_type_alignment<ov::op::v17::ErfInv>, 1>},
{"aten::exp", op::optional_out<op::translate_exp, 1>},
{"aten::exp_", op::inplace_op<op::translate_exp>},
{"aten::expand", op::translate_expand},
@@ -938,6 +941,7 @@ const std::unordered_map<std::string, CreatorFunction> get_supported_ops_fx() {
{"aten.eq.Tensor", op::translate_1to1_match_2_inputs_align_types<opset10::Equal>},
{"aten.erf.default", op::translate_erf},
{"aten.erfc.default", op::translate_erfc},
+ {"aten.erfinv.default", op::translate_1to1_match_1_inputs_with_fp32_type_alignment<ov::op::v17::ErfInv>},
{"aten.exp.default", op::translate_1to1_match_1_inputs_with_fp32_type_alignment<opset10::Exp>},
{"aten.expm1.default", op::translate_expm1},
{"aten.expand.default", op::translate_expand},
diff --git a/tests/layer_tests/pytorch_tests/test_unary_ops.py b/tests/layer_tests/pytorch_tests/test_unary_ops.py
index 194e1f5a465..f99644923f5 100644
--- a/tests/layer_tests/pytorch_tests/test_unary_ops.py
+++ b/tests/layer_tests/pytorch_tests/test_unary_ops.py
@@ -18,6 +18,7 @@ OPS = {
"aten::erf_": torch.erf_,
"aten::erfc": torch.erfc,
"aten::erfc_": torch.erfc_,
+ "aten::erfinv": torch.erfinv,
"aten::exp": torch.exp,
"aten::exp_": torch.exp_,
"aten::expm1": torch.expm1,
@@ -158,6 +159,7 @@ class TestUnaryOp(PytorchLayerTest):
"aten::sqrt",
"aten::erf",
"aten::erfc",
+ "aten::erfinv",
"aten::exp",
"aten::expm1",
"aten::relu",
@@ -190,9 +192,11 @@ class TestUnaryOp(PytorchLayerTest):
self.dtype = dtype
if self.use_torch_export() and op_type == "aten::atanh" and dtype in [torch.int8, torch.int32, torch.int64]:
pytest.xfail(reason="torch.export after 2.4.0 doesn't support unsigned int types for atanh in some configurations")
+ if ie_device == "GPU" and op_type == "aten::erfinv":
+ pytest.xfail(reason="erfinv is not supported on GPU")
self._test(unary_op_net(OPS[op_type], dtype), op_type,
ie_device, precision, ir_version,
- kwargs_to_prepare_input={"unit_range": op_type == "aten::atanh"})
+ kwargs_to_prepare_input={"unit_range": op_type in ("aten::atanh", "aten::erfinv")})
@pytest.mark.nightly
@pytest.mark.precommit
@@ -251,6 +255,7 @@ class TestUnaryOp(PytorchLayerTest):
"aten::sqrt",
"aten::erf",
"aten::erfc",
+ "aten::erfinv",
"aten::exp",
"aten::expm1",
"aten::relu",
@@ -278,9 +283,11 @@ class TestUnaryOp(PytorchLayerTest):
])
def test_unary_op_out(self, op_type, dtype, ie_device, precision, ir_version):
self.dtype = dtype
+ if ie_device == "GPU" and op_type == "aten::erfinv":
+ pytest.xfail(reason="erfinv is not supported on GPU")
self._test(unary_op_out_net(OPS[op_type], dtype), op_type,
ie_device, precision, ir_version,
- kwargs_to_prepare_input={"unit_range": op_type == "aten::atanh"})
+ kwargs_to_prepare_input={"unit_range": op_type in ("aten::atanh", "aten::erfinv")})
@pytest.mark.nightly
@pytest.mark.precommit