brevitas.core.stats package#
Submodules#
brevitas.core.stats.stats_op module#
- class brevitas.core.stats.stats_op.AbsAve(stats_reduce_dim=None)[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.stats.stats_op.AbsMax(stats_reduce_dim=None, keepdim=False)[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.stats.stats_op.AbsMaxAve(stats_reduce_dim)[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.stats.stats_op.AbsMaxL2(stats_reduce_dim)[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.stats.stats_op.AbsMinMax(stats_reduce_dim=None, keepdim=False, dtype=None, device=None)[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.stats.stats_op.AbsPercentile(high_percentile_q, stats_reduce_dim, percentile_q=None, keepdim=False)[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.stats.stats_op.HalfQuadraticOptimizerScale(proxy_module, hqo_init_op_scale, keepdim, inner_stats_input_view_shape_impl, scaling_min_val=None, stats_reduce_dim=None, int_scaling_impl=None, bit_width_impl=None, hqo_beta_scale=100000.0, hqo_kappa_scale=1.01, hqo_lp_norm_scale=0.7, hqo_iters_scale=1000)[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.stats.stats_op.HalfQuadraticOptimizerZeroPoint(proxy_module, keepdim, hqo_init_op_zp, inner_stats_input_view_shape_impl, stats_reduce_dim=None, hqo_beta_zp=1.0, hqo_kappa_zp=1.01, hqo_lp_norm_zp=0.5, hqo_iters_zp=1000)[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.stats.stats_op.KLMinimizerThreshold(signed, bit_width_impl, num_bins=1001, smoothing_eps=0.0001)[source]#
Bases:
Module
Based on: apache/incubator-mxnet
- 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.stats.stats_op.L1Norm(stats_reduce_dim=None)[source]#
Bases:
Module
ScriptModule implementation to collect per-channel L1 normalization stats for weight normalization-based quantization.
- 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.stats.stats_op.L2Norm(stats_reduce_dim=None)[source]#
Bases:
Module
ScriptModule implementation to collect per-channel L2 normalization stats for weight normalization-based quantization.
- 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.stats.stats_op.MSE(proxy_module, mse_init_op, inner_stats_input_view_shape_impl, stats_reduce_dim=None, mse_search_method='fibonacci', mse_iters=20)[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.stats.stats_op.MeanLearnedSigmaStd(sigma, stats_output_shape, stats_reduce_dim=None, std_dev_epsilon=1e-08, dtype=None, device=None)[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.stats.stats_op.MeanSigmaStd(sigma, stats_reduce_dim=None, std_dev_epsilon=1e-08, dtype=None, device=None)[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.stats.stats_op.NegativeMinOrZero(stats_reduce_dim=None, dtype=None, device=None, keepdim=False)[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.stats.stats_op.NegativePercentileOrZero(low_percentile_q, stats_reduce_dim=None, dtype=None, device=None, keepdim=False)[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.stats.stats_op.PercentileInterval(low_percentile_q, high_percentile_q, stats_reduce_dim=None, keepdim=False, dtype=None, device=None)[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.
- brevitas.core.stats.stats_op.masked_median(x, mask, dim=None, keepdim=False)[source]#
Compute the median of tensor x along dim, ignoring values where mask is False. x and mask need to be broadcastable.
- Parameters:
x (Tensor) – Tensor to compute median of.
mask (BoolTensor) – Same shape as x with True where x is valid and False where x should be masked. Mask should not be all False in any column of dimension dim to avoid NaNs from zero division.
dim (int, optional) – Dimension to take median of. Defaults to 0.
- Returns:
Same shape as x, except dimension dim reduced.
- Return type:
Tensor