OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[PT FE] Support aten.eye.m for FX graph (#25833)
Maxim Vafinc0f7765f3ff7
diff --git a/src/frontends/pytorch/src/op/eye.cpp b/src/frontends/pytorch/src/op/eye.cppindex 7565b4a5f06..64751bfae3d 100644--- a/src/frontends/pytorch/src/op/eye.cpp+++ b/src/frontends/pytorch/src/op/eye.cpp@@ -45,6 +45,20 @@ OutputVector translate_eye(const NodeContext& context) {return {context.mark_node(std::make_shared<v0::Convert>(eye, dtype))};};+OutputVector translate_eye_fx(const NodeContext& context) {+ num_inputs_check(context, 2, 2);+ auto x = get_input_as_i32(context, 0);+ auto y = get_input_as_i32(context, 1);+ // aten::eye support only main diagonal+ auto diagonal = context.mark_node(v0::Constant::create(element::i32, Shape{}, {0}));+ auto dtype = element::i32;+ if (context.has_attribute("dtype")) {+ dtype = context.get_attribute<element::Type>("dtype");+ }+ auto eye = context.mark_node(std::make_shared<v9::Eye>(x, y, diagonal, dtype));+ return {context.mark_node(std::make_shared<v0::Convert>(eye, dtype))};+};+} // namespace op} // namespace pytorch} // namespace frontenddiff --git a/src/frontends/pytorch/src/op_table.cpp b/src/frontends/pytorch/src/op_table.cppindex 078af4e3655..83ff923efcd 100644--- a/src/frontends/pytorch/src/op_table.cpp+++ b/src/frontends/pytorch/src/op_table.cpp@@ -267,6 +267,7 @@ OP_CONVERTER(translate_div_fx);OP_CONVERTER(translate_div_fx_);OP_CONVERTER(translate_embedding_bag_fx);OP_CONVERTER(translate_expand_fx);+OP_CONVERTER(translate_eye_fx);OP_CONVERTER(translate_fake_quantize_per_channel_affine_fx);OP_CONVERTER(translate_fake_quantize_per_tensor_affine_fx);OP_CONVERTER(translate_full_fx);@@ -839,6 +840,7 @@ const std::map<std::string, CreatorFunction> get_supported_ops_fx() {{"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_fx},+ {"aten.eye.m", op::translate_eye_fx},{"aten.fake_quantize_per_channel_affine_cachemask.default", op::translate_fake_quantize_per_channel_affine_fx},{"aten.fill.Scalar", op::translate_fill},{"aten.fill_.Scalar", op::inplace_op<op::translate_fill>},diff --git a/tests/layer_tests/pytorch_tests/test_eye.py b/tests/layer_tests/pytorch_tests/test_eye.pyindex c79422731ee..55af29b12a5 100644--- a/tests/layer_tests/pytorch_tests/test_eye.py+++ b/tests/layer_tests/pytorch_tests/test_eye.py@@ -51,6 +51,7 @@ class TestEye(PytorchLayerTest):@pytest.mark.nightly@pytest.mark.precommit+ @pytest.mark.precommit_torch_export@pytest.mark.parametrize("dtype", ["bool", "int8", "uint8", "int32", "int64", "float32", "float64"])@pytest.mark.parametrize("m", [2, 3, 4, 5])def test_eye_square(self, dtype, m, ie_device, precision, ir_version):@@ -60,6 +61,7 @@ class TestEye(PytorchLayerTest):@pytest.mark.nightly@pytest.mark.precommit+ @pytest.mark.precommit_torch_export@pytest.mark.parametrize("dtype", ["bool", "int8", "uint8", "int32", "int64", "float32", "float64"])@pytest.mark.parametrize(("m", "n"), [[2, 2], [3, 4], [5, 3]])def test_eye(self, dtype, m, n, ie_device, precision, ir_version):