Skip to main content

Module numpy_converter

Module numpy_converter 

Source
Expand description

NumPy to Trueno conversion module (BATUTA-008)

Converts Python NumPy operations to Rust Trueno operations with automatic backend selection via MoE routing.

§Conversion Strategy

NumPy operations are mapped to equivalent Trueno operations:

  • np.array(...)Vector::from_slice(...) or Matrix::from_slice(...)
  • np.add(a, b)a.add(&b)
  • np.dot(a, b)a.dot(&b) or a.matmul(&b)
  • np.sum(a)a.sum()
  • Element-wise ops automatically use MoE routing

§Example

# Python NumPy code
import numpy as np
a = np.array([1.0, 2.0, 3.0])
b = np.array([4.0, 5.0, 6.0])
c = np.add(a, b)

Converts to:

use trueno::Vector;
let a = Vector::from_slice(&[1.0, 2.0, 3.0]);
let b = Vector::from_slice(&[4.0, 5.0, 6.0]);
let c = a.add(&b).unwrap();

Structs§

NumPyConverter
NumPy to Trueno converter
TruenoOp
Trueno equivalent operation

Enums§

NumPyOp
NumPy operation types