coreai_opt.quantization.spec.RangeCalculatorBase

class coreai_opt.quantization.spec.RangeCalculatorBase(granularity, **kwargs)[source]

Bases: ClassRegistryMixin, Module

Base class and registry for classes used to compute the range of a given tensor.

Parameters:

granularity (QuantizationGranularity)

__init__(granularity, **kwargs)[source]
Parameters:

granularity (QuantizationGranularity)

Methods

forward(x)

Compute range statistics on an input and return the min/max bounds.

get_class(key)

list_registry_keys()

list_registry_values()

register(key)

Register a virtual subclass of an ABC.

forward(x)[source]

Compute range statistics on an input and return the min/max bounds.

Calls _generate_min_max to compute range statistics and validates that the returned min/max shapes match the original tensor number of dimensions.

Parameters:

x (torch.Tensor) – Tensor to compute range statistics upon.

Return type:

tuple[Tensor, Tensor]