API Reference

Abovo: A C++ neural network engine with Python bindings for educational performance optimization.

class abovo.ActivationType(*values)[source]

Bases: IntEnum

LEAKY_RELU = 1
RELU = 0
SIGMOID = 2
SOFTMAX = 3
class abovo.DenseLayer(spec=None, wraps=None, name=None, spec_set=None, parent=None, _spec_state=None, _new_name='', _new_parent=None, _spec_as_instance=False, _eat_self=None, unsafe=False, **kwargs)[source]

Bases: DenseLayerMock

A fully connected neural network layer with optional quantization and activation.

Parameters:
  • input_size (int) – Number of input features.

  • output_size (int) – Number of output features.

  • activation (ActivationType) – Activation function to apply.

dequantize()[source]

Dequantizes the layer weights.

forward(input)[source]

Performs a forward pass through the layer.

Return type:

Matrix

is_quantized()[source]

Returns whether the layer is currently quantized.

Return type:

bool

print()[source]

Prints the layer’s weights and configuration.

quantize()[source]

Quantizes the layer weights (useful for efficient inference).

class abovo.LossType(*values)[source]

Bases: IntEnum

CROSS_ENTROPY = 1
MSE = 0
class abovo.MatMulType(*values)[source]

Bases: IntEnum

BLOCKED = 1
NAIVE = 0
SIMD = 2
SIMD_MT = 3
class abovo.Matrix(spec=None, wraps=None, name=None, spec_set=None, parent=None, _spec_state=None, _new_name='', _new_parent=None, _spec_as_instance=False, _eat_self=None, unsafe=False, **kwargs)[source]

Bases: MatrixMock

A 2D matrix supporting basic operations like transpose, min/max lookup, and element access.

Parameters:
  • rows (int) – Number of rows.

  • cols (int) – Number of columns.

get_cols()[source]

Returns the number of columns in the matrix.

Return type:

int

get_max()[source]

Returns the maximum value in the matrix.

Return type:

float

get_min()[source]

Returns the minimum value in the matrix.

Return type:

float

get_rows()[source]

Returns the number of rows in the matrix.

Return type:

int

print()[source]

Prints the matrix to stdout.

transpose()[source]

Returns a new matrix that is the transpose of this one.

Return type:

Matrix

class abovo.Sequential(spec=None, wraps=None, name=None, spec_set=None, parent=None, _spec_state=None, _new_name='', _new_parent=None, _spec_as_instance=False, _eat_self=None, unsafe=False, **kwargs)[source]

Bases: SequentialMock

A sequential model for stacking layers and training.

add(layer)[source]

Add a DenseLayer to the model.

forward(X)[source]

Perform a forward pass.

train(...)[source]

Train the model with given parameters.

evaluate(...)[source]

Evaluate model accuracy.

quantize_all()[source]

Quantize all layers.

dequantize_all()[source]

Revert quantization.

enable_qat()[source]

Enable quantization-aware training.

enable_adam(...)[source]

Use Adam optimizer.

add(layer)[source]

Adds a new DenseLayer to the model.

dequantize_all()[source]

Dequantizes all layers.

enable_adam(enable=True, beta1=0.9, beta2=0.999, epsilon=1e-08)[source]

Enables Adam optimizer with given hyperparameters.

Parameters:
  • enable (bool) – Whether to use Adam.

  • beta1 (float) – Exponential decay rate for 1st moment.

  • beta2 (float) – Exponential decay rate for 2nd moment.

  • epsilon (float) – Small value to avoid division by zero.

enable_qat()[source]

Enables quantization-aware training.

evaluate(X, y)[source]

Evaluates model performance on test data.

forward(X)[source]

Feeds input X through the model and returns the output.

Return type:

Matrix

print()[source]

Prints the model structure and parameters.

quantize_all(per_channel=True)[source]

Quantizes all layers in the model.

train(X, y, epochs, batch_size, learning_rate, loss_type=LossType.MSE)[source]

Trains the model on data using gradient descent.

Parameters:
  • X (Matrix) – Input data.

  • y (Matrix) – Target labels.

  • epochs (int) – Number of training epochs.

  • batch_size (int) – Batch size.

  • learning_rate (float) – Learning rate.

  • loss_type (LossType) – Loss function to use.

Matrix

class abovo.Matrix(spec=None, wraps=None, name=None, spec_set=None, parent=None, _spec_state=None, _new_name='', _new_parent=None, _spec_as_instance=False, _eat_self=None, unsafe=False, **kwargs)[source]

Bases: MatrixMock

A 2D matrix supporting basic operations like transpose, min/max lookup, and element access.

Parameters:
  • rows (int) – Number of rows.

  • cols (int) – Number of columns.

get_cols()[source]

Returns the number of columns in the matrix.

Return type:

int

get_max()[source]

Returns the maximum value in the matrix.

Return type:

float

get_min()[source]

Returns the minimum value in the matrix.

Return type:

float

get_rows()[source]

Returns the number of rows in the matrix.

Return type:

int

print()[source]

Prints the matrix to stdout.

transpose()[source]

Returns a new matrix that is the transpose of this one.

Return type:

Matrix

DenseLayer

class abovo.DenseLayer(spec=None, wraps=None, name=None, spec_set=None, parent=None, _spec_state=None, _new_name='', _new_parent=None, _spec_as_instance=False, _eat_self=None, unsafe=False, **kwargs)[source]

Bases: DenseLayerMock

A fully connected neural network layer with optional quantization and activation.

Parameters:
  • input_size (int) – Number of input features.

  • output_size (int) – Number of output features.

  • activation (ActivationType) – Activation function to apply.

dequantize()[source]

Dequantizes the layer weights.

forward(input)[source]

Performs a forward pass through the layer.

Return type:

Matrix

is_quantized()[source]

Returns whether the layer is currently quantized.

Return type:

bool

print()[source]

Prints the layer’s weights and configuration.

quantize()[source]

Quantizes the layer weights (useful for efficient inference).

Sequential

class abovo.Sequential(spec=None, wraps=None, name=None, spec_set=None, parent=None, _spec_state=None, _new_name='', _new_parent=None, _spec_as_instance=False, _eat_self=None, unsafe=False, **kwargs)[source]

Bases: SequentialMock

A sequential model for stacking layers and training.

add(layer)[source]

Add a DenseLayer to the model.

forward(X)[source]

Perform a forward pass.

train(...)[source]

Train the model with given parameters.

evaluate(...)[source]

Evaluate model accuracy.

quantize_all()[source]

Quantize all layers.

dequantize_all()[source]

Revert quantization.

enable_qat()[source]

Enable quantization-aware training.

enable_adam(...)[source]

Use Adam optimizer.

add(layer)[source]

Adds a new DenseLayer to the model.

dequantize_all()[source]

Dequantizes all layers.

enable_adam(enable=True, beta1=0.9, beta2=0.999, epsilon=1e-08)[source]

Enables Adam optimizer with given hyperparameters.

Parameters:
  • enable (bool) – Whether to use Adam.

  • beta1 (float) – Exponential decay rate for 1st moment.

  • beta2 (float) – Exponential decay rate for 2nd moment.

  • epsilon (float) – Small value to avoid division by zero.

enable_qat()[source]

Enables quantization-aware training.

evaluate(X, y)[source]

Evaluates model performance on test data.

forward(X)[source]

Feeds input X through the model and returns the output.

Return type:

Matrix

print()[source]

Prints the model structure and parameters.

quantize_all(per_channel=True)[source]

Quantizes all layers in the model.

train(X, y, epochs, batch_size, learning_rate, loss_type=LossType.MSE)[source]

Trains the model on data using gradient descent.

Parameters:
  • X (Matrix) – Input data.

  • y (Matrix) – Target labels.

  • epochs (int) – Number of training epochs.

  • batch_size (int) – Batch size.

  • learning_rate (float) – Learning rate.

  • loss_type (LossType) – Loss function to use.

Enums

abovo.LossType Enum for loss functions[source]
  • MSE = 0

  • CROSS_ENTROPY = 1

abovo.ActivationType Enum for activation functions[source]
  • RELU = 0

  • LEAKY_RELU = 1

  • SIGMOID = 2

  • SOFTMAX = 3

abovo.MatMulType Enum for matrix multiplication implementations[source]
  • NAIVE = 0

  • BLOCKED = 1

  • SIMD = 2

  • SIMD_MT = 3