keras-nightly 3.12.0.dev2025082903__py3-none-any.whl → 3.12.0.dev2025083003__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.
- keras/_tf_keras/keras/ops/__init__.py +1 -0
- keras/_tf_keras/keras/ops/numpy/__init__.py +1 -0
- keras/ops/__init__.py +1 -0
- keras/ops/numpy/__init__.py +1 -0
- keras/src/backend/jax/numpy.py +6 -0
- keras/src/backend/numpy/numpy.py +8 -0
- keras/src/backend/openvino/numpy.py +45 -3
- keras/src/backend/tensorflow/numpy.py +37 -0
- keras/src/backend/torch/numpy.py +6 -0
- keras/src/dtype_policies/dtype_policy_map.py +109 -27
- keras/src/layers/preprocessing/integer_lookup.py +6 -3
- keras/src/layers/preprocessing/string_lookup.py +39 -10
- keras/src/ops/numpy.py +31 -0
- keras/src/version.py +1 -1
- {keras_nightly-3.12.0.dev2025082903.dist-info → keras_nightly-3.12.0.dev2025083003.dist-info}/METADATA +1 -1
- {keras_nightly-3.12.0.dev2025082903.dist-info → keras_nightly-3.12.0.dev2025083003.dist-info}/RECORD +18 -18
- {keras_nightly-3.12.0.dev2025082903.dist-info → keras_nightly-3.12.0.dev2025083003.dist-info}/WHEEL +0 -0
- {keras_nightly-3.12.0.dev2025082903.dist-info → keras_nightly-3.12.0.dev2025083003.dist-info}/top_level.txt +0 -0
@@ -187,6 +187,7 @@ from keras.src.ops.numpy import floor as floor
|
|
187
187
|
from keras.src.ops.numpy import floor_divide as floor_divide
|
188
188
|
from keras.src.ops.numpy import full as full
|
189
189
|
from keras.src.ops.numpy import full_like as full_like
|
190
|
+
from keras.src.ops.numpy import gcd as gcd
|
190
191
|
from keras.src.ops.numpy import get_item as get_item
|
191
192
|
from keras.src.ops.numpy import greater as greater
|
192
193
|
from keras.src.ops.numpy import greater_equal as greater_equal
|
@@ -75,6 +75,7 @@ from keras.src.ops.numpy import floor as floor
|
|
75
75
|
from keras.src.ops.numpy import floor_divide as floor_divide
|
76
76
|
from keras.src.ops.numpy import full as full
|
77
77
|
from keras.src.ops.numpy import full_like as full_like
|
78
|
+
from keras.src.ops.numpy import gcd as gcd
|
78
79
|
from keras.src.ops.numpy import get_item as get_item
|
79
80
|
from keras.src.ops.numpy import greater as greater
|
80
81
|
from keras.src.ops.numpy import greater_equal as greater_equal
|
keras/ops/__init__.py
CHANGED
@@ -187,6 +187,7 @@ from keras.src.ops.numpy import floor as floor
|
|
187
187
|
from keras.src.ops.numpy import floor_divide as floor_divide
|
188
188
|
from keras.src.ops.numpy import full as full
|
189
189
|
from keras.src.ops.numpy import full_like as full_like
|
190
|
+
from keras.src.ops.numpy import gcd as gcd
|
190
191
|
from keras.src.ops.numpy import get_item as get_item
|
191
192
|
from keras.src.ops.numpy import greater as greater
|
192
193
|
from keras.src.ops.numpy import greater_equal as greater_equal
|
keras/ops/numpy/__init__.py
CHANGED
@@ -75,6 +75,7 @@ from keras.src.ops.numpy import floor as floor
|
|
75
75
|
from keras.src.ops.numpy import floor_divide as floor_divide
|
76
76
|
from keras.src.ops.numpy import full as full
|
77
77
|
from keras.src.ops.numpy import full_like as full_like
|
78
|
+
from keras.src.ops.numpy import gcd as gcd
|
78
79
|
from keras.src.ops.numpy import get_item as get_item
|
79
80
|
from keras.src.ops.numpy import greater as greater
|
80
81
|
from keras.src.ops.numpy import greater_equal as greater_equal
|
keras/src/backend/jax/numpy.py
CHANGED
@@ -736,6 +736,12 @@ def full_like(x, fill_value, dtype=None):
|
|
736
736
|
return jnp.full_like(x, fill_value, dtype=dtype)
|
737
737
|
|
738
738
|
|
739
|
+
def gcd(x1, x2):
|
740
|
+
x1 = convert_to_tensor(x1)
|
741
|
+
x2 = convert_to_tensor(x2)
|
742
|
+
return jnp.gcd(x1, x2)
|
743
|
+
|
744
|
+
|
739
745
|
def greater(x1, x2):
|
740
746
|
x1 = convert_to_tensor(x1)
|
741
747
|
x2 = convert_to_tensor(x2)
|
keras/src/backend/numpy/numpy.py
CHANGED
@@ -662,6 +662,14 @@ def full_like(x, fill_value, dtype=None):
|
|
662
662
|
return np.full_like(x, fill_value, dtype=dtype)
|
663
663
|
|
664
664
|
|
665
|
+
def gcd(x1, x2):
|
666
|
+
x1 = convert_to_tensor(x1)
|
667
|
+
x2 = convert_to_tensor(x2)
|
668
|
+
|
669
|
+
dtype = dtypes.result_type(x1.dtype, x2.dtype)
|
670
|
+
return np.gcd(x1, x2).astype(dtype)
|
671
|
+
|
672
|
+
|
665
673
|
def greater(x1, x2):
|
666
674
|
return np.greater(x1, x2)
|
667
675
|
|
@@ -863,6 +863,10 @@ def full_like(x, fill_value, dtype=None):
|
|
863
863
|
return OpenVINOKerasTensor(res)
|
864
864
|
|
865
865
|
|
866
|
+
def gcd(x1, x2):
|
867
|
+
raise NotImplementedError("`gcd` is not supported with openvino backend")
|
868
|
+
|
869
|
+
|
866
870
|
def greater(x1, x2):
|
867
871
|
element_type = None
|
868
872
|
if isinstance(x1, OpenVINOKerasTensor):
|
@@ -1101,9 +1105,47 @@ def median(x, axis=None, keepdims=False):
|
|
1101
1105
|
|
1102
1106
|
|
1103
1107
|
def meshgrid(*x, indexing="xy"):
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1108
|
+
if len(x) < 2:
|
1109
|
+
raise ValueError(
|
1110
|
+
"meshgrid requires at least 2 input arrays. "
|
1111
|
+
f"Received: {len(x)} input array(s)."
|
1112
|
+
)
|
1113
|
+
if indexing not in ("xy", "ij"):
|
1114
|
+
raise ValueError("indexing must be either 'xy' or 'ij'")
|
1115
|
+
|
1116
|
+
tensors = [get_ov_output(xi) for xi in x]
|
1117
|
+
n = len(tensors)
|
1118
|
+
|
1119
|
+
shapes = [
|
1120
|
+
ov_opset.shape_of(t, Type.i64).output(0) for t in tensors
|
1121
|
+
] # each is [Ni]
|
1122
|
+
one = ov_opset.constant([1], Type.i64).output(0)
|
1123
|
+
|
1124
|
+
if indexing == "xy":
|
1125
|
+
shape_list = [shapes[1], shapes[0]] + shapes[2:]
|
1126
|
+
out_shape = ov_opset.concat(shape_list, axis=0).output(0)
|
1127
|
+
else:
|
1128
|
+
out_shape = ov_opset.concat(shapes, axis=0).output(0)
|
1129
|
+
|
1130
|
+
outputs = []
|
1131
|
+
for i, t in enumerate(tensors):
|
1132
|
+
reshape_parts = [one] * n
|
1133
|
+
if indexing == "xy":
|
1134
|
+
if i == 0:
|
1135
|
+
reshape_parts[1] = shapes[0]
|
1136
|
+
elif i == 1:
|
1137
|
+
reshape_parts[0] = shapes[1]
|
1138
|
+
else:
|
1139
|
+
reshape_parts[i] = shapes[i]
|
1140
|
+
else:
|
1141
|
+
reshape_parts[i] = shapes[i]
|
1142
|
+
|
1143
|
+
reshape_shape = ov_opset.concat(reshape_parts, axis=0).output(0)
|
1144
|
+
reshaped = ov_opset.reshape(t, reshape_shape, False).output(0)
|
1145
|
+
broadcasted = ov_opset.broadcast(reshaped, out_shape).output(0)
|
1146
|
+
outputs.append(OpenVINOKerasTensor(broadcasted))
|
1147
|
+
|
1148
|
+
return outputs
|
1107
1149
|
|
1108
1150
|
|
1109
1151
|
def min(x, axis=None, keepdims=False, initial=None):
|
@@ -1531,6 +1531,43 @@ def full_like(x, fill_value, dtype=None):
|
|
1531
1531
|
return tf.broadcast_to(fill_value, tf.shape(x))
|
1532
1532
|
|
1533
1533
|
|
1534
|
+
def gcd(x1, x2):
|
1535
|
+
x1 = tf.convert_to_tensor(x1)
|
1536
|
+
x2 = tf.convert_to_tensor(x2)
|
1537
|
+
|
1538
|
+
dtype = dtypes.result_type(x1.dtype, x2.dtype)
|
1539
|
+
x1 = tf.cast(x1, dtype)
|
1540
|
+
x2 = tf.cast(x2, dtype)
|
1541
|
+
|
1542
|
+
if not x1.dtype.is_integer:
|
1543
|
+
raise TypeError("Arguments to gcd must be integers.")
|
1544
|
+
|
1545
|
+
target_shape = tf.broadcast_static_shape(x1.shape, x2.shape)
|
1546
|
+
x1 = tf.broadcast_to(x1, target_shape)
|
1547
|
+
x2 = tf.broadcast_to(x2, target_shape)
|
1548
|
+
|
1549
|
+
def cond(a, b):
|
1550
|
+
return tf.reduce_any(b != 0)
|
1551
|
+
|
1552
|
+
def body(a, b):
|
1553
|
+
b_safe = tf.where(tf.equal(b, 0), tf.ones_like(b), b)
|
1554
|
+
return (
|
1555
|
+
tf.where(tf.not_equal(b, 0), b, a),
|
1556
|
+
tf.where(
|
1557
|
+
tf.not_equal(b, 0),
|
1558
|
+
tf.math.floormod(a, b_safe),
|
1559
|
+
tf.zeros_like(b),
|
1560
|
+
),
|
1561
|
+
)
|
1562
|
+
|
1563
|
+
if dtype not in [tf.uint8, tf.uint16, tf.uint32, tf.uint64]:
|
1564
|
+
x1 = tf.abs(x1)
|
1565
|
+
x2 = tf.abs(x2)
|
1566
|
+
|
1567
|
+
gcd_val, _ = tf.while_loop(cond, body, [x1, x2])
|
1568
|
+
return gcd_val
|
1569
|
+
|
1570
|
+
|
1534
1571
|
def greater(x1, x2):
|
1535
1572
|
x1 = convert_to_tensor(x1)
|
1536
1573
|
x2 = convert_to_tensor(x2)
|
keras/src/backend/torch/numpy.py
CHANGED
@@ -839,6 +839,12 @@ def full_like(x, fill_value, dtype=None):
|
|
839
839
|
return full(shape=x.shape, fill_value=fill_value, dtype=dtype)
|
840
840
|
|
841
841
|
|
842
|
+
def gcd(x1, x2):
|
843
|
+
x1 = convert_to_tensor(x1)
|
844
|
+
x2 = convert_to_tensor(x2)
|
845
|
+
return torch.gcd(x1, x2)
|
846
|
+
|
847
|
+
|
842
848
|
def greater(x1, x2):
|
843
849
|
x1, x2 = convert_to_tensor(x1), convert_to_tensor(x2)
|
844
850
|
return torch.greater(x1, x2)
|
@@ -35,29 +35,54 @@ class DTypePolicyMap(DTypePolicy, MutableMapping):
|
|
35
35
|
However, it is also possible to set a regex as the key. See the docstring of
|
36
36
|
`get` for more details.
|
37
37
|
|
38
|
-
See below for a usage example. You can define the naming schema
|
39
|
-
of the `DTypePolicy`, and then retrieve the corresponding `DTypePolicy`
|
40
|
-
instance.
|
41
|
-
|
42
|
-
```python
|
43
|
-
dtype_policy_map = DTypePolicyMap()
|
44
|
-
dtype_policy_map["layer/dense_0"] = DTypePolicy("bfloat16")
|
45
|
-
dtype_policy_map["layer/dense_1"] = QuantizedDTypePolicy("int8", "bfloat16")
|
46
|
-
|
47
|
-
policy_0 = dtype_policy_map["layer/dense_0"]
|
48
|
-
policy_1 = dtype_policy_map["layer/dense_1"]
|
49
|
-
policy_2 = dtype_policy_map["layer/dense_2"] # No hit
|
50
|
-
assert policy_0 == DTypePolicy("bfloat16")
|
51
|
-
assert policy_1 == QuantizedDTypePolicy("int8", "bfloat16")
|
52
|
-
assert policy_2 == keras.config.dtype_policy()
|
53
|
-
```
|
54
|
-
|
55
38
|
Args:
|
56
39
|
default_policy: An optional `DTypePolicy` instance specifying the
|
57
40
|
default dtype policy. If not specified, the value will default to
|
58
41
|
`keras.config.dtype_policy()`.
|
59
42
|
policy_map: An optional dict that maps string to `DTypePolicy`
|
60
43
|
instances. Defaults to `None`
|
44
|
+
|
45
|
+
Example:
|
46
|
+
|
47
|
+
```python
|
48
|
+
>>> from keras.src import dtype_policies
|
49
|
+
>>> bfloat16 = dtype_policies.DTypePolicy("bfloat16")
|
50
|
+
>>> float16 = dtype_policies.DTypePolicy("float16")
|
51
|
+
>>> float32 = dtype_policies.DTypePolicy("float32")
|
52
|
+
>>> policy_map = DTypePolicyMap(default_policy=float32)
|
53
|
+
|
54
|
+
# Set policies using an exact path and a regex pattern.
|
55
|
+
# Note: "decoder" will only match the exact path, not its children.
|
56
|
+
>>> policy_map["encoder/layer_0/dense"] = bfloat16
|
57
|
+
>>> policy_map["encoder/.*"] = float16
|
58
|
+
>>> policy_map["decoder"] = bfloat16
|
59
|
+
|
60
|
+
# 1. An exact match is found and returned directly.
|
61
|
+
>>> policy_map["encoder/layer_0/dense"].name
|
62
|
+
'bfloat16'
|
63
|
+
|
64
|
+
# 2. A regex match is found for a child layer.
|
65
|
+
# It matches the "encoder/.*" pattern.
|
66
|
+
>>> policy_map["encoder/attention/query"].name
|
67
|
+
'float16'
|
68
|
+
|
69
|
+
# 3. No implicit prefix matching occurs.
|
70
|
+
# "decoder/attention" does not match the key "decoder".
|
71
|
+
# The default policy is returned.
|
72
|
+
>>> policy_map["decoder/attention"].name
|
73
|
+
'float32'
|
74
|
+
|
75
|
+
# 4. A ValueError is raised if a path matches multiple patterns.
|
76
|
+
>>> policy_map["encoder/attention/.*"] = bfloat16
|
77
|
+
# "encoder/attention/query" now matches two patterns:
|
78
|
+
# - "encoder/.*"
|
79
|
+
# - "encoder/attention/.*"
|
80
|
+
>>> try:
|
81
|
+
... policy_map["encoder/attention/query"]
|
82
|
+
... except ValueError as e:
|
83
|
+
... print(e)
|
84
|
+
Path 'encoder/attention/query' matches multiple dtype policy ..
|
85
|
+
```
|
61
86
|
"""
|
62
87
|
|
63
88
|
def __init__(self, default_policy=None, policy_map=None):
|
@@ -100,24 +125,79 @@ class DTypePolicyMap(DTypePolicy, MutableMapping):
|
|
100
125
|
def __getitem__(self, key):
|
101
126
|
"""Retrieves the corresponding `DTypePolicy` by the string key.
|
102
127
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
128
|
+
This method first attempts an exact key match. If no exact match is
|
129
|
+
found, it treats all keys in the map as regular expression patterns
|
130
|
+
and uses `re.fullmatch` to find a policy.
|
131
|
+
|
132
|
+
For example, to apply a policy to all sublayers of an `encoder` block,
|
133
|
+
the key should be explicitly set to `"encoder/.*"`. A key of
|
134
|
+
`"encoder"` will only match the layer with that exact path.
|
107
135
|
|
108
136
|
Args:
|
109
|
-
key:
|
137
|
+
key: str. The key to query for a `DTypePolicy`.
|
110
138
|
|
111
139
|
Returns:
|
112
|
-
|
140
|
+
The corresponding `DTypePolicy`. If no match is found, this method
|
141
|
+
returns `self.default_policy`.
|
142
|
+
|
143
|
+
Raises:
|
144
|
+
ValueError: If the `key` matches more than one regex pattern in the
|
145
|
+
map.
|
146
|
+
|
147
|
+
Example:
|
148
|
+
|
149
|
+
```python
|
150
|
+
>>> from keras.src import dtype_policies
|
151
|
+
>>> bfloat16 = dtype_policies.DTypePolicy("bfloat16")
|
152
|
+
>>> float16 = dtype_policies.DTypePolicy("float16")
|
153
|
+
>>> float32 = dtype_policies.DTypePolicy("float32")
|
154
|
+
>>> policy_map = DTypePolicyMap(default_policy=float32)
|
155
|
+
|
156
|
+
# Set policies using an exact path and a regex pattern.
|
157
|
+
# Note: "decoder" will only match the exact path, not its children.
|
158
|
+
>>> policy_map["encoder/layer_0/dense"] = bfloat16
|
159
|
+
>>> policy_map["encoder/.*"] = float16
|
160
|
+
>>> policy_map["decoder"] = bfloat16
|
161
|
+
|
162
|
+
# 1. An exact match is found and returned directly.
|
163
|
+
>>> policy_map["encoder/layer_0/dense"].name
|
164
|
+
'bfloat16'
|
165
|
+
|
166
|
+
# 2. A regex match is found for a child layer.
|
167
|
+
# It matches the "encoder/.*" pattern.
|
168
|
+
>>> policy_map["encoder/attention/query"].name
|
169
|
+
'float16'
|
170
|
+
|
171
|
+
# 3. No implicit prefix matching occurs.
|
172
|
+
# "decoder/attention" does not match the key "decoder".
|
173
|
+
# The default policy is returned.
|
174
|
+
>>> policy_map["decoder/attention"].name
|
175
|
+
'float32'
|
176
|
+
|
177
|
+
# 4. A ValueError is raised if a path matches multiple patterns.
|
178
|
+
>>> policy_map["encoder/attention/.*"] = bfloat16
|
179
|
+
# "encoder/attention/query" now matches two patterns:
|
180
|
+
# - "encoder/.*"
|
181
|
+
# - "encoder/attention/.*"
|
182
|
+
>>> try:
|
183
|
+
... policy_map["encoder/attention/query"]
|
184
|
+
... except ValueError as e:
|
185
|
+
... print(e)
|
186
|
+
Path 'encoder/attention/query' matches multiple dtype policy ..
|
187
|
+
```
|
113
188
|
"""
|
189
|
+
# 1. Check for an exact match.
|
114
190
|
if key in self._policy_map:
|
115
191
|
return self._policy_map[key]
|
116
192
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
193
|
+
# 2. Fallback to a full regex match.
|
194
|
+
matching_keys = [
|
195
|
+
pattern
|
196
|
+
for pattern in self._policy_map
|
197
|
+
if re.fullmatch(pattern, key)
|
198
|
+
]
|
199
|
+
|
200
|
+
# 3. Handle cases based on the number of matches found.
|
121
201
|
if len(matching_keys) > 1:
|
122
202
|
raise ValueError(
|
123
203
|
f"Path '{key}' matches multiple dtype policy "
|
@@ -127,6 +207,8 @@ class DTypePolicyMap(DTypePolicy, MutableMapping):
|
|
127
207
|
)
|
128
208
|
elif len(matching_keys) == 1:
|
129
209
|
return self._policy_map[matching_keys[0]]
|
210
|
+
|
211
|
+
# 4. If there were no matches, return the default.
|
130
212
|
return self.default_policy
|
131
213
|
|
132
214
|
def __setitem__(self, key, policy):
|
@@ -111,9 +111,12 @@ class IntegerLookup(IndexLookup):
|
|
111
111
|
appeared in the sample.
|
112
112
|
- `"tf_idf"`: As `"multi_hot"`, but the TF-IDF algorithm is
|
113
113
|
applied to find the value in each token slot.
|
114
|
-
For `"int"` output,
|
115
|
-
For
|
116
|
-
|
114
|
+
For `"int"` output, the output shape matches the input shape.
|
115
|
+
For `"one_hot"` output, the output shape is
|
116
|
+
`input_shape + (vocabulary_size,)`, where `input_shape` may
|
117
|
+
have arbitrary rank. For other output modes (`"multi_hot"`,
|
118
|
+
`"count"`, `"tf_idf"`), the output shape is `(batch_size,
|
119
|
+
vocabulary_size)`. Defaults to `"int"`.
|
117
120
|
pad_to_max_tokens: Only applicable when `output_mode` is `"multi_hot"`,
|
118
121
|
`"count"`, or `"tf_idf"`. If `True`, the output will have
|
119
122
|
its feature axis padded to `max_tokens` even if the number
|
@@ -6,6 +6,9 @@ from keras.src.layers.preprocessing.index_lookup import IndexLookup
|
|
6
6
|
from keras.src.utils import backend_utils
|
7
7
|
from keras.src.utils.module_utils import tensorflow as tf
|
8
8
|
|
9
|
+
if backend.backend() == "torch":
|
10
|
+
import torch
|
11
|
+
|
9
12
|
|
10
13
|
@keras_export("keras.layers.StringLookup")
|
11
14
|
class StringLookup(IndexLookup):
|
@@ -382,13 +385,39 @@ class StringLookup(IndexLookup):
|
|
382
385
|
return {**base_config, **config}
|
383
386
|
|
384
387
|
def call(self, inputs):
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
388
|
+
is_torch_backend = backend.backend() == "torch"
|
389
|
+
|
390
|
+
# Handle input conversion
|
391
|
+
inputs_for_processing = inputs
|
392
|
+
was_tf_input = isinstance(
|
393
|
+
inputs, (tf.Tensor, tf.RaggedTensor, tf.SparseTensor)
|
394
|
+
)
|
395
|
+
|
396
|
+
if is_torch_backend and isinstance(inputs, torch.Tensor):
|
397
|
+
inputs_for_processing = tf.convert_to_tensor(
|
398
|
+
inputs.detach().cpu().numpy()
|
399
|
+
)
|
400
|
+
elif isinstance(inputs, (np.ndarray, list, tuple)):
|
401
|
+
inputs_for_processing = tf.convert_to_tensor(inputs)
|
402
|
+
elif not was_tf_input:
|
403
|
+
inputs_for_processing = tf.convert_to_tensor(
|
404
|
+
backend.convert_to_numpy(inputs)
|
405
|
+
)
|
406
|
+
|
407
|
+
output = super().call(inputs_for_processing)
|
408
|
+
|
409
|
+
# Handle torch backend output conversion
|
410
|
+
if is_torch_backend and isinstance(
|
411
|
+
inputs, (torch.Tensor, np.ndarray, list, tuple)
|
412
|
+
):
|
413
|
+
numpy_outputs = output.numpy()
|
414
|
+
if self.invert:
|
415
|
+
return [n.decode(self.encoding) for n in numpy_outputs]
|
416
|
+
else:
|
417
|
+
return torch.from_numpy(numpy_outputs)
|
418
|
+
|
419
|
+
# other backends
|
420
|
+
if not was_tf_input:
|
421
|
+
output = backend_utils.convert_tf_tensor(output)
|
422
|
+
|
423
|
+
return output
|
keras/src/ops/numpy.py
CHANGED
@@ -3329,6 +3329,37 @@ def full_like(x, fill_value, dtype=None):
|
|
3329
3329
|
return backend.numpy.full_like(x, fill_value, dtype=dtype)
|
3330
3330
|
|
3331
3331
|
|
3332
|
+
class Gcd(Operation):
|
3333
|
+
def call(self, x1, x2):
|
3334
|
+
return backend.numpy.gcd(x1, x2)
|
3335
|
+
|
3336
|
+
def compute_output_spec(self, x1, x2):
|
3337
|
+
x1_shape = getattr(x1, "shape", [])
|
3338
|
+
x2_shape = getattr(x2, "shape", [])
|
3339
|
+
output_shape = broadcast_shapes(x1_shape, x2_shape)
|
3340
|
+
|
3341
|
+
x1_type = backend.standardize_dtype(getattr(x1, "dtype", type(x1)))
|
3342
|
+
x2_type = backend.standardize_dtype(getattr(x2, "dtype", type(x2)))
|
3343
|
+
dtype = dtypes.result_type(x1_type, x2_type)
|
3344
|
+
return KerasTensor(output_shape, dtype=dtype)
|
3345
|
+
|
3346
|
+
|
3347
|
+
@keras_export(["keras.ops.gcd", "keras.ops.numpy.gcd"])
|
3348
|
+
def gcd(x1, x2):
|
3349
|
+
"""Greatest common divisor of `x1` and `x2`, element-wise.
|
3350
|
+
|
3351
|
+
Args:
|
3352
|
+
x1: First input tensor (integer type).
|
3353
|
+
x2: Second input tensor (integer type).
|
3354
|
+
|
3355
|
+
Returns:
|
3356
|
+
Output tensor, element-wise greatest common divisor of `x1` and `x2`.
|
3357
|
+
"""
|
3358
|
+
if any_symbolic_tensors((x1, x2)):
|
3359
|
+
return Gcd().symbolic_call(x1, x2)
|
3360
|
+
return backend.numpy.gcd(x1, x2)
|
3361
|
+
|
3362
|
+
|
3332
3363
|
class GetItem(Operation):
|
3333
3364
|
def call(self, x, key):
|
3334
3365
|
if isinstance(key, list):
|
keras/src/version.py
CHANGED
{keras_nightly-3.12.0.dev2025082903.dist-info → keras_nightly-3.12.0.dev2025083003.dist-info}/RECORD
RENAMED
@@ -44,11 +44,11 @@ keras/_tf_keras/keras/losses/__init__.py,sha256=xBc_KOtSLwp3h3CKQ0EnCuIy-Bsak2SP
|
|
44
44
|
keras/_tf_keras/keras/metrics/__init__.py,sha256=_wF31PTvua5ahF9JEW4Hx1UVNjVCLqVI8J5JNrZCBf8,6546
|
45
45
|
keras/_tf_keras/keras/mixed_precision/__init__.py,sha256=AM51CzHqzcY75tqdpQiuVcTRUEpUzBqeb-EfLeSDSV8,727
|
46
46
|
keras/_tf_keras/keras/models/__init__.py,sha256=83pyA0pzytqin8JLV6FEbPreCb-V64ToebxFGrHsVdQ,501
|
47
|
-
keras/_tf_keras/keras/ops/__init__.py,sha256=
|
47
|
+
keras/_tf_keras/keras/ops/__init__.py,sha256=yQXz8CrRtgdWsn8hAnqlj598WXteZ-z_-TfgDKxV_WA,14731
|
48
48
|
keras/_tf_keras/keras/ops/image/__init__.py,sha256=K57F1fBruHn6hacx9uQFWPYO1qbdNM40VR3djvKIRq4,961
|
49
49
|
keras/_tf_keras/keras/ops/linalg/__init__.py,sha256=cc8apE35y2X8idUxY-kc7qYCUm3SAvY2b_StSjRB7Ro,778
|
50
50
|
keras/_tf_keras/keras/ops/nn/__init__.py,sha256=DAloStL366PAGID_tqeSKnConPl5aB4dcyNVm8bWnUU,2802
|
51
|
-
keras/_tf_keras/keras/ops/numpy/__init__.py,sha256=
|
51
|
+
keras/_tf_keras/keras/ops/numpy/__init__.py,sha256=PWk69Pi1Z8KLcK_ByDepAxBHvPfU5DL1vxXuvqkd3cU,9027
|
52
52
|
keras/_tf_keras/keras/optimizers/__init__.py,sha256=1fx0vEB-oGu-9dumxoIvX4qVHdgJvf74OLyYoBkE2y0,1267
|
53
53
|
keras/_tf_keras/keras/optimizers/legacy/__init__.py,sha256=uIMQESCV80Q0FY-9ikQUjXYPyZqmTfAM3dfohQ5DzYs,516
|
54
54
|
keras/_tf_keras/keras/optimizers/schedules/__init__.py,sha256=pQF3rQiAPuUSTUdflTr-fpL77oyGIv9xzGdjae3M3kw,1120
|
@@ -109,11 +109,11 @@ keras/losses/__init__.py,sha256=VIXBHQFNdLUPZ7JuwtIKj_4E-xf2yvNyrmdklvjr_xM,3667
|
|
109
109
|
keras/metrics/__init__.py,sha256=qeEwtqpSCAaCr8BMUv1eVaqJl2Zb83OB5K0BG3JB0nI,6245
|
110
110
|
keras/mixed_precision/__init__.py,sha256=AM51CzHqzcY75tqdpQiuVcTRUEpUzBqeb-EfLeSDSV8,727
|
111
111
|
keras/models/__init__.py,sha256=83pyA0pzytqin8JLV6FEbPreCb-V64ToebxFGrHsVdQ,501
|
112
|
-
keras/ops/__init__.py,sha256=
|
112
|
+
keras/ops/__init__.py,sha256=yQXz8CrRtgdWsn8hAnqlj598WXteZ-z_-TfgDKxV_WA,14731
|
113
113
|
keras/ops/image/__init__.py,sha256=K57F1fBruHn6hacx9uQFWPYO1qbdNM40VR3djvKIRq4,961
|
114
114
|
keras/ops/linalg/__init__.py,sha256=cc8apE35y2X8idUxY-kc7qYCUm3SAvY2b_StSjRB7Ro,778
|
115
115
|
keras/ops/nn/__init__.py,sha256=DAloStL366PAGID_tqeSKnConPl5aB4dcyNVm8bWnUU,2802
|
116
|
-
keras/ops/numpy/__init__.py,sha256=
|
116
|
+
keras/ops/numpy/__init__.py,sha256=PWk69Pi1Z8KLcK_ByDepAxBHvPfU5DL1vxXuvqkd3cU,9027
|
117
117
|
keras/optimizers/__init__.py,sha256=1fx0vEB-oGu-9dumxoIvX4qVHdgJvf74OLyYoBkE2y0,1267
|
118
118
|
keras/optimizers/legacy/__init__.py,sha256=uIMQESCV80Q0FY-9ikQUjXYPyZqmTfAM3dfohQ5DzYs,516
|
119
119
|
keras/optimizers/schedules/__init__.py,sha256=pQF3rQiAPuUSTUdflTr-fpL77oyGIv9xzGdjae3M3kw,1120
|
@@ -126,7 +126,7 @@ keras/regularizers/__init__.py,sha256=542Shphw7W8h4Dyf2rmqMKUECVZ8IVBvN9g1LWhz-b
|
|
126
126
|
keras/saving/__init__.py,sha256=KvL2GZxjvgFgEhvEnkvqjIR9JSNHKz-NWZacXajsjLI,1298
|
127
127
|
keras/src/__init__.py,sha256=Gi4S7EiCMkE03PbdGNpFdaUYySWDs_FcAJ8Taz9Y1BE,684
|
128
128
|
keras/src/api_export.py,sha256=gXOkBOnmscV013WAc75lc4Up01-Kkg9EylIAT_QWctg,1173
|
129
|
-
keras/src/version.py,sha256=
|
129
|
+
keras/src/version.py,sha256=qIUdFEBpnrJ70d7MjDe34fHBFzFG_t_fsQPX7fJOSM8,204
|
130
130
|
keras/src/activations/__init__.py,sha256=0nL3IFDB9unlrMz8ninKOWo-uCHasTUpTo1tXZb2u44,4433
|
131
131
|
keras/src/activations/activations.py,sha256=mogPggtp4CGldI3VOPNmesRxp6EbiR1_i4KLGaVwzL8,17614
|
132
132
|
keras/src/applications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -169,7 +169,7 @@ keras/src/backend/jax/layer.py,sha256=QxZeeiimUulsb3j1h3ncNxIoTYdKPO89s0kP49ZwF-
|
|
169
169
|
keras/src/backend/jax/linalg.py,sha256=dtGHRYCvoVlRX0UwbDDdunA8Vp_mA3sdqoasX4P8SbQ,2532
|
170
170
|
keras/src/backend/jax/math.py,sha256=1IEDpdoF8e5ltu3D4wbDQuihzvJHhMXz8W9Z_E-eJqU,9391
|
171
171
|
keras/src/backend/jax/nn.py,sha256=R0a8-WB0YCl14FpRi2CQ45MFRvHCFtPTedk0Q1LfWYc,45935
|
172
|
-
keras/src/backend/jax/numpy.py,sha256=
|
172
|
+
keras/src/backend/jax/numpy.py,sha256=S0FA9ZM0U9zYH_011-89xAoe_UCpMKeSTTskniBNAoE,36907
|
173
173
|
keras/src/backend/jax/optimizer.py,sha256=JSKRkBteb7u-He5rtHwU6Wy5p8IjSsZf-IIL4-eQfsE,4102
|
174
174
|
keras/src/backend/jax/random.py,sha256=Uk2huGIk_dlzMrx5eDVrrr2TeCEMitn2vr4yzA0NXjs,3594
|
175
175
|
keras/src/backend/jax/rnn.py,sha256=Ycq0qfLY4M4jhltvztpLQyywjEM17T7CZQFh4hhHOUE,7767
|
@@ -184,7 +184,7 @@ keras/src/backend/numpy/layer.py,sha256=dTk7W7ql7vRgll7JbOXK5PlIhQw5VHdpSjKciHd8
|
|
184
184
|
keras/src/backend/numpy/linalg.py,sha256=H8Bdu8LG6OlzXqx8uVxLmTKKE8s9lMoZHMsM2tW4e04,2417
|
185
185
|
keras/src/backend/numpy/math.py,sha256=HdkEA5ro7dtQBTP78GFIgqTFLgNQ49PXHhqI1vLRGfo,10169
|
186
186
|
keras/src/backend/numpy/nn.py,sha256=wTh4s2ZvL4PjPjz4VE6tMrFkRMaQiqpdBeNb6RY5kyE,36623
|
187
|
-
keras/src/backend/numpy/numpy.py,sha256=
|
187
|
+
keras/src/backend/numpy/numpy.py,sha256=gr2kiDR9bbFFDOkM-q0h1Ke6o2b-GFS33Cw0Cab8cnk,35408
|
188
188
|
keras/src/backend/numpy/random.py,sha256=wx2nE75q7L2cBMjtQlQx8yKMj4Ie3puFMDQsbrZO8SA,3961
|
189
189
|
keras/src/backend/numpy/rnn.py,sha256=thOsMung1qR3lQsR4_D6hqKMFollQgrB0KwsJLk4BMY,7867
|
190
190
|
keras/src/backend/numpy/trainer.py,sha256=MzWr8_LLHa1P6fxdUWirGw_lQwHGF_vkZ7RUGLUzjUs,11126
|
@@ -196,7 +196,7 @@ keras/src/backend/openvino/layer.py,sha256=5RdvaH1yOyPAphjKiuQAK1H_yZFYKE1Hp7c5b
|
|
196
196
|
keras/src/backend/openvino/linalg.py,sha256=Q09iv7fcE-xtNOop_hTG_RADkI0CHhjfrcOHqdWCmIY,1486
|
197
197
|
keras/src/backend/openvino/math.py,sha256=qw9kX2sJ2qr0dBJF12Ey0E2GcwixPUqoev6UcNra4NI,3944
|
198
198
|
keras/src/backend/openvino/nn.py,sha256=FUjNvBOcwP-A1BHffaCIZ-bl6na6xM_v91dcaTP4Q4U,15121
|
199
|
-
keras/src/backend/openvino/numpy.py,sha256=
|
199
|
+
keras/src/backend/openvino/numpy.py,sha256=XYXmWh7i-3jsPq0Dpzw8bwcspgKUoIzKa1_wa_EX5fg,65713
|
200
200
|
keras/src/backend/openvino/random.py,sha256=bR7BYdfYHsBi5rYgCKmpFf310fa1q7JT48Z29XxhwmA,5851
|
201
201
|
keras/src/backend/openvino/rnn.py,sha256=ErmuZLPSgG9qU-NfYPPvBZ6Ysy8k-fA4g19Vhqq7OVQ,866
|
202
202
|
keras/src/backend/openvino/trainer.py,sha256=bMmtSALqydqdS6ke-5sYW5fgxZDshDH810p_C0xCRTg,9087
|
@@ -209,7 +209,7 @@ keras/src/backend/tensorflow/layer.py,sha256=iE6XYSZENEoTpNhoXrEOm7gnIOHwOjETZd_
|
|
209
209
|
keras/src/backend/tensorflow/linalg.py,sha256=fpzxql1ycXIAks9AvS753aiSoaVqAuM6xbv671BulhQ,8038
|
210
210
|
keras/src/backend/tensorflow/math.py,sha256=zTu_7Ff6B2Ro862z_xH0OCmIWbV74DjsO5UnfjYuOUQ,12370
|
211
211
|
keras/src/backend/tensorflow/nn.py,sha256=oS7sngoA2C2SFfKQdYWvSZe7HCFfG29t4glbE6yv9CM,34616
|
212
|
-
keras/src/backend/tensorflow/numpy.py,sha256=
|
212
|
+
keras/src/backend/tensorflow/numpy.py,sha256=3KqOBtVfMf8qQ9YEqpLSZLbv5oWftvBOjNjVE8j67o0,96100
|
213
213
|
keras/src/backend/tensorflow/optimizer.py,sha256=kFlyEOnGjEYdLpd8mpwhUeku78__xBfZbbrDWpJrq60,9307
|
214
214
|
keras/src/backend/tensorflow/random.py,sha256=iO8V_soaDXZm9ewyAVbjudhsMj08C348c9Bz64nxXC4,6475
|
215
215
|
keras/src/backend/tensorflow/rnn.py,sha256=99EJqbPdWddmG14zyjjhUZfU5zo9ObmslF_Mak7EmAs,34602
|
@@ -225,7 +225,7 @@ keras/src/backend/torch/layer.py,sha256=htECdpv9ioHWM8_zqQkEdxgDsgLu8XJi5yXgnLl-
|
|
225
225
|
keras/src/backend/torch/linalg.py,sha256=2GUb107BufiHEK2zJ_fkFREo8Y8mo0OqUZLkwNNgOv4,1991
|
226
226
|
keras/src/backend/torch/math.py,sha256=g-ElDii2Y_o1-t6BAu2nbS7JH-aPqVS5Fqds8aYzIlg,14324
|
227
227
|
keras/src/backend/torch/nn.py,sha256=8sqbeYU1siImRRyF4J-7JEE_CvcVeGnQ4D9aGijAyxo,33379
|
228
|
-
keras/src/backend/torch/numpy.py,sha256=
|
228
|
+
keras/src/backend/torch/numpy.py,sha256=8kQfqtbMwDoi9Ra8I1ykphf2ZY0-RYlMC61MfwDeBU4,55098
|
229
229
|
keras/src/backend/torch/random.py,sha256=YhLfC7qkGpzlU_i6gGPVormo3BMSo7OUA3TC3GCehrA,8292
|
230
230
|
keras/src/backend/torch/rnn.py,sha256=J0vg7ikxBiv1FzEavgwT8IVCs0ceBcEv5LYyM5C2suA,25545
|
231
231
|
keras/src/backend/torch/trainer.py,sha256=TCnq0Tl9W0OUYesGGaSTWtGMnPiz-s6jrR5AC2F-TTg,17837
|
@@ -274,7 +274,7 @@ keras/src/distribution/__init__.py,sha256=pseLHx387oTmXROr95tU7kNWjPL8-JB4kZs8nU
|
|
274
274
|
keras/src/distribution/distribution_lib.py,sha256=S9ytKry0o36ZN0vDGxBuY22mxLHqYKxsDAaFOyIk0-U,33954
|
275
275
|
keras/src/dtype_policies/__init__.py,sha256=qYQQC3MvU0BujZcP0IN7_0awcu926rtSRukjcV2TU5w,3545
|
276
276
|
keras/src/dtype_policies/dtype_policy.py,sha256=H7RgeqsyCbG_Y-6-bAvjFn7RnZfkkMVhwsjwMtiPv6Y,12790
|
277
|
-
keras/src/dtype_policies/dtype_policy_map.py,sha256=
|
277
|
+
keras/src/dtype_policies/dtype_policy_map.py,sha256=DqDYlssUGSiTqawPpaVRvR6ljYD8DJrFERCxXVVFvBE,10840
|
278
278
|
keras/src/export/__init__.py,sha256=eAnOPPV1JqVPfb3Z67T48HfSMit-x8Je51mFVYynxgI,265
|
279
279
|
keras/src/export/export_utils.py,sha256=ppBvXH5pHj93n5zCdm4rD-44dM45YkC__zVGaocTIkI,4049
|
280
280
|
keras/src/export/onnx.py,sha256=bQBWxD7hcQmgZ00ywwI8dTwwd0VjMPHCVVHnUeELhlw,8186
|
@@ -365,13 +365,13 @@ keras/src/layers/preprocessing/feature_space.py,sha256=-cB4tpfk2RovCUJ3AXMsNPtVf
|
|
365
365
|
keras/src/layers/preprocessing/hashed_crossing.py,sha256=uwOTKPsv2UweHuGiF4V5HFRgYnjP8N0_S6qT3JP5KeQ,8481
|
366
366
|
keras/src/layers/preprocessing/hashing.py,sha256=3k1L_2d_bROHxZNjDbfURRBSFzFBIHFj0tEXCobcS8w,11188
|
367
367
|
keras/src/layers/preprocessing/index_lookup.py,sha256=t39CWJWnjHrAzy_RxbJ-yC27PwDGaYQjqJjrcnacnGw,41952
|
368
|
-
keras/src/layers/preprocessing/integer_lookup.py,sha256=
|
368
|
+
keras/src/layers/preprocessing/integer_lookup.py,sha256=xZ04Iltmg3e3CXMdESvCZlvsiclZ2oZ_C9vp8RJ5YHA,18688
|
369
369
|
keras/src/layers/preprocessing/mel_spectrogram.py,sha256=ER_XvZt8hwCqTYlWvO4f-edA1b8pFJjrWLdcrilHluA,14697
|
370
370
|
keras/src/layers/preprocessing/normalization.py,sha256=DKXPEfWZNDVabReyIayMlzsiseLNbKV7or_usvMw2Ss,15067
|
371
371
|
keras/src/layers/preprocessing/pipeline.py,sha256=D6dd1LQTW9m9jUaeorTn29rY19gRmkSXXaUxj02kUxc,2533
|
372
372
|
keras/src/layers/preprocessing/rescaling.py,sha256=Uhcqui6BKs9DI-iJYItWSWA6AH1mmBrDH1N4Daz68P0,2802
|
373
373
|
keras/src/layers/preprocessing/stft_spectrogram.py,sha256=D92Gsbx4chANl2xLPXBCSKTM6z3Nc9pWZpgTz0d5MnA,15058
|
374
|
-
keras/src/layers/preprocessing/string_lookup.py,sha256=
|
374
|
+
keras/src/layers/preprocessing/string_lookup.py,sha256=SkJyJrCbopO4BbAqcvBm-AUiNrNXoxNRMGZOHv8q2R4,18622
|
375
375
|
keras/src/layers/preprocessing/text_vectorization.py,sha256=p1uubjplFyPo5yOnNJXtG9Vg0GJMQTJucUGljf3FROM,28161
|
376
376
|
keras/src/layers/preprocessing/image_preprocessing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
377
377
|
keras/src/layers/preprocessing/image_preprocessing/aug_mix.py,sha256=74a--OGdbonqwdEpErAZ8EnS6aGNyktRcPYheTvTbvg,11221
|
@@ -489,7 +489,7 @@ keras/src/ops/linalg.py,sha256=1Z6my5X0e0uoTYPGJ0I0s2hiKbxYFmdyvoifBcZJEsc,22636
|
|
489
489
|
keras/src/ops/math.py,sha256=4qYMJ5qAPmeSyeF63YWoGbUkQt6f4_VX0enOChU4mXU,37233
|
490
490
|
keras/src/ops/nn.py,sha256=1BC-zmnpsUhqG5lSE4VvV5PsBf81wN0ZGg4kU-R8TJY,95259
|
491
491
|
keras/src/ops/node.py,sha256=aJgn9D-GkteE--Bbt2cZ9JjVxb2W2uS1OWEKoeLsl3Y,5583
|
492
|
-
keras/src/ops/numpy.py,sha256=
|
492
|
+
keras/src/ops/numpy.py,sha256=ovWnm3XHDIzjiwjm_GjM0oVZHCGige7Ek95cX4qCAvk,236694
|
493
493
|
keras/src/ops/operation.py,sha256=Q-nOnXPrmt2daaC3X1png3Y86sFPDttrNEopPb6o3wM,12957
|
494
494
|
keras/src/ops/operation_utils.py,sha256=BSarr5DZF5dr-URdXNzawwZlFx6R7VRjh6P2DGwgrT4,14457
|
495
495
|
keras/src/ops/symbolic_arguments.py,sha256=MKwXxZYkyouD9BPmQ1uUNxILdcwPvTayAqXaUV3P3o4,1628
|
@@ -597,7 +597,7 @@ keras/utils/bounding_boxes/__init__.py,sha256=jtvQll4u8ZY0Z96HwNhP1nxWEG9FM3gI-6
|
|
597
597
|
keras/utils/legacy/__init__.py,sha256=oSYZz6uS8UxSElRaaJYWJEoweJ4GAasZjnn7fNaOlog,342
|
598
598
|
keras/visualization/__init__.py,sha256=UKWmiy6sps4SWlmQi9WX8_Z53cPpLlphz2zIeHdwJpQ,722
|
599
599
|
keras/wrappers/__init__.py,sha256=QkS-O5K8qGS7C3sytF8MpmO6PasATpNVGF8qtb7Ojsw,407
|
600
|
-
keras_nightly-3.12.0.
|
601
|
-
keras_nightly-3.12.0.
|
602
|
-
keras_nightly-3.12.0.
|
603
|
-
keras_nightly-3.12.0.
|
600
|
+
keras_nightly-3.12.0.dev2025083003.dist-info/METADATA,sha256=PA8ZDoSK479YTz79H8VmTX-QqmhTUyYJ3AIW0oPiou0,5970
|
601
|
+
keras_nightly-3.12.0.dev2025083003.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
602
|
+
keras_nightly-3.12.0.dev2025083003.dist-info/top_level.txt,sha256=ptcw_-QuGZ4ZDjMdwi_Z0clZm8QAqFdvzzFnDEOTs9o,6
|
603
|
+
keras_nightly-3.12.0.dev2025083003.dist-info/RECORD,,
|
{keras_nightly-3.12.0.dev2025082903.dist-info → keras_nightly-3.12.0.dev2025083003.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|