hgq.layers.core package

Submodules

hgq.layers.core.base module

class hgq.layers.core.base.MultipleQuantizers(*args, **kwargs)

Bases: Layer

build(shapes: Sequence[Sequence[int | None]])
call(x, **kwargs)
class hgq.layers.core.base.QLayerBase(*args, **kwargs)

Bases: Layer

property beta
build(*args, **kwargs)
property ebops
property enable_ebops
property enable_iq
enable_lora(*args, **kwargs)
property enable_oq
classmethod from_config(config)

Creates an operation from its config.

This method is the reverse of get_config, capable of instantiating the same operation from the config dictionary.

Note: If you override this method, you might receive a serialized dtype config, which is a dict. You can deserialize it as follows:

```python if “dtype” in config and isinstance(config[“dtype”], dict):

policy = dtype_policies.deserialize(config[“dtype”])

```

Parameters:

config – A Python dictionary, typically the output of get_config.

Returns:

An operation instance.

get_config()

Returns the config of the object.

An object config is a Python dictionary (serializable) containing the information needed to re-instantiate it.

load_own_variables(store)

Loads the state of the layer.

You can override this method to take full control of how the state of the layer is loaded upon calling keras.models.load_model().

Parameters:

store – Dict from which the state of the model will be loaded.

property oq
save_own_variables(store)

Saves the state of the layer.

You can override this method to take full control of how the state of the layer is saved upon calling model.save().

Parameters:

store – Dict where the state of the model will be saved.

try_build_output_quantizer(input_shape=None, *args, **kwargs)
class hgq.layers.core.base.QLayerBaseMultiInputs(*args, **kwargs)

Bases: QLayerBase

build(input_shape)
get_config()

Returns the config of the object.

An object config is a Python dictionary (serializable) containing the information needed to re-instantiate it.

property iq
property iq_confs
class hgq.layers.core.base.QLayerBaseSingleInput(*args, **kwargs)

Bases: QLayerBase

build(input_shape)
get_config()

Returns the config of the object.

An object config is a Python dictionary (serializable) containing the information needed to re-instantiate it.

property iq
class hgq.layers.core.base.QLayerMeta(name, bases, namespace, /, **kwargs)

Bases: ABCMeta

hgq.layers.core.base.check_save_load_own_variables(cls)

Assert that save_own_variables and load_own_variables are not overriden, or they should be defined in the same class

hgq.layers.core.base.get_method_source(cls, method_name)

Get the class that defines the method

hgq.layers.core.dense module

class hgq.layers.core.dense.QBatchNormDense(*args, **kwargs)

Bases: QDense

build(input_shape)
call(inputs, training=None)
get_config()

Returns the config of the object.

An object config is a Python dictionary (serializable) containing the information needed to re-instantiate it.

get_fused_qkernel_and_qbias(mean, var)
property qbias
property qkernel
class hgq.layers.core.dense.QDense(*args, **kwargs)

Bases: QLayerBaseSingleInput, Dense

property bq
build(input_shape)
call(inputs, training=None)
get_config()

Returns the config of the object.

An object config is a Python dictionary (serializable) containing the information needed to re-instantiate it.

property kq
property qbias
property qkernel

hgq.layers.core.einsum_dense module

class hgq.layers.core.einsum_dense.QEinsumDense(*args, **kwargs)

Bases: QLayerBaseSingleInput, EinsumDense

property bq
build(input_shape)
call(inputs, training=None)
get_config()

Returns the config of the object.

An object config is a Python dictionary (serializable) containing the information needed to re-instantiate it.

property kq
property qbias
property qkernel

Module contents

class hgq.layers.core.QBatchNormDense(*args, **kwargs)

Bases: QDense

build(input_shape)
call(inputs, training=None)
get_config()

Returns the config of the object.

An object config is a Python dictionary (serializable) containing the information needed to re-instantiate it.

get_fused_qkernel_and_qbias(mean, var)
property qbias
property qkernel
class hgq.layers.core.QDense(*args, **kwargs)

Bases: QLayerBaseSingleInput, Dense

property bq
build(input_shape)
call(inputs, training=None)
get_config()

Returns the config of the object.

An object config is a Python dictionary (serializable) containing the information needed to re-instantiate it.

property kq
property qbias
property qkernel
class hgq.layers.core.QEinsumDense(*args, **kwargs)

Bases: QLayerBaseSingleInput, EinsumDense

property bq
build(input_shape)
call(inputs, training=None)
get_config()

Returns the config of the object.

An object config is a Python dictionary (serializable) containing the information needed to re-instantiate it.

property kq
property qbias
property qkernel
class hgq.layers.core.QLayerBase(*args, **kwargs)

Bases: Layer

property beta
build(*args, **kwargs)
property ebops
property enable_ebops
property enable_iq
enable_lora(*args, **kwargs)
property enable_oq
classmethod from_config(config)

Creates an operation from its config.

This method is the reverse of get_config, capable of instantiating the same operation from the config dictionary.

Note: If you override this method, you might receive a serialized dtype config, which is a dict. You can deserialize it as follows:

```python if “dtype” in config and isinstance(config[“dtype”], dict):

policy = dtype_policies.deserialize(config[“dtype”])

```

Parameters:

config – A Python dictionary, typically the output of get_config.

Returns:

An operation instance.

get_config()

Returns the config of the object.

An object config is a Python dictionary (serializable) containing the information needed to re-instantiate it.

load_own_variables(store)

Loads the state of the layer.

You can override this method to take full control of how the state of the layer is loaded upon calling keras.models.load_model().

Parameters:

store – Dict from which the state of the model will be loaded.

property oq
save_own_variables(store)

Saves the state of the layer.

You can override this method to take full control of how the state of the layer is saved upon calling model.save().

Parameters:

store – Dict where the state of the model will be saved.

try_build_output_quantizer(input_shape=None, *args, **kwargs)
class hgq.layers.core.QLayerBaseMultiInputs(*args, **kwargs)

Bases: QLayerBase

build(input_shape)
get_config()

Returns the config of the object.

An object config is a Python dictionary (serializable) containing the information needed to re-instantiate it.

property iq
property iq_confs
class hgq.layers.core.QLayerBaseSingleInput(*args, **kwargs)

Bases: QLayerBase

build(input_shape)
get_config()

Returns the config of the object.

An object config is a Python dictionary (serializable) containing the information needed to re-instantiate it.

property iq