hgq.layers package

Subpackages

Submodules

hgq.layers.activation module

class hgq.layers.activation.QUnaryFunctionLUT(*args, **kwargs)

Bases: Activation, QLayerBaseSingleInput

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.

hgq.layers.batch_normalization module

class hgq.layers.batch_normalization.QBatchNormalization(*args, **kwargs)

Bases: QLayerBaseSingleInput, BatchNormalization

property beta
property bq
build(input_shape)
call(inputs, training=None, mask=None)
property gamma
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 qscaler_and_qoffset

hgq.layers.conv module

class hgq.layers.conv.QBaseConv(*args, **kwargs)

Bases: QLayerBaseSingleInput, BaseConv

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.conv.QConv1D(*args, **kwargs)

Bases: QBaseConv

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.

class hgq.layers.conv.QConv2D(*args, **kwargs)

Bases: QBaseConv

get_config()

Returns the config of the object.

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

class hgq.layers.conv.QConv3D(*args, **kwargs)

Bases: QBaseConv

get_config()

Returns the config of the object.

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

hgq.layers.einsum_dense_batchnorm module

class hgq.layers.einsum_dense_batchnorm.QEinsumDenseBatchnorm(*args, **kwargs)

Bases: QEinsumDense

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.

get_fused_qkernel_and_qbias(training, mean, var)
property kq
property qbias
property qkernel

hgq.layers.multi_head_attention module

class hgq.layers.multi_head_attention.QMultiHeadAttention(*args, **kwargs)

Bases: MultiHeadAttention, QLayerBase

build(query_shape, value_shape, key_shape=None)

Builds layers and variables.

Parameters:
  • query_shape (tuple) – Shape of the query tensor.

  • value_shape (tuple) – Shape of the value tensor.

  • key_shape (tuple, optional) – Shape of the key tensor.

call(query, value, key=None, query_mask=None, value_mask=None, key_mask=None, attention_mask=None, return_attention_scores=False, training=None, use_causal_mask=False)
compute_output_shape(query_shape, value_shape, key_shape=None)
property ebops
get_config()

Returns the config of the object.

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

hgq.layers.softmax module

class hgq.layers.softmax.QSoftmax(*args, **kwargs)

Bases: QLayerBaseSingleInput

build(input_shape)
call(inputs, training=None, mask=None)
compute_output_shape(input_shape)
property ebops
get_config()

Returns the config of the object.

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

Module contents

class hgq.layers.QAdd(*args, **kwargs)

Bases: QMerge, Add

get_config()

Returns the config of the object.

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

class hgq.layers.QAveragePow2(*args, **kwargs)

Bases: QAdd, Average

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.

class hgq.layers.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.QBatchNormalization(*args, **kwargs)

Bases: QLayerBaseSingleInput, BatchNormalization

property beta
property bq
build(input_shape)
call(inputs, training=None, mask=None)
property gamma
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 qscaler_and_qoffset
class hgq.layers.QConv1D(*args, **kwargs)

Bases: QBaseConv

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.

class hgq.layers.QConv2D(*args, **kwargs)

Bases: QBaseConv

get_config()

Returns the config of the object.

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

class hgq.layers.QConv3D(*args, **kwargs)

Bases: QBaseConv

get_config()

Returns the config of the object.

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

class hgq.layers.QDot(*args, **kwargs)

Bases: QMerge, Dot

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.

class hgq.layers.QEinsum(*args, **kwargs)

Bases: QLayerBaseMultiInputs

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.

class hgq.layers.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.QEinsumDenseBatchnorm(*args, **kwargs)

Bases: QEinsumDense

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.

get_fused_qkernel_and_qbias(training, mean, var)
property kq
property qbias
property qkernel
class hgq.layers.QMaximum(*args, **kwargs)

Bases: QMerge, Maximum

get_config()

Returns the config of the object.

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

class hgq.layers.QMeanPow2(*args, **kwargs)

Bases: QSum

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.

class hgq.layers.QMinimum(*args, **kwargs)

Bases: QMerge, Minimum

get_config()

Returns the config of the object.

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

class hgq.layers.QMultiHeadAttention(*args, **kwargs)

Bases: MultiHeadAttention, QLayerBase

build(query_shape, value_shape, key_shape=None)

Builds layers and variables.

Parameters:
  • query_shape (tuple) – Shape of the query tensor.

  • value_shape (tuple) – Shape of the value tensor.

  • key_shape (tuple, optional) – Shape of the key tensor.

call(query, value, key=None, query_mask=None, value_mask=None, key_mask=None, attention_mask=None, return_attention_scores=False, training=None, use_causal_mask=False)
compute_output_shape(query_shape, value_shape, key_shape=None)
property ebops
get_config()

Returns the config of the object.

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

class hgq.layers.QMultiply(*args, **kwargs)

Bases: QMerge, Multiply

get_config()

Returns the config of the object.

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

class hgq.layers.QSoftmax(*args, **kwargs)

Bases: QLayerBaseSingleInput

build(input_shape)
call(inputs, training=None, mask=None)
compute_output_shape(input_shape)
property ebops
get_config()

Returns the config of the object.

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

class hgq.layers.QSubtract(*args, **kwargs)

Bases: QMerge, Subtract

get_config()

Returns the config of the object.

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

class hgq.layers.QSum(*args, **kwargs)

Bases: QLayerBaseSingleInput

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 keepdims
property scale
class hgq.layers.QUnaryFunctionLUT(*args, **kwargs)

Bases: Activation, QLayerBaseSingleInput

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.

class hgq.layers.Quantizer(*args, **kwargs)

Bases: Layer

The generic quantizer layer, wraps internal quantizers to provide a universal interface. Supports float, fixed-point (KBI, KIF) quantization. Can be initialized with a QuantizerConfig object or with the quantizer type and its parameters.

property bits
bits_(shape)
build(input_shape)
call(inputs, training=None)
epsilon_(shape)
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.

get_quantizer_config_kwargs(*args, **kwargs)
max_(shape)
min_(shape)
property q_type