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
[TF FE][JAX FE] Support latest TF 2.18, JAX 0.4.35 and NumPy 2.x (#27246)
Roman Kazantsev8bc165595cea
diff --git a/.github/workflows/job_tokenizers.yml b/.github/workflows/job_tokenizers.ymlindex 14243bda135..5c5e59aa3be 100644--- a/.github/workflows/job_tokenizers.yml+++ b/.github/workflows/job_tokenizers.yml@@ -20,12 +20,15 @@ on:description: 'Components that are affected by changes in the commit defined by the Smart CI Action'type: stringrequired: true+ python-version:+ description: 'Python version to setup. E.g., "3.11"'+ type: string+ required: truepermissions: read-allenv:PIP_CACHE_PATH: /mount/caches/pip/linux- PYTHON_VERSION: '3.11'TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref || github.ref }}jobs:@@ -63,10 +66,10 @@ jobs:if: runner.os == 'macOS'run: brew install pigz- - name: Setup Python ${{ env.PYTHON_VERSION }}+ - name: Setup Python ${{ inputs.python-version }}uses: ./.github/actions/setup_pythonwith:- version: ${{ env.PYTHON_VERSION }}+ version: ${{ inputs.python-version }}pip-cache-path: ${{ runner.os == 'Linux' && env.PIP_CACHE_PATH || '' }}should-setup-pip-paths: ${{ runner.os == 'Linux' }}self-hosted-runner: ${{ runner.os == 'Linux' }}diff --git a/.github/workflows/linux_arm64.yml b/.github/workflows/linux_arm64.ymlindex 67cd4d0d1a5..0af30621a2a 100644--- a/.github/workflows/linux_arm64.yml+++ b/.github/workflows/linux_arm64.yml@@ -146,6 +146,7 @@ jobs:shell: bashcontainer: '{"image": "${{ fromJSON(needs.docker.outputs.images).ov_build.ubuntu_20_04_arm64 }}", "volumes": ["/mount:/mount"]}'affected-components: ${{ needs.smart_ci.outputs.affected_components }}+ python-version: '3.11'if: fromJSON(needs.smart_ci.outputs.affected_components).TOKENIZERSCXX_Unit_Tests:diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.ymlindex 7c47c1c635c..5492ad40aa1 100644--- a/.github/workflows/mac.yml+++ b/.github/workflows/mac.yml@@ -258,6 +258,7 @@ jobs:runner: 'macos-13'shell: bashaffected-components: ${{ needs.smart_ci.outputs.affected_components }}+ python-version: '3.11'if: fromJSON(needs.smart_ci.outputs.affected_components).TOKENIZERSCXX_Unit_Tests:diff --git a/.github/workflows/mac_arm64.yml b/.github/workflows/mac_arm64.ymlindex 81cd229d1dd..8100b74734a 100644--- a/.github/workflows/mac_arm64.yml+++ b/.github/workflows/mac_arm64.yml@@ -258,6 +258,7 @@ jobs:runner: 'macos-13-xlarge'shell: bashaffected-components: ${{ needs.smart_ci.outputs.affected_components }}+ python-version: '3.11'if: fromJSON(needs.smart_ci.outputs.affected_components).TOKENIZERSCXX_Unit_Tests:diff --git a/.github/workflows/ubuntu_22.yml b/.github/workflows/ubuntu_22.ymlindex 753708d9b3b..92178fce7f5 100644--- a/.github/workflows/ubuntu_22.yml+++ b/.github/workflows/ubuntu_22.yml@@ -491,6 +491,7 @@ jobs:shell: bashcontainer: '{"image": "${{ fromJSON(needs.docker.outputs.images).ov_build.ubuntu_22_04_x64 }}", "volumes": ["/mount:/mount"]}'affected-components: ${{ needs.smart_ci.outputs.affected_components }}+ python-version: '3.11'if: fromJSON(needs.smart_ci.outputs.affected_components).TOKENIZERSiGPU:diff --git a/.github/workflows/ubuntu_24.yml b/.github/workflows/ubuntu_24.ymlindex 9d9aba6739f..d874e06a189 100644--- a/.github/workflows/ubuntu_24.yml+++ b/.github/workflows/ubuntu_24.yml@@ -144,9 +144,31 @@ jobs:affected-components: ${{ needs.smart_ci.outputs.affected_components }}python-version: '3.12'+ TensorFlow_Layer_Tests:+ name: TensorFlow Layer Tests+ needs: [ Docker, Build, Smart_CI, Openvino_tokenizers ]+ uses: ./.github/workflows/job_tensorflow_layer_tests.yml+ with:+ runner: 'aks-linux-4-cores-16gb'+ container: '{"image": "${{ fromJSON(needs.docker.outputs.images).ov_test.ubuntu_24_04_x64 }}", "volumes": ["/mount:/mount"]}'+ affected-components: ${{ needs.smart_ci.outputs.affected_components }}+ python-version: '3.12'++ Openvino_tokenizers:+ name: OpenVINO tokenizers extension+ needs: [ Build, Smart_CI, Docker ]+ uses: ./.github/workflows/job_tokenizers.yml+ with:+ runner: 'aks-linux-4-cores-16gb'+ shell: bash+ container: '{"image": "${{ fromJSON(needs.docker.outputs.images).ov_build.ubuntu_24_04_x64 }}", "volumes": ["/mount:/mount"]}'+ affected-components: ${{ needs.smart_ci.outputs.affected_components }}+ python-version: '3.12'+ if: fromJSON(needs.smart_ci.outputs.affected_components).TOKENIZERS+Overall_Status:name: ci/gha_overall_status_ubuntu_24- needs: [Smart_CI, Build, Debian_Packages, Samples, Python_Unit_Tests]+ needs: [Smart_CI, Build, Debian_Packages, Samples, Python_Unit_Tests, Pytorch_Layer_Tests, TensorFlow_Layer_Tests, Openvino_tokenizers]if: ${{ always() }}runs-on: ubuntu-lateststeps:diff --git a/.github/workflows/windows_vs2019_release.yml b/.github/workflows/windows_vs2019_release.ymlindex 1a3e8753f15..1c84db5dcda 100644--- a/.github/workflows/windows_vs2019_release.yml+++ b/.github/workflows/windows_vs2019_release.yml@@ -235,6 +235,7 @@ jobs:runner: 'aks-win-4-cores-8gb'shell: pwshaffected-components: ${{ needs.smart_ci.outputs.affected_components }}+ python-version: '3.11'if: fromJSON(needs.smart_ci.outputs.affected_components).TOKENIZERSPython_Unit_Tests:diff --git a/src/frontends/jax/src/op/erfc.cpp b/src/frontends/jax/src/op/erfc.cppnew file mode 100644index 00000000000..5a38577f868--- /dev/null+++ b/src/frontends/jax/src/op/erfc.cpp@@ -0,0 +1,33 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/frontend/jax/node_context.hpp"+#include "openvino/op/erf.hpp"+#include "openvino/op/subtract.hpp"+#include "utils.hpp"++using namespace std;+using namespace ov;+using namespace ov::op;++namespace ov {+namespace frontend {+namespace jax {+namespace op {++OutputVector translate_erfc(const NodeContext& context) {+ num_inputs_check(context, 1, 1);+ auto x = context.get_input(0);++ // create const one of the same type as x+ auto const_one = create_same_type_const_scalar<int64_t>(x, 1);+ Output<Node> res = make_shared<v0::Erf>(x);+ res = make_shared<v1::Subtract>(const_one, res);+ return {res};+};++} // namespace op+} // namespace jax+} // namespace frontend+} // namespace ovdiff --git a/src/frontends/jax/src/op_table.cpp b/src/frontends/jax/src/op_table.cppindex 500226594fe..98f22452c5a 100644--- a/src/frontends/jax/src/op_table.cpp+++ b/src/frontends/jax/src/op_table.cpp@@ -45,6 +45,7 @@ OP_CONVERTER(translate_convert);OP_CONVERTER(translate_convolution);OP_CONVERTER(translate_copy);OP_CONVERTER(translate_dot_general);+OP_CONVERTER(translate_erfc);OP_CONVERTER(translate_integer_pow);OP_T_CONVERTER(translate_reduce_op);OP_CONVERTER(translate_reduce_window_max);@@ -72,6 +73,7 @@ const std::map<std::string, CreatorFunction> get_supported_ops_jaxpr() {{"dot_general", op::translate_dot_general},{"eq", op::translate_binary_op<v1::Equal>},{"erf", op::translate_1to1_match_1_input<v0::Erf>},+ {"erfc", op::translate_erfc},{"exp", op::translate_1to1_match_1_input<v0::Exp>},{"ge", op::translate_binary_op<v1::GreaterEqual>},{"gt", op::translate_binary_op<v1::Greater>},diff --git a/tests/constraints.txt b/tests/constraints.txtindex 775d3287c06..b800d289ce1 100644--- a/tests/constraints.txt+++ b/tests/constraints.txt@@ -11,7 +11,7 @@ sympy>=1.10wheel>=0.38.1defusedxml>=0.7.1fastjsonschema~=2.17.1-tensorflow>=2.5,<2.18.0+tensorflow>=2.5,<2.19.0requests>=2.25.1opencv-python>=4.5paddlepaddle==2.6.1@@ -21,11 +21,11 @@ pytest>=5.0,<8.4pytest-dependency==0.5.1pytest-html==4.1.1pytest-timeout==2.3.1-jax<=0.4.33-jaxlib<=0.4.33+jax<=0.4.35+jaxlib<=0.4.35kornia==0.7.0networkx<=3.3-flax<=0.9.0+flax<=0.10.0--extra-index-url https://download.pytorch.org/whl/cputorch~=2.4.1; platform_system != "Darwin" or platform_machine != "x86_64"diff --git a/tests/layer_tests/jax_tests/test_erfc.py b/tests/layer_tests/jax_tests/test_erfc.pynew file mode 100644index 00000000000..c84655635ba--- /dev/null+++ b/tests/layer_tests/jax_tests/test_erfc.py@@ -0,0 +1,38 @@+# Copyright (C) 2018-2024 Intel Corporation+# SPDX-License-Identifier: Apache-2.0++import jax+import numpy as np+import pytest+from jax import numpy as jnp++from jax_layer_test_class import JaxLayerTest++rng = np.random.default_rng(109734)+++class TestErfc(JaxLayerTest):+ def _prepare_input(self):+ # erf are mostly changing in a range [-4, 4]+ x = rng.uniform(-4.0, 4.0, self.input_shape).astype(self.input_type)++ x = jnp.array(x)+ return [x]++ def create_model(self, input_shape, input_type):+ self.input_shape = input_shape+ self.input_type = input_type++ def jax_erfc(x):+ return jax.lax.erfc(x)++ return jax_erfc, None, 'erfc'++ @pytest.mark.parametrize("input_shape", [[2], [3, 4]])+ @pytest.mark.parametrize("input_type", [np.float16, np.float32, np.float64])+ @pytest.mark.nightly+ @pytest.mark.precommit_jax_fe+ def test_erfc(self, ie_device, precision, ir_version, input_shape, input_type):+ self._test(*self.create_model(input_shape, input_type),+ ie_device, precision,+ ir_version)diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Equal.py b/tests/layer_tests/tensorflow_tests/test_tf_Equal.pyindex 7d61317857d..8c0b496a7b4 100644--- a/tests/layer_tests/tensorflow_tests/test_tf_Equal.py+++ b/tests/layer_tests/tensorflow_tests/test_tf_Equal.py@@ -146,8 +146,8 @@ class TestTFEqual(CommonTFLayerTest):# Values for checking important corner cases for float values# expect: false false false false false false true false true- x_corner = [1., 1., 1., np.nan, np.nan, np.nan, np.inf, np.inf, np.NINF]- y_corner = [np.nan, np.inf, np.NINF, np.nan, np.inf, np.NINF, np.inf, np.NINF, np.NINF]+ x_corner = [1., 1., 1., np.nan, np.nan, np.nan, np.inf, np.inf, -np.inf]+ y_corner = [np.nan, np.inf, -np.inf, np.nan, np.inf, -np.inf, np.inf, -np.inf, -np.inf]test_data_float16 = [pytest.param(diff --git a/tests/requirements_tensorflow b/tests/requirements_tensorflowindex c29aa777fda..3ae47d81ee2 100644--- a/tests/requirements_tensorflow+++ b/tests/requirements_tensorflow@@ -1,15 +1,21 @@-# tensorflow-intel inside tensorflow still requires numpy<2.0.0-numpy==1.26.4+# test ovc with NumPy 2.x on Ubuntu 24 with default Python 3.12+# test against NumPy 1.x with older Python versions+# tensorflow-intel 2.18.0 depends on numpy<2.1.0 and >=1.26.0+numpy==1.26.4; python_version < "3.12"+numpy==2.0.2; python_version >= "3.12"pytest==7.0.1pytest-xdist[psutil]==3.6.1pytest-html==4.1.1transformers==4.45.1# install exact keras version since tensorflow depends and has no upper bound for itkeras==3.6.0-tensorflow==2.17.0; platform_system != "Darwin" or platform_machine != "x86_64"+tensorflow==2.18.0; python_version >= "3.12" and (platform_system != "Darwin" or platform_machine != "x86_64")+tensorflow==2.17.0; python_version < "3.12" and (platform_system != "Darwin" or platform_machine != "x86_64")tensorflow==2.16.2; platform_system == "Darwin" and platform_machine == "x86_64"+# install explicit version of wrapt to avoid "this __dict__ descriptor does not support '_DictWrapper' objects" error from TensorFlow 2.18+wrapt==1.15.0; python_version >= "3.12"# tensorflow-text is not available for both Windows and ARM platforms-tensorflow-text==2.17.0; platform_system == "Linux" and platform_machine == "x86_64"+tensorflow-text==2.17.0; python_version < "3.12" and platform_system == "Linux" and platform_machine == "x86_64"tensorflow-hub==0.16.1-jax==0.4.33+jax==0.4.35defusedxml==0.7.1diff --git a/tools/mo/requirements_tf.txt b/tools/mo/requirements_tf.txtindex 4897012177c..fb19c216e95 100644--- a/tools/mo/requirements_tf.txt+++ b/tools/mo/requirements_tf.txt@@ -1,6 +1,6 @@-c ../constraints.txth5py-tensorflow>=1.15.5,<2.18.0+tensorflow>=1.15.5,<2.19.0numpy>=1.16.6,<1.27networkxdefusedxmldiff --git a/tools/mo/requirements_tf2.txt b/tools/mo/requirements_tf2.txtindex b6f9029cdff..50df4160c66 100644--- a/tools/mo/requirements_tf2.txt+++ b/tools/mo/requirements_tf2.txt@@ -1,6 +1,6 @@-c ../constraints.txth5py-tensorflow>=2.5,<2.18.0+tensorflow>=2.5,<2.19.0numpy>=1.16.6,<1.27networkxdefusedxml