bitorch_engine.layers.qlinear.binary.binary_implementation.BinaryLinearImplementationMixin

class bitorch_engine.layers.qlinear.binary.binary_implementation.BinaryLinearImplementationMixin(*args: Any, **kwargs: Any)[source]

A mixin class for binary linear layer implementations that extends the quantized linear layer implementation mixin (QLinearImplementationMixin). This class provides specialized methods to determine if a layer can be cloned based on the quantization functions used for inputs and weights.

The class supports binary quantization functions such as Sign and SwishSign for both inputs and weights. It leverages the can_clone class method to check if the specified quantization functions are supported for cloning a layer according to a given recipe.

None specified explicitly, but inherits from QLinearImplementationMixin and ABC.
can_clone()[source]

Class method to determine if a layer can be cloned based on its quantization functions for inputs and weights.

Methods

can_clone

Determines if a layer can be cloned based on its quantization functions for inputs and weights.

classmethod can_clone(recipe: LayerRecipe) Tuple[bool, str][source]

Determines if a layer can be cloned based on its quantization functions for inputs and weights.

This method checks if the layer’s input and weight quantization functions are among the supported binary quantization functions. If either quantization function is not supported, the method returns False along with a message indicating which quantization function is not supported.

Parameters:

recipe (LayerRecipe) – An object containing the configuration and parameters for the layer to be cloned.

Returns:

A tuple containing a boolean indicating whether the layer can be cloned and a string message. If the layer can be cloned, the boolean is True, and the string is empty. If the layer cannot be cloned due to unsupported quantization functions, the boolean is False, and the string contains a message specifying the unsupported quantization function.

Return type:

Tuple[bool, str]