Skip to content

Commit 8bc1655

Browse files
authored
[TF FE][JAX FE] Support latest TF 2.18, JAX 0.4.35 and NumPy 2.x (openvinotoolkit#27246)
**Details:** Support TF 2.18 and JAX 0.4.35 **Ticket:** TBD --------- Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>
1 parent 9b97cf9 commit 8bc1655

15 files changed

+126
-17
lines changed

.github/workflows/job_tokenizers.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@ on:
2020
description: 'Components that are affected by changes in the commit defined by the Smart CI Action'
2121
type: string
2222
required: true
23+
python-version:
24+
description: 'Python version to setup. E.g., "3.11"'
25+
type: string
26+
required: true
2327

2428
permissions: read-all
2529

2630
env:
2731
PIP_CACHE_PATH: /mount/caches/pip/linux
28-
PYTHON_VERSION: '3.11'
2932
TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref || github.ref }}
3033

3134
jobs:
@@ -63,10 +66,10 @@ jobs:
6366
if: runner.os == 'macOS'
6467
run: brew install pigz
6568

66-
- name: Setup Python ${{ env.PYTHON_VERSION }}
69+
- name: Setup Python ${{ inputs.python-version }}
6770
uses: ./.github/actions/setup_python
6871
with:
69-
version: ${{ env.PYTHON_VERSION }}
72+
version: ${{ inputs.python-version }}
7073
pip-cache-path: ${{ runner.os == 'Linux' && env.PIP_CACHE_PATH || '' }}
7174
should-setup-pip-paths: ${{ runner.os == 'Linux' }}
7275
self-hosted-runner: ${{ runner.os == 'Linux' }}

.github/workflows/linux_arm64.yml

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ jobs:
146146
shell: bash
147147
container: '{"image": "${{ fromJSON(needs.docker.outputs.images).ov_build.ubuntu_20_04_arm64 }}", "volumes": ["/mount:/mount"]}'
148148
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
149+
python-version: '3.11'
149150
if: fromJSON(needs.smart_ci.outputs.affected_components).TOKENIZERS
150151

151152
CXX_Unit_Tests:

.github/workflows/mac.yml

+1
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ jobs:
258258
runner: 'macos-13'
259259
shell: bash
260260
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
261+
python-version: '3.11'
261262
if: fromJSON(needs.smart_ci.outputs.affected_components).TOKENIZERS
262263

263264
CXX_Unit_Tests:

.github/workflows/mac_arm64.yml

+1
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ jobs:
258258
runner: 'macos-13-xlarge'
259259
shell: bash
260260
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
261+
python-version: '3.11'
261262
if: fromJSON(needs.smart_ci.outputs.affected_components).TOKENIZERS
262263

263264
CXX_Unit_Tests:

.github/workflows/ubuntu_22.yml

+1
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ jobs:
491491
shell: bash
492492
container: '{"image": "${{ fromJSON(needs.docker.outputs.images).ov_build.ubuntu_22_04_x64 }}", "volumes": ["/mount:/mount"]}'
493493
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
494+
python-version: '3.11'
494495
if: fromJSON(needs.smart_ci.outputs.affected_components).TOKENIZERS
495496

496497
iGPU:

.github/workflows/ubuntu_24.yml

+23-1
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,31 @@ jobs:
144144
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
145145
python-version: '3.12'
146146

147+
TensorFlow_Layer_Tests:
148+
name: TensorFlow Layer Tests
149+
needs: [ Docker, Build, Smart_CI, Openvino_tokenizers ]
150+
uses: ./.github/workflows/job_tensorflow_layer_tests.yml
151+
with:
152+
runner: 'aks-linux-4-cores-16gb'
153+
container: '{"image": "${{ fromJSON(needs.docker.outputs.images).ov_test.ubuntu_24_04_x64 }}", "volumes": ["/mount:/mount"]}'
154+
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
155+
python-version: '3.12'
156+
157+
Openvino_tokenizers:
158+
name: OpenVINO tokenizers extension
159+
needs: [ Build, Smart_CI, Docker ]
160+
uses: ./.github/workflows/job_tokenizers.yml
161+
with:
162+
runner: 'aks-linux-4-cores-16gb'
163+
shell: bash
164+
container: '{"image": "${{ fromJSON(needs.docker.outputs.images).ov_build.ubuntu_24_04_x64 }}", "volumes": ["/mount:/mount"]}'
165+
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
166+
python-version: '3.12'
167+
if: fromJSON(needs.smart_ci.outputs.affected_components).TOKENIZERS
168+
147169
Overall_Status:
148170
name: ci/gha_overall_status_ubuntu_24
149-
needs: [Smart_CI, Build, Debian_Packages, Samples, Python_Unit_Tests]
171+
needs: [Smart_CI, Build, Debian_Packages, Samples, Python_Unit_Tests, Pytorch_Layer_Tests, TensorFlow_Layer_Tests, Openvino_tokenizers]
150172
if: ${{ always() }}
151173
runs-on: ubuntu-latest
152174
steps:

.github/workflows/windows_vs2019_release.yml

+1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ jobs:
235235
runner: 'aks-win-4-cores-8gb'
236236
shell: pwsh
237237
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
238+
python-version: '3.11'
238239
if: fromJSON(needs.smart_ci.outputs.affected_components).TOKENIZERS
239240

240241
Python_Unit_Tests:

src/frontends/jax/src/op/erfc.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (C) 2018-2024 Intel Corporation
2+
// SPDX-License-Identifier: Apache-2.0
3+
//
4+
5+
#include "openvino/frontend/jax/node_context.hpp"
6+
#include "openvino/op/erf.hpp"
7+
#include "openvino/op/subtract.hpp"
8+
#include "utils.hpp"
9+
10+
using namespace std;
11+
using namespace ov;
12+
using namespace ov::op;
13+
14+
namespace ov {
15+
namespace frontend {
16+
namespace jax {
17+
namespace op {
18+
19+
OutputVector translate_erfc(const NodeContext& context) {
20+
num_inputs_check(context, 1, 1);
21+
auto x = context.get_input(0);
22+
23+
// create const one of the same type as x
24+
auto const_one = create_same_type_const_scalar<int64_t>(x, 1);
25+
Output<Node> res = make_shared<v0::Erf>(x);
26+
res = make_shared<v1::Subtract>(const_one, res);
27+
return {res};
28+
};
29+
30+
} // namespace op
31+
} // namespace jax
32+
} // namespace frontend
33+
} // namespace ov

src/frontends/jax/src/op_table.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ OP_CONVERTER(translate_convert);
4545
OP_CONVERTER(translate_convolution);
4646
OP_CONVERTER(translate_copy);
4747
OP_CONVERTER(translate_dot_general);
48+
OP_CONVERTER(translate_erfc);
4849
OP_CONVERTER(translate_integer_pow);
4950
OP_T_CONVERTER(translate_reduce_op);
5051
OP_CONVERTER(translate_reduce_window_max);
@@ -72,6 +73,7 @@ const std::map<std::string, CreatorFunction> get_supported_ops_jaxpr() {
7273
{"dot_general", op::translate_dot_general},
7374
{"eq", op::translate_binary_op<v1::Equal>},
7475
{"erf", op::translate_1to1_match_1_input<v0::Erf>},
76+
{"erfc", op::translate_erfc},
7577
{"exp", op::translate_1to1_match_1_input<v0::Exp>},
7678
{"ge", op::translate_binary_op<v1::GreaterEqual>},
7779
{"gt", op::translate_binary_op<v1::Greater>},

tests/constraints.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ sympy>=1.10
1111
wheel>=0.38.1
1212
defusedxml>=0.7.1
1313
fastjsonschema~=2.17.1
14-
tensorflow>=2.5,<2.18.0
14+
tensorflow>=2.5,<2.19.0
1515
requests>=2.25.1
1616
opencv-python>=4.5
1717
paddlepaddle==2.6.1
@@ -21,11 +21,11 @@ pytest>=5.0,<8.4
2121
pytest-dependency==0.5.1
2222
pytest-html==4.1.1
2323
pytest-timeout==2.3.1
24-
jax<=0.4.33
25-
jaxlib<=0.4.33
24+
jax<=0.4.35
25+
jaxlib<=0.4.35
2626
kornia==0.7.0
2727
networkx<=3.3
28-
flax<=0.9.0
28+
flax<=0.10.0
2929

3030
--extra-index-url https://download.pytorch.org/whl/cpu
3131
torch~=2.4.1; platform_system != "Darwin" or platform_machine != "x86_64"
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright (C) 2018-2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
import jax
5+
import numpy as np
6+
import pytest
7+
from jax import numpy as jnp
8+
9+
from jax_layer_test_class import JaxLayerTest
10+
11+
rng = np.random.default_rng(109734)
12+
13+
14+
class TestErfc(JaxLayerTest):
15+
def _prepare_input(self):
16+
# erf are mostly changing in a range [-4, 4]
17+
x = rng.uniform(-4.0, 4.0, self.input_shape).astype(self.input_type)
18+
19+
x = jnp.array(x)
20+
return [x]
21+
22+
def create_model(self, input_shape, input_type):
23+
self.input_shape = input_shape
24+
self.input_type = input_type
25+
26+
def jax_erfc(x):
27+
return jax.lax.erfc(x)
28+
29+
return jax_erfc, None, 'erfc'
30+
31+
@pytest.mark.parametrize("input_shape", [[2], [3, 4]])
32+
@pytest.mark.parametrize("input_type", [np.float16, np.float32, np.float64])
33+
@pytest.mark.nightly
34+
@pytest.mark.precommit_jax_fe
35+
def test_erfc(self, ie_device, precision, ir_version, input_shape, input_type):
36+
self._test(*self.create_model(input_shape, input_type),
37+
ie_device, precision,
38+
ir_version)

tests/layer_tests/tensorflow_tests/test_tf_Equal.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ def test_tf_equal_int64(self, params, ie_device, precision, ir_version, temp_dir
146146

147147
# Values for checking important corner cases for float values
148148
# expect: false false false false false false true false true
149-
x_corner = [1., 1., 1., np.nan, np.nan, np.nan, np.inf, np.inf, np.NINF]
150-
y_corner = [np.nan, np.inf, np.NINF, np.nan, np.inf, np.NINF, np.inf, np.NINF, np.NINF]
149+
x_corner = [1., 1., 1., np.nan, np.nan, np.nan, np.inf, np.inf, -np.inf]
150+
y_corner = [np.nan, np.inf, -np.inf, np.nan, np.inf, -np.inf, np.inf, -np.inf, -np.inf]
151151

152152
test_data_float16 = [
153153
pytest.param(

tests/requirements_tensorflow

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
# tensorflow-intel inside tensorflow still requires numpy<2.0.0
2-
numpy==1.26.4
1+
# test ovc with NumPy 2.x on Ubuntu 24 with default Python 3.12
2+
# test against NumPy 1.x with older Python versions
3+
# tensorflow-intel 2.18.0 depends on numpy<2.1.0 and >=1.26.0
4+
numpy==1.26.4; python_version < "3.12"
5+
numpy==2.0.2; python_version >= "3.12"
36
pytest==7.0.1
47
pytest-xdist[psutil]==3.6.1
58
pytest-html==4.1.1
69
transformers==4.45.1
710
# install exact keras version since tensorflow depends and has no upper bound for it
811
keras==3.6.0
9-
tensorflow==2.17.0; platform_system != "Darwin" or platform_machine != "x86_64"
12+
tensorflow==2.18.0; python_version >= "3.12" and (platform_system != "Darwin" or platform_machine != "x86_64")
13+
tensorflow==2.17.0; python_version < "3.12" and (platform_system != "Darwin" or platform_machine != "x86_64")
1014
tensorflow==2.16.2; platform_system == "Darwin" and platform_machine == "x86_64"
15+
# install explicit version of wrapt to avoid "this __dict__ descriptor does not support '_DictWrapper' objects" error from TensorFlow 2.18
16+
wrapt==1.15.0; python_version >= "3.12"
1117
# tensorflow-text is not available for both Windows and ARM platforms
12-
tensorflow-text==2.17.0; platform_system == "Linux" and platform_machine == "x86_64"
18+
tensorflow-text==2.17.0; python_version < "3.12" and platform_system == "Linux" and platform_machine == "x86_64"
1319
tensorflow-hub==0.16.1
14-
jax==0.4.33
20+
jax==0.4.35
1521
defusedxml==0.7.1

tools/mo/requirements_tf.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-c ../constraints.txt
22
h5py
3-
tensorflow>=1.15.5,<2.18.0
3+
tensorflow>=1.15.5,<2.19.0
44
numpy>=1.16.6,<1.27
55
networkx
66
defusedxml

tools/mo/requirements_tf2.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-c ../constraints.txt
22
h5py
3-
tensorflow>=2.5,<2.18.0
3+
tensorflow>=2.5,<2.19.0
44
numpy>=1.16.6,<1.27
55
networkx
66
defusedxml

0 commit comments

Comments
 (0)