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
DynamicOverSubChannelBlockViewOverBatchOverOutputChannelViewOverBatchOverTensorViewOverOutputChannelViewOverOutputFeaturesViewOverSubChannelBlockViewOverTensorViewPermuteDimsStatsInputViewShapeImplStatsInputViewShapeImpl.DYNAMIC_OVER_SUBCHANNEL_BLOCKStatsInputViewShapeImpl.OVER_BATCH_OVER_OUTPUT_CHANNELSStatsInputViewShapeImpl.OVER_BATCH_OVER_TENSORStatsInputViewShapeImpl.OVER_OUTPUT_CHANNELSStatsInputViewShapeImpl.OVER_OUTPUT_FEATURESStatsInputViewShapeImpl.OVER_SUBCHANNEL_BLOCKStatsInputViewShapeImpl.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:
TensorNote
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance 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
Moduleinstance 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
Moduleinstance 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
Moduleinstance 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.QuantRestrictValue(restrict_value_float_to_int_impl, scaling_shape, scale_dequantized_shape)[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
Moduleinstance 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
Moduleinstance 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
Moduleinstance 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:
TensorNote
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance 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
Moduleinstance 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
Noneare 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,prefixandkeep_varsin order. However, this is being deprecated and keyword arguments will be enforced in future releases.Warning
Please avoid the use of argument
destinationas 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
OrderedDictwill 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
Tensors 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']