VTL is a pure-V tensor library for numerical computing and machine learning — n-dimensional arrays, autograd, linear algebra via VSL, and a full neural network module.
vlang.io | Docs | Tutorials | ML Roadmap | Contributing | VSL
import vtl
t := vtl.from_array([1.0, 2, 3, 4], [2, 2])!
t.get([1, 1])
// 4.0- Tensors — create, slice, reshape, transpose, broadcast, map/reduce
- Autograd — reverse-mode AD; arbitrary computational graphs
- Neural networks —
SequentialAPI; Linear, Conv2D, LSTM, Attention, … - Losses & optimizers — MSE, BCE, CrossEntropy, Huber; Adam, AdamW, SGD, …
- Linear algebra — VSL-backed matmul, solve, QR, LU, Cholesky, SVD, pinv
- Hardware — zero-copy
Tensor.datafor C libs; optional CUDA paths
import vtl
import vtl.autograd
import vtl.nn.layers
import vtl.nn.models
import vtl.nn.optimizers
mut ctx := autograd.ctx[f64]()
mut model := models.sequential_from_ctx[f64](ctx)
model.input([784])
model.linear(256)
model.linear(10)
input_tensor := vtl.zeros[f64]([64, 784])
mut x := ctx.variable(input_tensor)
y_pred := model.forward(x)!
target := vtl.zeros[f64]([64, 10])
mut loss_val := model.loss(y_pred, target)!
loss_val.backprop()!
mut opt := optimizers.adam_optimizer[f64](optimizers.AdamOptimizerConfig{
learning_rate: 0.001
})
opt.build_params(model.info.layers)
opt.update()!| Module | Purpose |
|---|---|
vtl |
Core Tensor[T]; creation, slicing, broadcasting |
vtl.autograd |
Context, Variable, gates, backprop() |
vtl.la |
Linear algebra (wraps VSL) |
vtl.nn |
Layers, losses, optimizers |
vtl.nn.models |
Sequential model API |
vtl.nn.internal |
Weight init (Kaiming, Xavier) |
vtl.nn.gates |
Autograd gate implementations |
VTL uses VSL for linear algebra. The core vtl
module works without optional system BLAS/LAPACK, but LA features need VSL.
Follow VSL install instructions, then:
v install vtlv test ~/.vmodules/vtlSee DEV_LIGHTWEIGHT.md for memory-safe subsets in CI.
| Tutorial | Topic |
|---|---|
| TUTORIAL_FIRST_STEPS.md | Tensor creation, indexing, slicing |
| TUTORIAL_MAP_REDUCE.md | map / nmap and reductions |
| TUTORIAL_AUTOGRAD.md | Variable, gates, backprop |
| TUTORIAL_REDUCTIONS.md | argmax / argmin / cumsum |
| TUTORIAL_NEURAL_NETWORKS.md | Layers, losses, Sequential |
| TUTORIAL_OPTIMIZERS.md | Adam, AdamW, RMSProp, schedulers |
| TUTORIAL_LINEAR_ALGEBRA.md | LA basics via VSL |
| TUTORIAL_ADVANCED_LA.md | QR, LU, Cholesky, pinv |
| TUTORIAL_BROADCASTING.md | Broadcasting rules |
| TUTORIAL_SLICING.md | Slicing and views |
Full index: docs/README.md.
Originally based on work by christopherzimmerman. The core was reimplemented while keeping that lineage and inspiration.
Made with contributors-img.

