Crates.io | tensor_optim |
lib.rs | tensor_optim |
version | 0.1.0 |
created_at | 2025-08-23 00:29:05.832426+00 |
updated_at | 2025-08-23 00:29:05.832426+00 |
description | A tiny autodiff + tensor engine that doesn't compromise on flexibility |
homepage | |
repository | https://github.com/bobbothe2nd/tensor_optim |
max_upload_size | |
id | 1807084 |
size | 76,696 |
tensor_optim
A no-std compatible, zero-unsafe public API Rust library providing foundational tensor abstractions optimized for embedded and performance-critical machine learning workloads.
no_std
by default; dynamic allocation disabled by default.alloc
feature enables dynamically sized, heap-allocated tensors (DynTensor
).tensor_optim
offers three primary tensor types representing different ownership and allocation models:
Type | Ownership | Allocation | Use Case |
---|---|---|---|
RefTensor * |
Borrowed mutable slices | None (zero-copy views) | Temporary tensor views, zero-allocation borrowing |
ArrTensor |
Fully owned, fixed size | Stack | Fixed-shape tensors in embedded or realtime systems |
DynTensor |
Fully owned, dynamic size | Heap (behind alloc flag) |
Flexible tensor sizes with shared ownership via Arc |
[*] RefTensor
is a special tensor type that doesn't own anything and lacks capability like matrix multiplication and transposition.
unsafe
code is exposed or required by users.RefTensor
to create zero-copy views into existing data without allocation or ownership transfer.ArrTensor
for fixed-size tensors with deterministic, stack-allocated memory layout.alloc
feature and use DynTensor
for dynamically sized tensors requiring heap allocation and shared ownership.All tensor types support (with the exception of RefTensor
):
Add
, Sub
, Mul
, Div
and assignment variants).Index
and IndexMut
for direct element access.... and every tensor is row-major.
alloc
(disabled by default): Enables DynTensor
and dynamic heap allocation. Requires allocator support.Add this to your Cargo.toml
:
[dependencies]
tensor_optim = "0.1"
# Enable dynamic tensors if your environment supports alloc:
# tensor_optim = { version = "0.1", features = ["alloc"] }
or just run this command: cargo add tensor_optim
.
#![no_std]
Supporttensor_optim
compiles without the Rust standard library, always.DynTensor
), enable the alloc
feature.clippy
lint enforcement and fulll documentation coverage.Licensed under an MIT license.
tensor_optim
is a minimal, safe, and high-performance Rust tensor library that empowers embedded and performance-critical ML applications without sacrificing safety or compatibility. Its carefully designed ownership models and optimized core kernels provide the solid foundation needed for next-generation Rust ML frameworks.