afe.ir.transform.requantization_fusion

Attributes

AttributesMutatorCallable

RequantizationCheckCallable

Classes

FuseRequantizations

A compiler pass that does fusion on RequantizeOp nodes, such as the ones

Functions

convert_to_arith_folded_requantization(...)

Convert the given requantization to an ArithFoldedRequantization, if possible.

can_convert_to_arith_folded_requantization(→ bool)

Decide whether the given requantization can be converted to an ArithFoldedRequantization.

Module Contents

afe.ir.transform.requantization_fusion.convert_to_arith_folded_requantization(requant: ml_kernels.requantization.BaseRequantization[numpy.ndarray]) ml_kernels.requantization.ArithFoldedRequantization[numpy.ndarray] | None[source]

Convert the given requantization to an ArithFoldedRequantization, if possible. Only convert if the ArithFoldedRequantization is exactly equivalent, including rounding and saturation behavior.

Parameters:

requant – Requantization to convert

Returns:

An ArithFoldedRequantization that is equivalent to the input. None if there is no equivalent ArithFoldedRequantization.

afe.ir.transform.requantization_fusion.can_convert_to_arith_folded_requantization(requant: ml_kernels.requantization.BaseRequantization[numpy.ndarray]) bool[source]

Decide whether the given requantization can be converted to an ArithFoldedRequantization.

afe.ir.transform.requantization_fusion.AttributesMutatorCallable[source]
afe.ir.transform.requantization_fusion.RequantizationCheckCallable[source]
class afe.ir.transform.requantization_fusion.FuseRequantizations[source]

A compiler pass that does fusion on RequantizeOp nodes, such as the ones that are inserted during quantization. RequantizeOp nodes are fused into the preceding node where possible.