keras-nightly 3.12.0.dev2025090303__py3-none-any.whl → 3.12.0.dev2025090503__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 +7 -0
- keras/src/backend/openvino/numpy.py +4 -0
- keras/src/backend/tensorflow/numpy.py +46 -0
- keras/src/backend/torch/numpy.py +6 -0
- keras/src/models/model.py +2 -2
- keras/src/ops/numpy.py +43 -0
- keras/src/quantizers/gptq.py +284 -192
- keras/src/quantizers/gptq_config.py +3 -13
- keras/src/quantizers/gptq_core.py +211 -158
- keras/src/quantizers/quantizers.py +200 -0
- keras/src/version.py +1 -1
- {keras_nightly-3.12.0.dev2025090303.dist-info → keras_nightly-3.12.0.dev2025090503.dist-info}/METADATA +1 -1
- {keras_nightly-3.12.0.dev2025090303.dist-info → keras_nightly-3.12.0.dev2025090503.dist-info}/RECORD +20 -21
- keras/src/quantizers/gptq_quant.py +0 -133
- {keras_nightly-3.12.0.dev2025090303.dist-info → keras_nightly-3.12.0.dev2025090503.dist-info}/WHEEL +0 -0
- {keras_nightly-3.12.0.dev2025090303.dist-info → keras_nightly-3.12.0.dev2025090503.dist-info}/top_level.txt +0 -0
@@ -208,6 +208,7 @@ from keras.src.ops.numpy import isnan as isnan
|
|
208
208
|
from keras.src.ops.numpy import isneginf as isneginf
|
209
209
|
from keras.src.ops.numpy import isposinf as isposinf
|
210
210
|
from keras.src.ops.numpy import kaiser as kaiser
|
211
|
+
from keras.src.ops.numpy import kron as kron
|
211
212
|
from keras.src.ops.numpy import left_shift as left_shift
|
212
213
|
from keras.src.ops.numpy import less as less
|
213
214
|
from keras.src.ops.numpy import less_equal as less_equal
|
@@ -96,6 +96,7 @@ from keras.src.ops.numpy import isnan as isnan
|
|
96
96
|
from keras.src.ops.numpy import isneginf as isneginf
|
97
97
|
from keras.src.ops.numpy import isposinf as isposinf
|
98
98
|
from keras.src.ops.numpy import kaiser as kaiser
|
99
|
+
from keras.src.ops.numpy import kron as kron
|
99
100
|
from keras.src.ops.numpy import left_shift as left_shift
|
100
101
|
from keras.src.ops.numpy import less as less
|
101
102
|
from keras.src.ops.numpy import less_equal as less_equal
|
keras/ops/__init__.py
CHANGED
@@ -208,6 +208,7 @@ from keras.src.ops.numpy import isnan as isnan
|
|
208
208
|
from keras.src.ops.numpy import isneginf as isneginf
|
209
209
|
from keras.src.ops.numpy import isposinf as isposinf
|
210
210
|
from keras.src.ops.numpy import kaiser as kaiser
|
211
|
+
from keras.src.ops.numpy import kron as kron
|
211
212
|
from keras.src.ops.numpy import left_shift as left_shift
|
212
213
|
from keras.src.ops.numpy import less as less
|
213
214
|
from keras.src.ops.numpy import less_equal as less_equal
|
keras/ops/numpy/__init__.py
CHANGED
@@ -96,6 +96,7 @@ from keras.src.ops.numpy import isnan as isnan
|
|
96
96
|
from keras.src.ops.numpy import isneginf as isneginf
|
97
97
|
from keras.src.ops.numpy import isposinf as isposinf
|
98
98
|
from keras.src.ops.numpy import kaiser as kaiser
|
99
|
+
from keras.src.ops.numpy import kron as kron
|
99
100
|
from keras.src.ops.numpy import left_shift as left_shift
|
100
101
|
from keras.src.ops.numpy import less as less
|
101
102
|
from keras.src.ops.numpy import less_equal as less_equal
|
keras/src/backend/jax/numpy.py
CHANGED
@@ -809,6 +809,12 @@ def isposinf(x):
|
|
809
809
|
return jnp.isposinf(x)
|
810
810
|
|
811
811
|
|
812
|
+
def kron(x1, x2):
|
813
|
+
x1 = convert_to_tensor(x1)
|
814
|
+
x2 = convert_to_tensor(x2)
|
815
|
+
return jnp.kron(x1, x2)
|
816
|
+
|
817
|
+
|
812
818
|
def less(x1, x2):
|
813
819
|
x1 = convert_to_tensor(x1)
|
814
820
|
x2 = convert_to_tensor(x2)
|
keras/src/backend/numpy/numpy.py
CHANGED
@@ -742,6 +742,13 @@ def isposinf(x):
|
|
742
742
|
return np.isposinf(x)
|
743
743
|
|
744
744
|
|
745
|
+
def kron(x1, x2):
|
746
|
+
x1 = convert_to_tensor(x1)
|
747
|
+
x2 = convert_to_tensor(x2)
|
748
|
+
dtype = dtypes.result_type(x1.dtype, x2.dtype)
|
749
|
+
return np.kron(x1, x2).astype(dtype)
|
750
|
+
|
751
|
+
|
745
752
|
def less(x1, x2):
|
746
753
|
return np.less(x1, x2)
|
747
754
|
|
@@ -1711,6 +1711,52 @@ def isposinf(x):
|
|
1711
1711
|
return tf.math.equal(x, tf.constant(float("inf"), dtype=x.dtype))
|
1712
1712
|
|
1713
1713
|
|
1714
|
+
def kron(x1, x2):
|
1715
|
+
x1 = convert_to_tensor(x1)
|
1716
|
+
x2 = convert_to_tensor(x2)
|
1717
|
+
|
1718
|
+
dtype = dtypes.result_type(x1.dtype, x2.dtype)
|
1719
|
+
x1 = tf.cast(x1, dtype)
|
1720
|
+
x2 = tf.cast(x2, dtype)
|
1721
|
+
|
1722
|
+
ndim_x1 = tf.rank(x1)
|
1723
|
+
ndim_x2 = tf.rank(x2)
|
1724
|
+
|
1725
|
+
def expand_front(x, num):
|
1726
|
+
for _ in range(num):
|
1727
|
+
x = tf.expand_dims(x, axis=0)
|
1728
|
+
return x
|
1729
|
+
|
1730
|
+
x1 = tf.cond(
|
1731
|
+
ndim_x1 < ndim_x2,
|
1732
|
+
lambda: expand_front(x1, ndim_x2 - ndim_x1),
|
1733
|
+
lambda: x1,
|
1734
|
+
)
|
1735
|
+
x2 = tf.cond(
|
1736
|
+
ndim_x2 < ndim_x1,
|
1737
|
+
lambda: expand_front(x2, ndim_x1 - ndim_x2),
|
1738
|
+
lambda: x2,
|
1739
|
+
)
|
1740
|
+
|
1741
|
+
x1_reshaped = tf.reshape(
|
1742
|
+
x1,
|
1743
|
+
tf.reshape(
|
1744
|
+
tf.stack([tf.shape(x1), tf.ones_like(tf.shape(x1))], axis=1), [-1]
|
1745
|
+
),
|
1746
|
+
)
|
1747
|
+
x2_reshaped = tf.reshape(
|
1748
|
+
x2,
|
1749
|
+
tf.reshape(
|
1750
|
+
tf.stack([tf.ones_like(tf.shape(x2)), tf.shape(x2)], axis=1), [-1]
|
1751
|
+
),
|
1752
|
+
)
|
1753
|
+
|
1754
|
+
out = tf.multiply(x1_reshaped, x2_reshaped)
|
1755
|
+
out_shape = tf.multiply(tf.shape(x1), tf.shape(x2))
|
1756
|
+
out = tf.reshape(out, out_shape)
|
1757
|
+
return out
|
1758
|
+
|
1759
|
+
|
1714
1760
|
def less(x1, x2):
|
1715
1761
|
x1 = convert_to_tensor(x1)
|
1716
1762
|
x2 = convert_to_tensor(x2)
|
keras/src/backend/torch/numpy.py
CHANGED
@@ -945,6 +945,12 @@ def isposinf(x):
|
|
945
945
|
return torch.isposinf(x)
|
946
946
|
|
947
947
|
|
948
|
+
def kron(x1, x2):
|
949
|
+
x1 = convert_to_tensor(x1)
|
950
|
+
x2 = convert_to_tensor(x2)
|
951
|
+
return torch.kron(x1, x2)
|
952
|
+
|
953
|
+
|
948
954
|
def less(x1, x2):
|
949
955
|
x1, x2 = convert_to_tensor(x1), convert_to_tensor(x2)
|
950
956
|
return torch.less(x1, x2)
|
keras/src/models/model.py
CHANGED
@@ -9,6 +9,7 @@ from keras.src.api_export import keras_export
|
|
9
9
|
from keras.src.layers.layer import Layer
|
10
10
|
from keras.src.models.variable_mapping import map_saveable_variables
|
11
11
|
from keras.src.quantizers.gptq_config import GPTQConfig
|
12
|
+
from keras.src.quantizers.gptq_core import gptq_quantize
|
12
13
|
from keras.src.saving import saving_api
|
13
14
|
from keras.src.trainers import trainer as base_trainer
|
14
15
|
from keras.src.utils import summary_utils
|
@@ -440,8 +441,7 @@ class Model(Trainer, base_trainer.Trainer, Layer):
|
|
440
441
|
"The `config` argument must be of type "
|
441
442
|
"`keras.quantizers.GPTQConfig`."
|
442
443
|
)
|
443
|
-
|
444
|
-
config.quantize(self)
|
444
|
+
gptq_quantize(self, config)
|
445
445
|
return
|
446
446
|
|
447
447
|
# For all other modes, verify that a config object was not passed.
|
keras/src/ops/numpy.py
CHANGED
@@ -3845,6 +3845,49 @@ def isposinf(x):
|
|
3845
3845
|
return backend.numpy.isposinf(x)
|
3846
3846
|
|
3847
3847
|
|
3848
|
+
class Kron(Operation):
|
3849
|
+
def call(self, x1, x2):
|
3850
|
+
return backend.numpy.kron(x1, x2)
|
3851
|
+
|
3852
|
+
def compute_output_spec(self, x1, x2):
|
3853
|
+
x1_shape = getattr(x1, "shape", [])
|
3854
|
+
x2_shape = getattr(x2, "shape", [])
|
3855
|
+
|
3856
|
+
def _mul_shape_dim(a, b):
|
3857
|
+
if a is None or b is None:
|
3858
|
+
return None
|
3859
|
+
return a * b
|
3860
|
+
|
3861
|
+
output_shape = tuple(
|
3862
|
+
_mul_shape_dim(a, b) for a, b in zip(x1_shape, x2_shape)
|
3863
|
+
)
|
3864
|
+
|
3865
|
+
x1_type = backend.standardize_dtype(getattr(x1, "dtype", type(x1)))
|
3866
|
+
x2_type = backend.standardize_dtype(getattr(x2, "dtype", type(x2)))
|
3867
|
+
dtype = dtypes.result_type(x1_type, x2_type)
|
3868
|
+
return KerasTensor(output_shape, dtype=dtype)
|
3869
|
+
|
3870
|
+
|
3871
|
+
@keras_export(["keras.ops.kron", "keras.ops.numpy.kron"])
|
3872
|
+
def kron(x1, x2):
|
3873
|
+
"""Kronecker product of `x1` and `x2`.
|
3874
|
+
|
3875
|
+
Computes the Kronecker product of two input tensors. If `x1` has shape
|
3876
|
+
`(a0, a1, ..., an)` and `x2` has shape `(b0, b1, ..., bn)`, then the
|
3877
|
+
output will have shape `(a0*b0, a1*b1, ..., an*bn)`.
|
3878
|
+
|
3879
|
+
Args:
|
3880
|
+
x1: First input tensor.
|
3881
|
+
x2: Second input tensor.
|
3882
|
+
|
3883
|
+
Returns:
|
3884
|
+
A tensor representing the Kronecker product of `x1` and `x2`.
|
3885
|
+
"""
|
3886
|
+
if any_symbolic_tensors((x1, x2)):
|
3887
|
+
return Kron().symbolic_call(x1, x2)
|
3888
|
+
return backend.numpy.kron(x1, x2)
|
3889
|
+
|
3890
|
+
|
3848
3891
|
class Less(Operation):
|
3849
3892
|
def call(self, x1, x2):
|
3850
3893
|
return backend.numpy.less(x1, x2)
|