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
AbsAve
AbsMax
AbsMaxAve
AbsMaxL2
AbsMinMax
AbsPercentile
HalfQuadraticOptimizerScale
HalfQuadraticOptimizerZeroPoint
KLMinimizerThreshold
L1Norm
L2Norm
MSE
MeanLearnedSigmaStd
MeanSigmaStd
NegativeMinOrZero
NegativePercentileOrZero
PercentileInterval
SignedScaleStats
UnsignedScaleStat
masked_median()
shrink_lp_op()
- 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.
- 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
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']