We present MiniTensor, an open source tensor operations library that focuses on minimalism, correctness, and performance. MiniTensor exposes a familiar PyTorch-like Python API while it executes performance critical code in a Rust engine. The core supports dense $n$ dimensional tensors, broadcasting, reductions, matrix multiplication, reverse mode automatic differentiation, a compact set of neural network layers, and standard optimizers. In this paper, we describe the design of MiniTensor's architecture, including its efficient memory management, dynamic computation graph for gradients, and integration with Python via PyO3. We also compare the install footprint with PyTorch and TensorFlow to demonstrate that MiniTensor achieves a package size of only a few megabytes, several orders of magnitude smaller than mainstream frameworks, while preserving the essentials needed for research and development on CPUs. The repository can be found at https://github.com/neuralsorcerer/minitensor
翻译:本文介绍MiniTensor,一个专注于简洁性、正确性与性能的开源张量运算库。MiniTensor提供类似PyTorch的Python API接口,同时在Rust引擎中执行性能关键代码。其核心功能支持稠密$n$维张量、广播运算、归约操作、矩阵乘法、反向模式自动微分、紧凑的神经网络层集合以及标准优化器。本文详细阐述了MiniTensor的架构设计,包括其高效内存管理机制、用于梯度计算的动态计算图,以及通过PyO3实现的Python集成。我们进一步将安装体积与PyTorch和TensorFlow进行对比,证明MiniTensor的软件包大小仅为数兆字节,比主流框架小数个数量级,同时完整保留了CPU上进行研发所需的核心功能。项目仓库地址为https://github.com/neuralsorcerer/minitensor