View source on GitHub
|
Quantized dtype policy for int4 quantization.
Inherits From: QuantizedDTypePolicy, DTypePolicy
tf.keras.dtype_policies.Int4DTypePolicy(
mode, source_name=None
)
This policy helps propagate quantization settings for int4 sub-channel quantization when loading a quantized model in Keras format.
Attributes | |
|---|---|
compute_dtype
|
The compute dtype of this policy.
This is the dtype layers will do their computations in. Typically layers output tensors with the compute dtype as well. Note that even if the compute dtype is float16 or bfloat16, hardware devices may not do individual adds, multiplies, and other fundamental operations in float16 or bfloat16, but instead may do some of them in float32 for numeric stability. The compute dtype is the dtype of the inputs and outputs of the ops that the layer executes. Internally, many ops will do certain internal calculations in float32 or some other device-internal intermediate format with higher precision than float16/bfloat16, to increase numeric stability. |
name
|
Returns the name of this policy. |
quantization_mode
|
The quantization mode of this policy. |
variable_dtype
|
The variable dtype of this policy.
This is the dtype layers will create their variables in, unless a layer
explicitly chooses a different dtype. If this is different than
Variable regularizers are run in the variable dtype, not the compute dtype. |
Methods
convert_input
convert_input(
x, autocast, dtype
)
Converts the input dtype based on autocast and dtype.
Note that x can be a tensor, symbolic tensor or numpy array, and this
method will keep integer inputs untouched and only apply casting to
floats.
from_config
@classmethodfrom_config( config )
get_config
get_config()
__eq__
__eq__(
other
)
Return self==value.
View source on GitHub