bitorch_engine.layers.qlinear.qlinear_implementation.QLinearImplementationMixin

class bitorch_engine.layers.qlinear.qlinear_implementation.QLinearImplementationMixin(*args: Any, **kwargs: Any)[source]

A mixin class for QLinear layer implementations that provides common utility functions and checks specific to quantized linear layers. This mixin extends CustomImplementationMixin and implements the Abstract Base Class (ABC) to ensure that subclasses provide implementations for abstract methods defined in parent classes.

The class provides a method to check if a given layer configuration can be cloned based on specific constraints related to quantized linear layers.

Methods

can_clone

Determines if a QLinear layer described by the given recipe can be cloned.

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

Determines if a QLinear layer described by the given recipe can be cloned.

The method checks if the layer configuration meets certain criteria necessary for cloning a quantized linear layer. Specifically, it checks if the layer includes bias, and if the number of input features is divisible by 32, as these are current limitations for cloning such layers.

Parameters:

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

Returns:

A tuple containing a boolean and a string. The boolean

indicates whether the layer can be cloned (True if it can, False otherwise). The string provides a message explaining why the layer cannot be cloned if the boolean is False.

Return type:

Tuple[bool, str]