keras-nightly 3.14.0.dev2026020304__py3-none-any.whl → 3.14.0.dev2026020404__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -802,7 +802,78 @@ def count_nonzero(x, axis=None):
802
802
 
803
803
 
804
804
  def cross(x1, x2, axisa=-1, axisb=-1, axisc=-1, axis=None):
805
- raise NotImplementedError("`cross` is not supported with openvino backend")
805
+ if axis is not None:
806
+ axisa = axisb = axisc = axis
807
+
808
+ x1 = get_ov_output(x1)
809
+ x2 = get_ov_output(x2)
810
+
811
+ x1, x2 = _align_operand_types(x1, x2, "cross()")
812
+
813
+ shape1 = x1.get_partial_shape()
814
+ shape2 = x2.get_partial_shape()
815
+
816
+ # Rank Normalization
817
+ rank1 = shape1.rank.get_length()
818
+ rank2 = shape2.rank.get_length()
819
+
820
+ axisa = canonicalize_axis(axisa, rank1)
821
+ axisb = canonicalize_axis(axisb, rank2)
822
+ axisc = canonicalize_axis(axisc, rank1 if rank1 > rank2 else rank2)
823
+
824
+ d1 = shape1[axisa].get_length()
825
+ d2 = shape2[axisb].get_length()
826
+
827
+ if d1 not in (2, 3) or d2 not in (2, 3):
828
+ raise ValueError(
829
+ "Dimension of vectors for cross product must be 2 or 3. "
830
+ f"Got dimensions {d1} and {d2} for inputs x1 and x2."
831
+ )
832
+
833
+ # Pad to 3D by adding a zero component.
834
+ def pad_to_3d(x, dim, ax):
835
+ if dim == 3:
836
+ return x
837
+
838
+ # Create a slice of zeros with the same type as x
839
+ slice0 = ov_opset.gather(
840
+ x,
841
+ ov_opset.constant([0], Type.i32),
842
+ ov_opset.constant(ax, Type.i32),
843
+ )
844
+ zeros = ov_opset.multiply(
845
+ slice0,
846
+ ov_opset.constant(0, x.get_element_type()),
847
+ )
848
+
849
+ return ov_opset.concat([x, zeros], ax)
850
+
851
+ x1_3d = pad_to_3d(x1, d1, axisa)
852
+ x2_3d = pad_to_3d(x2, d2, axisb)
853
+
854
+ # Split Vectors
855
+ u = ov_opset.split(x1_3d, ov_opset.constant(axisa, Type.i32), 3).outputs()
856
+ v = ov_opset.split(x2_3d, ov_opset.constant(axisb, Type.i32), 3).outputs()
857
+
858
+ # u x v = (u2*v3 - u3*v2, u3*v1 - u1*v3, u1*v2 - u2*v1)
859
+ res_x = ov_opset.subtract(
860
+ ov_opset.multiply(u[1], v[2]), ov_opset.multiply(u[2], v[1])
861
+ )
862
+ res_y = ov_opset.subtract(
863
+ ov_opset.multiply(u[2], v[0]), ov_opset.multiply(u[0], v[2])
864
+ )
865
+ res_z = ov_opset.subtract(
866
+ ov_opset.multiply(u[0], v[1]), ov_opset.multiply(u[1], v[0])
867
+ )
868
+
869
+ # If dim was 2D, we remove the padded zero component.
870
+ if d1 == 2 and d2 == 2:
871
+ result = res_z
872
+ result = ov_opset.squeeze(result, ov_opset.constant([axisc], Type.i32))
873
+ else:
874
+ result = ov_opset.concat([res_x, res_y, res_z], axisc)
875
+
876
+ return OpenVINOKerasTensor(result.output(0))
806
877
 
807
878
 
808
879
  def cumprod(x, axis=None, dtype=None):
@@ -2,6 +2,7 @@ from keras.src.testing.test_case import TestCase
2
2
  from keras.src.testing.test_case import jax_uses_gpu
3
3
  from keras.src.testing.test_case import jax_uses_tpu
4
4
  from keras.src.testing.test_case import tensorflow_uses_gpu
5
+ from keras.src.testing.test_case import tensorflow_uses_tpu
5
6
  from keras.src.testing.test_case import torch_uses_gpu
6
7
  from keras.src.testing.test_case import uses_gpu
7
8
  from keras.src.testing.test_case import uses_tpu
@@ -8,7 +8,6 @@ import numpy as np
8
8
  from absl.testing import parameterized
9
9
 
10
10
  from keras.src import backend
11
- from keras.src import distribution
12
11
  from keras.src import ops
13
12
  from keras.src import tree
14
13
  from keras.src import utils
@@ -626,43 +625,68 @@ class TestCase(parameterized.TestCase, unittest.TestCase):
626
625
  self.assertEqual(dtype, "float32")
627
626
 
628
627
 
629
- def tensorflow_uses_gpu():
630
- return backend.backend() == "tensorflow" and uses_gpu()
628
+ def _jax_uses(device_type):
629
+ import jax
631
630
 
631
+ return jax.default_backend() == device_type
632
632
 
633
- def jax_uses_gpu():
634
- return backend.backend() == "jax" and uses_gpu()
635
633
 
634
+ def _tensorflow_uses(device_type):
635
+ import tensorflow as tf
636
636
 
637
- def torch_uses_gpu():
638
- if backend.backend() != "torch":
639
- return False
640
- from keras.src.backend.torch.core import get_device
637
+ return len(tf.config.list_physical_devices(device_type.upper())) > 0
638
+
639
+
640
+ def _torch_uses(device_type):
641
+ if device_type == "gpu":
642
+ from keras.src.backend.torch.core import get_device
641
643
 
642
- return get_device() == "cuda"
644
+ return get_device() == "cuda"
645
+ return device_type == "cpu"
643
646
 
644
647
 
645
648
  def uses_gpu():
646
- # Condition used to skip tests when using the GPU
647
- devices = distribution.list_devices()
648
- if any(d.startswith("gpu") for d in devices):
649
- return True
650
- return False
649
+ if not hasattr(uses_gpu, "_value"):
650
+ if backend.backend() == "tensorflow":
651
+ uses_gpu._value = _tensorflow_uses("gpu")
652
+ elif backend.backend() == "jax":
653
+ uses_gpu._value = _jax_uses("gpu")
654
+ elif backend.backend() == "torch":
655
+ uses_gpu._value = _torch_uses("gpu")
656
+ else:
657
+ uses_gpu._value = False
658
+ return uses_gpu._value
659
+
660
+
661
+ def uses_tpu():
662
+ if not hasattr(uses_tpu, "_value"):
663
+ if backend.backend() == "tensorflow":
664
+ uses_tpu._value = _tensorflow_uses("tpu")
665
+ elif backend.backend() == "jax":
666
+ uses_tpu._value = _jax_uses("tpu")
667
+ else:
668
+ uses_tpu._value = False
669
+ return uses_tpu._value
670
+
671
+
672
+ def jax_uses_gpu():
673
+ return backend.backend() == "jax" and uses_gpu()
651
674
 
652
675
 
653
676
  def jax_uses_tpu():
654
677
  return backend.backend() == "jax" and uses_tpu()
655
678
 
656
679
 
657
- def uses_tpu():
658
- # Condition used to skip tests when using the TPU
659
- try:
660
- devices = distribution.list_devices()
661
- if any(d.startswith("tpu") for d in devices):
662
- return True
663
- except AttributeError:
664
- return False
665
- return False
680
+ def tensorflow_uses_gpu():
681
+ return backend.backend() == "tensorflow" and uses_gpu()
682
+
683
+
684
+ def tensorflow_uses_tpu():
685
+ return backend.backend() == "tensorflow" and uses_tpu()
686
+
687
+
688
+ def torch_uses_gpu():
689
+ return backend.backend() == "torch" and uses_gpu()
666
690
 
667
691
 
668
692
  def create_keras_tensors(input_shape, dtype, sparse, ragged):
keras/src/version.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from keras.src.api_export import keras_export
2
2
 
3
3
  # Unique source of truth for the version number.
4
- __version__ = "3.14.0.dev2026020304"
4
+ __version__ = "3.14.0.dev2026020404"
5
5
 
6
6
 
7
7
  @keras_export("keras.version")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: keras-nightly
3
- Version: 3.14.0.dev2026020304
3
+ Version: 3.14.0.dev2026020404
4
4
  Summary: Multi-backend Keras
5
5
  Author-email: Keras team <keras-users@googlegroups.com>
6
6
  License: Apache License 2.0
@@ -128,7 +128,7 @@ keras/regularizers/__init__.py,sha256=542Shphw7W8h4Dyf2rmqMKUECVZ8IVBvN9g1LWhz-b
128
128
  keras/saving/__init__.py,sha256=KvL2GZxjvgFgEhvEnkvqjIR9JSNHKz-NWZacXajsjLI,1298
129
129
  keras/src/__init__.py,sha256=Gi4S7EiCMkE03PbdGNpFdaUYySWDs_FcAJ8Taz9Y1BE,684
130
130
  keras/src/api_export.py,sha256=gXOkBOnmscV013WAc75lc4Up01-Kkg9EylIAT_QWctg,1173
131
- keras/src/version.py,sha256=EgrYJtA7YKUOV4vpq9co7mADp2YlsvvhgZYUYS4YnbY,204
131
+ keras/src/version.py,sha256=FhnIBR0HLjhX-AjhyRTy_cn4TF4qatX-aS3GrHpvUok,204
132
132
  keras/src/activations/__init__.py,sha256=0nL3IFDB9unlrMz8ninKOWo-uCHasTUpTo1tXZb2u44,4433
133
133
  keras/src/activations/activations.py,sha256=mogPggtp4CGldI3VOPNmesRxp6EbiR1_i4KLGaVwzL8,17614
134
134
  keras/src/applications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -198,7 +198,7 @@ keras/src/backend/openvino/layer.py,sha256=5RdvaH1yOyPAphjKiuQAK1H_yZFYKE1Hp7c5b
198
198
  keras/src/backend/openvino/linalg.py,sha256=L6a4MFGND2wWzPVCh44cwuOgkcC4wJTo8Xy3HwW04lg,1614
199
199
  keras/src/backend/openvino/math.py,sha256=qw9kX2sJ2qr0dBJF12Ey0E2GcwixPUqoev6UcNra4NI,3944
200
200
  keras/src/backend/openvino/nn.py,sha256=zULPxdwVO7JDZUUtsuoEEPCLQ09ew8z8T6G_i_NEqrM,23741
201
- keras/src/backend/openvino/numpy.py,sha256=8FKiEmrGHEvhXhpE84j_ew87muFgcr9QMxNGNX5OUig,113533
201
+ keras/src/backend/openvino/numpy.py,sha256=vPmpxizrgQyShUTeAaVSI38ANX6z2uHYiAf9b-4n9e4,115691
202
202
  keras/src/backend/openvino/random.py,sha256=4hRUtIP6qJxO3Qy9uH1x6jSuJna3nWPdUf4x2QU8-ew,5575
203
203
  keras/src/backend/openvino/rnn.py,sha256=ErmuZLPSgG9qU-NfYPPvBZ6Ysy8k-fA4g19Vhqq7OVQ,866
204
204
  keras/src/backend/openvino/trainer.py,sha256=bMmtSALqydqdS6ke-5sYW5fgxZDshDH810p_C0xCRTg,9087
@@ -550,8 +550,8 @@ keras/src/saving/orbax_util.py,sha256=ArJI9hQODUyyvzCiXt8AS3VH6E4SL0vF02-RHBk30g
550
550
  keras/src/saving/saving_api.py,sha256=X-zsTum57M3AWf_cYqhq_o5wgLcFxNh1ditoxbL_0LY,14694
551
551
  keras/src/saving/saving_lib.py,sha256=bRI8TeNOlflTfX3njSkkwNv-VYip-OW7ienIm0lL96I,58920
552
552
  keras/src/saving/serialization_lib.py,sha256=yzCTm8hin__MGA2N5M5F-8Zbts5ZJVmINbrH4wEtIwI,30334
553
- keras/src/testing/__init__.py,sha256=RQ5ZZ88NhcDTHCIpPulvaiTOTdJqAMH9ZhptXyMcqqY,368
554
- keras/src/testing/test_case.py,sha256=24aSbz5WG5ICUavaLWo-PWBD_O9T7feRGvrLoNS19Q8,31780
553
+ keras/src/testing/__init__.py,sha256=29k8fvygLsF33eSTUowVIEEQLRB3AzTQRvYotEOe3U8,428
554
+ keras/src/testing/test_case.py,sha256=FrQiXRvtarSv7G9g1PK8GJYJeMsKVg0GMzsLFivMopI,32432
555
555
  keras/src/testing/test_utils.py,sha256=6Vb8tJIyjU1ay63w3jvXNNhh7sSNrosQll4ii1NXELQ,6197
556
556
  keras/src/trainers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
557
557
  keras/src/trainers/compile_utils.py,sha256=k5FDn7we0RN9fhRslY_WOQZRFwfzjqpYmiDeOKkAKqk,31260
@@ -618,7 +618,7 @@ keras/utils/bounding_boxes/__init__.py,sha256=jtvQll4u8ZY0Z96HwNhP1nxWEG9FM3gI-6
618
618
  keras/utils/legacy/__init__.py,sha256=oSYZz6uS8UxSElRaaJYWJEoweJ4GAasZjnn7fNaOlog,342
619
619
  keras/visualization/__init__.py,sha256=UKWmiy6sps4SWlmQi9WX8_Z53cPpLlphz2zIeHdwJpQ,722
620
620
  keras/wrappers/__init__.py,sha256=QkS-O5K8qGS7C3sytF8MpmO6PasATpNVGF8qtb7Ojsw,407
621
- keras_nightly-3.14.0.dev2026020304.dist-info/METADATA,sha256=hy2sly87dVSoOiutBAyDJXlZX_b0UIWgCmSfphO4lwU,6339
622
- keras_nightly-3.14.0.dev2026020304.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
623
- keras_nightly-3.14.0.dev2026020304.dist-info/top_level.txt,sha256=ptcw_-QuGZ4ZDjMdwi_Z0clZm8QAqFdvzzFnDEOTs9o,6
624
- keras_nightly-3.14.0.dev2026020304.dist-info/RECORD,,
621
+ keras_nightly-3.14.0.dev2026020404.dist-info/METADATA,sha256=0_dkofG5lLCYTwNn1VT_Inp2boYDQMIjPvIW5QwXM9I,6339
622
+ keras_nightly-3.14.0.dev2026020404.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
623
+ keras_nightly-3.14.0.dev2026020404.dist-info/top_level.txt,sha256=ptcw_-QuGZ4ZDjMdwi_Z0clZm8QAqFdvzzFnDEOTs9o,6
624
+ keras_nightly-3.14.0.dev2026020404.dist-info/RECORD,,