brevitas.core package#
Subpackages#
- brevitas.core.bit_width package
- brevitas.core.function_wrapper package
- Submodules
- brevitas.core.function_wrapper.clamp module
- brevitas.core.function_wrapper.misc module
- brevitas.core.function_wrapper.ops_ste module
- brevitas.core.function_wrapper.shape module
DynamicOverSubChannelBlockView
OverBatchOverOutputChannelView
OverBatchOverTensorView
OverOutputChannelView
OverOutputFeaturesView
OverSubChannelBlockView
OverTensorView
PermuteDims
StatsInputViewShapeImpl
StatsInputViewShapeImpl.DYNAMIC_OVER_SUBCHANNEL_BLOCK
StatsInputViewShapeImpl.OVER_BATCH_OVER_OUTPUT_CHANNELS
StatsInputViewShapeImpl.OVER_BATCH_OVER_TENSOR
StatsInputViewShapeImpl.OVER_OUTPUT_CHANNELS
StatsInputViewShapeImpl.OVER_OUTPUT_FEATURES
StatsInputViewShapeImpl.OVER_SUBCHANNEL_BLOCK
StatsInputViewShapeImpl.OVER_TENSOR
- Module contents
- brevitas.core.quant package
- Submodules
- brevitas.core.quant.binary module
- brevitas.core.quant.delay module
- brevitas.core.quant.int module
- brevitas.core.quant.int_base module
- brevitas.core.quant.ternary module
- Module contents
- brevitas.core.scaling package
- brevitas.core.stats package
- Submodules
- brevitas.core.stats.stats_op module
- brevitas.core.stats.stats_wrapper module
- brevitas.core.stats.view_wrapper module
- Module contents
Submodules#
brevitas.core.restrict_val module#
- class brevitas.core.restrict_val.FloatRestrictValue[source]#
Bases:
Module
- forward(x)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses. :rtype:
Tensor
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class brevitas.core.restrict_val.IntRestrictValue(restrict_value_float_to_int_impl=RoundSte())[source]#
Bases:
Module
- forward(x)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class brevitas.core.restrict_val.LogFloatRestrictValue[source]#
Bases:
Module
- forward(x)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class brevitas.core.restrict_val.PowerOfTwoRestrictValue(restrict_value_float_to_int_impl=RoundSte())[source]#
Bases:
Module
- forward(x)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
brevitas.core.utils module#
- class brevitas.core.utils.ParameterWrapper(value)[source]#
Bases:
Module
- forward()[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class brevitas.core.utils.SingleArgStatelessBuffer(value)[source]#
Bases:
Module
- forward(placeholder)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class brevitas.core.utils.SliceTensor[source]#
Bases:
Module
- forward(x)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses. :rtype:
Tensor
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class brevitas.core.utils.StatelessBuffer(value)[source]#
Bases:
Module
- forward()[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- state_dict(destination=None, prefix='', keep_vars=False)[source]#
Return a dictionary containing references to the whole state of the module.
Both parameters and persistent buffers (e.g. running averages) are included. Keys are corresponding parameter and buffer names. Parameters and buffers set to
None
are not included.Note
The returned object is a shallow copy. It contains references to the module’s parameters and buffers.
Warning
Currently
state_dict()
also accepts positional arguments fordestination
,prefix
andkeep_vars
in order. However, this is being deprecated and keyword arguments will be enforced in future releases.Warning
Please avoid the use of argument
destination
as it is not designed for end-users.- Parameters:
destination (dict, optional) – If provided, the state of module will be updated into the dict and the same object is returned. Otherwise, an
OrderedDict
will be created and returned. Default:None
.prefix (str, optional) – a prefix added to parameter and buffer names to compose the keys in state_dict. Default:
''
.keep_vars (bool, optional) – by default the
Tensor
s returned in the state dict are detached from autograd. If it’s set toTrue
, detaching will not be performed. Default:False
.
- Returns:
a dictionary containing a whole state of the module
- Return type:
Example:
>>> # xdoctest: +SKIP("undefined vars") >>> module.state_dict().keys() ['bias', 'weight']
brevitas.core.zero_point module#
- class brevitas.core.zero_point.ParameterFromRuntimeZeroPoint(collect_stats_steps, int_quant, quantize_zero_point, zero_point_stats_impl, zero_point_shape, zero_point_stats_input_view_shape_impl, zero_point_stats_momentum=0.1, dtype=None, device=None)[source]#
Bases:
Module
- forward(x, scale, bit_width)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses. :rtype:
Tensor
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- state_dict(destination=None, prefix='', keep_vars=False)[source]#
Return a dictionary containing references to the whole state of the module.
Both parameters and persistent buffers (e.g. running averages) are included. Keys are corresponding parameter and buffer names. Parameters and buffers set to
None
are not included.Note
The returned object is a shallow copy. It contains references to the module’s parameters and buffers.
Warning
Currently
state_dict()
also accepts positional arguments fordestination
,prefix
andkeep_vars
in order. However, this is being deprecated and keyword arguments will be enforced in future releases.Warning
Please avoid the use of argument
destination
as it is not designed for end-users.- Parameters:
destination (dict, optional) – If provided, the state of module will be updated into the dict and the same object is returned. Otherwise, an
OrderedDict
will be created and returned. Default:None
.prefix (str, optional) – a prefix added to parameter and buffer names to compose the keys in state_dict. Default:
''
.keep_vars (bool, optional) – by default the
Tensor
s returned in the state dict are detached from autograd. If it’s set toTrue
, detaching will not be performed. Default:False
.
- Returns:
a dictionary containing a whole state of the module
- Return type:
Example:
>>> # xdoctest: +SKIP("undefined vars") >>> module.state_dict().keys() ['bias', 'weight']
- class brevitas.core.zero_point.ParameterFromStatsFromParameterZeroPoint(int_quant, quantize_zero_point, zero_point_stats_input_view_shape_impl, zero_point_stats_input_concat_dim, zero_point_stats_impl, zero_point_shape, tracked_parameter_list, dtype=None, device=None)[source]#
Bases:
Module
ScriptModule implementation of a learned scale factor initialized from statistics of a parameter, e.g. weights MSE or AbsMax.
- forward(x, scale, bit_width)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses. :rtype:
Tensor
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- state_dict(destination=None, prefix='', keep_vars=False)[source]#
Return a dictionary containing references to the whole state of the module.
Both parameters and persistent buffers (e.g. running averages) are included. Keys are corresponding parameter and buffer names. Parameters and buffers set to
None
are not included.Note
The returned object is a shallow copy. It contains references to the module’s parameters and buffers.
Warning
Currently
state_dict()
also accepts positional arguments fordestination
,prefix
andkeep_vars
in order. However, this is being deprecated and keyword arguments will be enforced in future releases.Warning
Please avoid the use of argument
destination
as it is not designed for end-users.- Parameters:
destination (dict, optional) – If provided, the state of module will be updated into the dict and the same object is returned. Otherwise, an
OrderedDict
will be created and returned. Default:None
.prefix (str, optional) – a prefix added to parameter and buffer names to compose the keys in state_dict. Default:
''
.keep_vars (bool, optional) – by default the
Tensor
s returned in the state dict are detached from autograd. If it’s set toTrue
, detaching will not be performed. Default:False
.
- Returns:
a dictionary containing a whole state of the module
- Return type:
Example:
>>> # xdoctest: +SKIP("undefined vars") >>> module.state_dict().keys() ['bias', 'weight']
- class brevitas.core.zero_point.ParameterZeroPoint(zero_point_init, int_quant, quantize_zero_point, zero_point_shape=None, dtype=None, device=None)[source]#
Bases:
Module
- forward(x, scale, bit_width)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses. :rtype:
Tensor
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class brevitas.core.zero_point.PreZeroCenterZeroPoint(stats_reduce_dim, pre_zero_point_stats_input_view_shape_impl, pre_zero_point_shape=None)[source]#
Bases:
Module
Experimental ScriptModule implementation of a pre-scaling zero-point that zero-centers the incoming tensors. This is intended to be used with DecoupledIntQuant.
- forward(x, scale, bit_width)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses. :rtype:
Tensor
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class brevitas.core.zero_point.StatsFromParameterZeroPoint(int_quant, quantize_zero_point, zero_point_stats_input_view_shape_impl, zero_point_stats_input_concat_dim, zero_point_stats_impl, zero_point_shape, tracked_parameter_list)[source]#
Bases:
Module
- forward(x, scale, bit_width)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses. :rtype:
Tensor
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class brevitas.core.zero_point.ZeroZeroPoint(dtype=None, device=None)[source]#
Bases:
Module
- forward(x, scale, bit_width)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses. :rtype:
Tensor
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.