bitorch_engine.layers.qlinear.binary.cpp.layer.BinaryLinearCPP
- class bitorch_engine.layers.qlinear.binary.cpp.layer.BinaryLinearCPP(input_features: int, out_features: int, device: device | None = None)[source]
A class representing the binary linear layer implemented in C++ for CPU runtime mode. Inherits from BinaryLinearBase and mixes in BinaryLinearImplementationMixin for common functionality.
This class supports creating a clone of itself from a given LayerRecipe, allowing for easy replication and modification of layer parameters.
Methods
Initializes the BinaryLinearCPP layer.
Creates a clone of this layer based on the provided LayerRecipe.
Defines the forward pass of the binary linear layer.
Generates the quantized weight matrix for this layer and optionally clears the original weight.
Prepares and initializes the model parameters for training.
Attributes
training
- __init__(input_features: int, out_features: int, device: device | None = None) None [source]
Initializes the BinaryLinearCPP layer.
- Parameters:
input_features (int) – The number of input features (divided by 8 for binary).
out_features (int) – The number of output features.
device (torch.device, optional) – The device on which to perform computations.
- classmethod create_clone_from(recipe: LayerRecipe) Any [source]
Creates a clone of this layer based on the provided LayerRecipe.
- Parameters:
recipe (LayerRecipe) – The recipe containing the parameters for the clone.
- Returns:
A new instance of this class with parameters derived from the recipe.
- Return type:
Any
- forward(x: Tensor) Tensor [source]
Defines the forward pass of the binary linear layer.
- Parameters:
x (torch.Tensor) – The input tensor.
- Returns:
The output tensor after applying the binary linear transformation.
- Return type:
torch.Tensor