Skip to content

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

[PT FE] Support for torch 2.4.0 (#26203)

Maxim Vafinc12606759f2a
diff --git a/src/frontends/pytorch/src/op/scaled_dot_product_attention.cpp b/src/frontends/pytorch/src/op/scaled_dot_product_attention.cpp
index 15ab0e07cab..a1e03beadab 100644
--- a/src/frontends/pytorch/src/op/scaled_dot_product_attention.cpp
+++ b/src/frontends/pytorch/src/op/scaled_dot_product_attention.cpp
@@ -40,8 +40,8 @@ std::shared_ptr<ov::Node> translate_scaled_dot_product_attention_common(const No
OutputVector translate_scaled_dot_product_attention(const NodeContext& context) {
// aten::scaled_dot_product_attention(Tensor query, Tensor key, Tensor value, Tensor? attn_mask=None, float
- // dropout_p=0., bool is_causal=False, float scale=None)
- num_inputs_check(context, 6, 7);
+ // dropout_p=0., bool is_causal=False, float scale=None, bool enable_gqa=False)
+ num_inputs_check(context, 6, 8);
return {translate_scaled_dot_product_attention_common(context)};
};
diff --git a/tests/constraints.txt b/tests/constraints.txt
index 16bffdf1696..bc6a3b4a906 100644
--- a/tests/constraints.txt
+++ b/tests/constraints.txt
@@ -27,7 +27,7 @@ jaxlib<=0.4.14
kornia==0.7.0
networkx<=3.3
keras>=2.0.0,<3.0.0
-timm==1.0.7
+timm==1.0.8
--extra-index-url https://download.pytorch.org/whl/cpu
-torch>=1.13,<2.4
\ No newline at end of file
+torch~=2.4.0
\ No newline at end of file
diff --git a/tests/layer_tests/pytorch_tests/test_arange.py b/tests/layer_tests/pytorch_tests/test_arange.py
index 7f35ea974b3..22ef792351f 100644
--- a/tests/layer_tests/pytorch_tests/test_arange.py
+++ b/tests/layer_tests/pytorch_tests/test_arange.py
@@ -3,7 +3,7 @@
import pytest
-from pytorch_layer_test_class import PytorchLayerTest, skip_check
+from pytorch_layer_test_class import PytorchLayerTest, skip_check, skip_if_export
class TestArange(PytorchLayerTest):
@@ -110,7 +110,13 @@ class TestArange(PytorchLayerTest):
@pytest.mark.nightly
@pytest.mark.precommit_torch_export
@pytest.mark.precommit_fx_backend
- @pytest.mark.parametrize("dtype", [None, "float32", "float64", "int32", "int64", "int8", "uin8"])
+ @pytest.mark.parametrize("dtype", [None,
+ skip_if_export("float32"),
+ skip_if_export("float64"),
+ skip_if_export("int32"),
+ "int64",
+ skip_if_export("int8"),
+ skip_if_export("uint8")])
@pytest.mark.parametrize("end", [1, 2, 3])
@pytest.mark.parametrize("use_out", [skip_check(True), False])
def test_arange_end_only(self, dtype, end, use_out, ie_device, precision, ir_version):
@@ -136,8 +142,14 @@ class TestArange(PytorchLayerTest):
@pytest.mark.nightly
@pytest.mark.precommit_torch_export
- @pytest.mark.precommit_fx_backend
- @pytest.mark.parametrize("dtype", ["float32", "float64", "int32", "int64", "int8", "uint8"])
+ @pytest.mark.precommit_fx_backend
+ @pytest.mark.parametrize("dtype", [skip_check(None),
+ skip_if_export("float32"),
+ skip_if_export("float64"),
+ skip_if_export("int32"),
+ "int64",
+ skip_if_export("int8"),
+ skip_if_export("uint8")])
@pytest.mark.parametrize("end", [1, 2, 3])
def test_arange_end_only_with_prim_dtype(self, dtype, end, ie_device, precision, ir_version):
self._test(*self.create_model(dtype, 1, False, True), ie_device, precision, ir_version,
@@ -158,4 +170,4 @@ class TestArange(PytorchLayerTest):
@pytest.mark.parametrize("start,end,step", [(0, 1, 1), (-2, 1, 1.25), (1, -5, -1), (1, 10, 2), (-1, -5, -2)])
def test_arange_start_end_step_with_prim_dtype(self, dtype, end, start, step, ie_device, precision, ir_version):
self._test(*self.create_model(dtype, 3, ref_dtype=True), ie_device, precision, ir_version,
- kwargs_to_prepare_input={"end": end, "start": start, "step": step, "ref_dtype":dtype})
+ kwargs_to_prepare_input={"end": end, "start": start, "step": step, "ref_dtype": dtype})
diff --git a/tests/layer_tests/pytorch_tests/test_full.py b/tests/layer_tests/pytorch_tests/test_full.py
index 6ef8ca25a69..09c2fb9674f 100644
--- a/tests/layer_tests/pytorch_tests/test_full.py
+++ b/tests/layer_tests/pytorch_tests/test_full.py
@@ -85,7 +85,6 @@ class TestFull(PytorchLayerTest):
@pytest.mark.nightly
@pytest.mark.precommit
@pytest.mark.precommit_fx_backend
- @pytest.mark.precommit_torch_export
def test_full(self, shape, value, ie_device, precision, ir_version):
self._test(*self.create_model(shape), ie_device, precision,
ir_version, kwargs_to_prepare_input={'value': value})
@@ -96,7 +95,6 @@ class TestFull(PytorchLayerTest):
@pytest.mark.parametrize("with_names", [skip_if_export(True), False])
@pytest.mark.nightly
@pytest.mark.precommit_fx_backend
- @pytest.mark.precommit_torch_export
def test_full_dtype(self, shape, value, dtype, with_names, ie_device, precision, ir_version):
self._test(*self.create_model(shape, dtype=dtype, use_dtype=True, with_names=with_names), ie_device, precision,
ir_version, kwargs_to_prepare_input={'value': value})
@@ -285,7 +283,6 @@ class TestFullLike(PytorchLayerTest):
@pytest.mark.nightly
@pytest.mark.precommit
@pytest.mark.precommit_fx_backend
- @pytest.mark.precommit_torch_export
def test_full_like(self, shape, value, ie_device, precision, ir_version):
self._test(*self.create_model(), ie_device, precision, ir_version,
kwargs_to_prepare_input={'value': value, 'shape': shape})
@@ -294,7 +291,6 @@ class TestFullLike(PytorchLayerTest):
@pytest.mark.parametrize("value", [0, 1, -1, 0.5])
@pytest.mark.parametrize("dtype", ["int8", "int32", "int64", "float32", "float64"])
@pytest.mark.nightly
- @pytest.mark.precommit_torch_export
def test_full_like_dtype(self, shape, value, dtype, ie_device, precision, ir_version):
self._test(*self.create_model(dtype, use_dtype=True), ie_device, precision, ir_version,
kwargs_to_prepare_input={'value': value, 'shape': shape})
@@ -355,7 +351,6 @@ class TestNewFull(PytorchLayerTest):
@pytest.mark.nightly
@pytest.mark.precommit
@pytest.mark.precommit_fx_backend
- @pytest.mark.precommit_torch_export
def test_new_full(self, shape, value, input_dtype, ie_device, precision, ir_version):
self._test(*self.create_model(shape), ie_device, precision, ir_version,
kwargs_to_prepare_input={'value': value, 'input_dtype': input_dtype}, use_convert_model=True)
@@ -364,7 +359,6 @@ class TestNewFull(PytorchLayerTest):
@pytest.mark.parametrize("value,input_dtype", [(0, np.uint8), (1, np.int32), (-1, np.float32), (0.5, np.float64)])
@pytest.mark.parametrize("dtype", ["int8", "int32", "int64", "float32", "float64"])
@pytest.mark.nightly
- @pytest.mark.precommit_torch_export
def test_new_full_with_dtype(self, value, shape, dtype, input_dtype, ie_device, precision, ir_version):
self._test(*self.create_model(shape, dtype=dtype, used_dtype=True), ie_device, precision, ir_version,
kwargs_to_prepare_input={'value': value, 'input_dtype': input_dtype}, use_convert_model=True)
diff --git a/tests/layer_tests/pytorch_tests/test_unary_ops.py b/tests/layer_tests/pytorch_tests/test_unary_ops.py
index 689ad67e64d..fd58ce5d40f 100644
--- a/tests/layer_tests/pytorch_tests/test_unary_ops.py
+++ b/tests/layer_tests/pytorch_tests/test_unary_ops.py
@@ -159,6 +159,8 @@ class TestUnaryOp(PytorchLayerTest):
])
def test_unary_op(self, op_type, dtype, ie_device, precision, ir_version):
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")
self._test(unary_op_net(OPS[op_type], dtype), None, op_type,
ie_device, precision, ir_version)
diff --git a/tests/model_hub_tests/pytorch/timm_models b/tests/model_hub_tests/pytorch/timm_models
index a101a374bde..311b54242f4 100644
--- a/tests/model_hub_tests/pytorch/timm_models
+++ b/tests/model_hub_tests/pytorch/timm_models
@@ -31,8 +31,8 @@ convnext_base.clip_laion2b,None
convnext_large_mlp.clip_laion2b_augreg,None
convnext_tiny_hnf.a2h_in1k,None
convnextv2_base.fcmae,None
-crossvit_15_dagger_240.in1k,None
-crossvit_base_240.in1k,None
+crossvit_15_dagger_240.in1k,None,xfail_export,Unsupported on torch 2.4
+crossvit_base_240.in1k,None,xfail_export,Unsupported on torch 2.4
cs3darknet_focus_m.c2ns_in1k,None
cs3darknet_m.c2ns_in1k,None
cs3darknet_x.c2ns_in1k,None
@@ -46,6 +46,7 @@ cspresnext50.ra_in1k,None
darknet53.c2ns_in1k,None
darknetaa53.c2ns_in1k,None
davit_base.msft_in1k,None
+davit_base_fl.msft_florence2,None
deit_base_distilled_patch16_224.fb_in1k,None
deit_base_patch16_224.fb_in1k,None
deit3_base_patch16_224.fb_in1k,None
@@ -106,7 +107,7 @@ efficientformerv2_l.snap_dist_in1k,None,xfail_export,Requested None inlined inpu
efficientformerv2_s0.snap_dist_in1k,None,xfail_export,Requested None inlined input
efficientformerv2_s1.snap_dist_in1k,None,xfail_export,Requested None inlined input
efficientformerv2_s2.snap_dist_in1k,None,xfail_export,Requested None inlined input
-efficientnet_b0.ra_in1k,None
+efficientnet_b0.ra4_e3600_r224_in1k,None
efficientnet_b1.ft_in1k,None
efficientnet_b1_pruned.in1k,None
efficientnet_b2.ra_in1k,None
@@ -236,14 +237,18 @@ mixer_b16_224.goog_in21k,None
mixer_l16_224.goog_in21k,None
mixnet_s.ft_in1k,None
mnasnet_small.lamb_in1k,None
+mobilenet_edgetpu_v2_m.ra4_e3600_r224_in1k,None
+mobilenetv1_100.ra4_e3600_r224_in1k,None
+mobilenetv1_100h.ra4_e3600_r224_in1k,None
mobilenetv2_050.lamb_in1k,None
mobilenetv2_110d.ra_in1k,None
mobilenetv2_120d.ra_in1k,None
mobilenetv3_rw.rmsp_in1k,None
mobilenetv3_small_050.lamb_in1k,None
+mobilenetv4_conv_aa_large.e230_r384_in12k,None
mobilenetv4_conv_blur_medium.e500_r224_in1k,None
mobilenetv4_conv_small.e1200_r224_in1k,None
-mobilenetv4_hybrid_medium.e500_r224_in1k,None
+mobilenetv4_hybrid_medium.e200_r256_in12k,None
mobileone_s0.apple_in1k,None
mobileone_s1.apple_in1k,None
mobileone_s2.apple_in1k,None
@@ -356,7 +361,7 @@ resnet34d.ra2_in1k,None
resnet50.a1_in1k,None
resnet50_clip.openai,None
resnet50_clip_gap.openai,None
-resnet50_gn.a1h_in1k,None
+resnet50_gn.a1h_in1k,None,xfail_export,Unsupported on torch 2.4
resnet50c.gluon_in1k,None
resnet50d.a1_in1k,None
resnet50s.gluon_in1k,None
@@ -434,6 +439,9 @@ swinv2_base_window16_256.ms_in1k,None
swinv2_base_window8_256.ms_in1k,None
swinv2_cr_small_224.sw_in1k,None
swinv2_cr_tiny_ns_224.sw_in1k,None
+test_byobnet.r160_in1k,None
+test_efficientnet.r160_in1k,None
+test_vit.r160_in1k,None
tf_efficientnet_b0.aa_in1k,None
tf_efficientnet_b1.aa_in1k,None
tf_efficientnet_b2.aa_in1k,None
@@ -500,7 +508,7 @@ vit_base_patch32_224.augreg_in1k,None
vit_base_patch32_clip_224.datacompxl,None
vit_base_patch32_clip_quickgelu_224.metaclip_2pt5b,None
vit_base_patch8_224.augreg2_in21k_ft_in1k,None
-vit_base_r50_s16_224.orig_in21k,None
+vit_base_r50_s16_224.orig_in21k,None,xfail_export,Unsupported on torch 2.4
vit_betwixt_patch16_reg1_gap_256.sbb_in1k,None
vit_betwixt_patch16_reg4_gap_256.sbb_in12k,None
vit_betwixt_patch16_rope_reg4_gap_256.sbb_in1k,None,xfail,Argument shapes are inconsistent
@@ -509,7 +517,7 @@ vit_huge_patch14_224.mae,None
vit_huge_patch14_gap_224.in1k_ijepa,None
vit_large_patch14_clip_224.datacompxl,None
vit_large_patch14_clip_quickgelu_224.dfn2b,None
-vit_large_r50_s32_224.augreg_in21k,None
+vit_large_r50_s32_224.augreg_in21k,None,xfail_export,Unsupported on torch 2.4
vit_little_patch16_reg1_gap_256.sbb_in12k,None
vit_little_patch16_reg4_gap_256.sbb_in1k,None
vit_medium_patch16_gap_240.sw_in12k,None
@@ -523,7 +531,7 @@ vit_relpos_base_patch16_clsgap_224.sw_in1k,None
vit_relpos_base_patch32_plus_rpn_256.sw_in1k,None
vit_relpos_medium_patch16_cls_224.sw_in1k,None
vit_relpos_medium_patch16_rpn_224.sw_in1k,None
-vit_small_r26_s32_224.augreg_in21k,None
+vit_small_r26_s32_224.augreg_in21k,None,xfail_export,Unsupported on torch 2.4
vit_so400m_patch14_siglip_224.webli,None
vit_so400m_patch14_siglip_gap_224.pali_mix,None,skip,Access to model google/paligemma-3b-mix-224-jax is restricted
vit_srelpos_small_patch16_224.sw_in1k,None