Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TF FE][JAX FE] Support latest TF 2.18, JAX 0.4.35 and NumPy 2.x #27246

Merged
merged 19 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/frontends/jax/src/op/erfc.cpp
Original file line number Diff line number Diff line change
@@ -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 y const of the same type as x
rkazants marked this conversation as resolved.
Show resolved Hide resolved
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 ov
2 changes: 2 additions & 0 deletions src/frontends/jax/src/op_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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>},
Expand Down
8 changes: 4 additions & 4 deletions tests/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ sympy>=1.10
wheel>=0.38.1
defusedxml>=0.7.1
fastjsonschema~=2.17.1
tensorflow>=2.5,<2.18.0
tensorflow>=2.5,<2.19.0
requests>=2.25.1
opencv-python>=4.5
paddlepaddle==2.6.1
Expand All @@ -21,11 +21,11 @@ pytest>=5.0,<8.4
pytest-dependency==0.5.1
pytest-html==4.1.1
pytest-timeout==2.3.1
jax<=0.4.33
jaxlib<=0.4.33
jax<=0.4.35
jaxlib<=0.4.35
kornia==0.7.0
networkx<=3.3
flax<=0.9.0
flax<=0.10.0

--extra-index-url https://download.pytorch.org/whl/cpu
torch~=2.4.1; platform_system != "Darwin" or platform_machine != "x86_64"
Expand Down
39 changes: 39 additions & 0 deletions tests/layer_tests/jax_tests/test_erfc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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
rkazants marked this conversation as resolved.
Show resolved Hide resolved
@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)
6 changes: 3 additions & 3 deletions tests/requirements_tensorflow
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ pytest-html==4.1.1
transformers==4.45.1
# install exact keras version since tensorflow depends and has no upper bound for it
keras==3.6.0
tensorflow==2.17.0; platform_system != "Darwin" or platform_machine != "x86_64"
tensorflow==2.18.0; platform_system != "Darwin" or platform_machine != "x86_64"
tensorflow==2.16.2; platform_system == "Darwin" and platform_machine == "x86_64"
# 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.18.0rc0; platform_system == "Linux" and platform_machine == "x86_64"
tensorflow-hub==0.16.1
jax==0.4.33
jax==0.4.35
defusedxml==0.7.1
2 changes: 1 addition & 1 deletion tools/mo/requirements_tf.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-c ../constraints.txt
h5py
tensorflow>=1.15.5,<2.18.0
tensorflow>=1.15.5,<2.19.0
numpy>=1.16.6,<1.27
networkx
defusedxml
Expand Down
2 changes: 1 addition & 1 deletion tools/mo/requirements_tf2.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-c ../constraints.txt
h5py
tensorflow>=2.5,<2.18.0
tensorflow>=2.5,<2.19.0
numpy>=1.16.6,<1.27
networkx
defusedxml
Expand Down
Loading