|
4 | 4 | import pytest
|
5 | 5 | from absl.testing import parameterized
|
6 | 6 |
|
| 7 | +from conftest import skip_if_backend |
7 | 8 | from keras.src import backend
|
8 | 9 | from keras.src import initializers
|
9 | 10 | from keras.src import ops
|
@@ -143,6 +144,9 @@ def test_variable_without_shape_from_callable_initializer(self):
|
143 | 144 | class VariablePropertiesTest(test_case.TestCase):
|
144 | 145 | """Tests for Variable._deferred_initialize Variable._maybe_autocast"""
|
145 | 146 |
|
| 147 | + @skip_if_backend( |
| 148 | + "openvino", "Can not constant fold eltwise node by CPU plugin" |
| 149 | + ) |
146 | 150 | def test_deferred_assignment(self):
|
147 | 151 | """Tests deferred assignment to variables."""
|
148 | 152 | with backend.StatelessScope() as scope:
|
@@ -246,6 +250,12 @@ def test_standardize_dtype(self, dtype):
|
246 | 250 | f"jax backend does not support {dtype} without x64 enabled"
|
247 | 251 | )
|
248 | 252 |
|
| 253 | + if backend.backend() == "openvino" and dtype in ( |
| 254 | + "complex64", |
| 255 | + "complex128", |
| 256 | + ): |
| 257 | + self.skipTest(f"openvino backend does not support dtype {dtype}") |
| 258 | + |
249 | 259 | x = backend.convert_to_tensor(np.zeros(()), dtype)
|
250 | 260 | actual = standardize_dtype(x.dtype)
|
251 | 261 | self.assertEqual(actual, dtype)
|
@@ -603,12 +613,18 @@ def test__rtruediv__(self):
|
603 | 613 | v2 = backend.Variable(initializer=np.array([1.0, 2.0, 3.0]))
|
604 | 614 | self.assertAllClose(v1.__rtruediv__(v2), np.array([0.25, 0.4, 0.5]))
|
605 | 615 |
|
| 616 | + @skip_if_backend( |
| 617 | + "openvino", "`floor_divide` is not supported with openvino backend" |
| 618 | + ) |
606 | 619 | def test__floordiv__(self):
|
607 | 620 | """Test floordiv operation on a variable."""
|
608 | 621 | v1 = backend.Variable(initializer=np.array([1.0, 2.0, 3.0]))
|
609 | 622 | v2 = backend.Variable(initializer=np.array([-4.0, 5.0, 6.0]))
|
610 | 623 | self.assertAllClose(v1.__floordiv__(v2), np.array([-1.0, 0.0, 0.0]))
|
611 | 624 |
|
| 625 | + @skip_if_backend( |
| 626 | + "openvino", "`floor_divide` is not supported with openvino backend" |
| 627 | + ) |
612 | 628 | def test__rfloordiv__(self):
|
613 | 629 | """Test reverse floordiv operation on a variable."""
|
614 | 630 | v1 = backend.Variable(initializer=np.array([-4.0, 5.0, 6.0]))
|
@@ -734,6 +750,9 @@ def test_variable_rpow(self):
|
734 | 750 | result = v2**v1
|
735 | 751 | self.assertAllClose(result, np.array([4.0, 25.0, 216.0]))
|
736 | 752 |
|
| 753 | + @skip_if_backend( |
| 754 | + "openvino", "`round` is not supported with openvino backend" |
| 755 | + ) |
737 | 756 | def test_round(self):
|
738 | 757 | v = backend.Variable(initializer=np.array([1.1, 2.2, 3.3]))
|
739 | 758 | self.assertAllClose(round(v), np.array([1.0, 2.0, 3.0]))
|
@@ -783,6 +802,9 @@ def test_invalid_float(self):
|
783 | 802 | INT_DTYPES = [
|
784 | 803 | x for x in INT_DTYPES if x not in ["uint16", "uint32", "uint64"]
|
785 | 804 | ]
|
| 805 | +elif backend.backend() == "openvino": |
| 806 | + # TODO: openvino doesn't support complex |
| 807 | + ALL_DTYPES = [x for x in ALL_DTYPES if x not in ["complex128", "complex64"]] |
786 | 808 | # Remove float8 dtypes for the following tests
|
787 | 809 | ALL_DTYPES = [x for x in ALL_DTYPES if x not in dtypes.FLOAT8_TYPES]
|
788 | 810 | NON_COMPLEX_DTYPES = [x for x in ALL_DTYPES if x and x not in COMPLEX_DTYPES]
|
@@ -976,6 +998,9 @@ def test_truediv(self, dtypes):
|
976 | 998 | @parameterized.named_parameters(
|
977 | 999 | named_product(dtypes=itertools.combinations(NON_COMPLEX_DTYPES, 2))
|
978 | 1000 | )
|
| 1001 | + @skip_if_backend( |
| 1002 | + "openvino", "`floor_divide` is not supported with openvino backend" |
| 1003 | + ) |
979 | 1004 | def test_floordiv(self, dtypes):
|
980 | 1005 | import jax.numpy as jnp
|
981 | 1006 |
|
|
0 commit comments