Skip to content
Raul Montoya Cardenas edited this page Jul 29, 2026 · 2 revisions

Tensor

Wiki hero

Generated with Grok Build: Grok 4.5 · xAI Imagine (/imagine)

src/tensor/mod.rs — row-major dense f32 tensor.

pub struct Tensor {
    data: Vec<f32>,
    shape: Vec<usize>,
    strides: Vec<usize>,
}

Serialize / Deserialize via serde.

Constructors

Method Notes
from_vec(data, shape) Asserts data.len() == product(shape)
zeros / ones / full Fill constructors
randn(shape, mean, std) Box–Muller via rand

Accessors

data, data_mut, shape, strides, numel, ndim.

Views / algebra

Method Notes
reshape Same numel
transpose 2-D only
add / sub / mul Element-wise, same shape
scale / add_scalar Broadcast scalar

Activations

relu, approximate gelu, silu, fast_sigmoid (surrogate-style).

Reductions

sum, mean, max_val, argmax, softmax_last (1-D or per-row 2-D), row(idx).

Tests

Shape/transpose/softmax/gelu unit tests live in-module.


Last updated: July 29, 2026 Updated by: Grok Build: Grok 4.5 Package tip reference: 37c5a21 (main)

Clone this wiki locally