Skip to main content
`Ctrl`+`K`

# brevitas.core.stats package

## Submodules

## brevitas.core.stats.stats_op module

class brevitas.core.stats.stats_op.AbsAve(stats_reduce_dim=None)

  Bases: `Module`

  forward(x)

    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)

  Bases: `Module`

  forward(x)

    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)

  Bases: `Module`

  forward(x)

    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)

  Bases: `Module`

  forward(x)

    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)

  Bases: `Module`

  forward(x)

    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)

  Bases: `Module`

  forward(x)

    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)

  Bases: `Module`

  forward(x)

    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.

  optimize(x)
  parameter_search(xl, x)

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)

  Bases: `Module`

  forward(x)

    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.

  optimize(x)
  parameter_search(xl, x)

class brevitas.core.stats.stats_op.KLMinimizerThreshold(signed, bit_width_impl, num_bins=1001, smoothing_eps=0.0001)

  Bases: `Module`

  Based on: apache/incubator-mxnet

  forward(x)

    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.

  smooth_normalize_distribution(p, eps)

class brevitas.core.stats.stats_op.L1Norm(stats_reduce_dim=None)

  Bases: `Module`

  ScriptModule implementation to collect per-channel L1 normalization stats for weight normalization-based quantization.

  forward(x)

    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)

  Bases: `Module`

  ScriptModule implementation to collect per-channel L2 normalization stats for weight normalization-based quantization.

  forward(x)

    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)

  Bases: `Module`

  evaluate_loss(x, candidate)
  forward(x)

    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.

  mse_fib_search(xl, xr, x)
  mse_grid_search(xl, x)
  mse_loss_fn(x, quant_value)
  mse_search(x)

class brevitas.core.stats.stats_op.MeanLearnedSigmaStd(sigma, stats_output_shape, stats_reduce_dim=None, std_dev_epsilon=1e-08, dtype=None, device=None)

  Bases: `Module`

  forward(x)

    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)

  Bases: `Module`

  forward(x)

    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)

  Bases: `Module`

  forward(x)

    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)

  Bases: `Module`

  forward(x)

    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)

  Bases: `Module`

  forward(x)

    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)

  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

brevitas.core.stats.stats_op.shrink_lp_op(x, beta, lp_norm)
  Return type:

    `Tensor`

## brevitas.core.stats.stats_wrapper module

## brevitas.core.stats.view_wrapper module

## Module contents