Tensor Shape Annotation Library (tsalib) enables named tensor dimensions
Top 96.7% on sourcepulse
This library provides Tensor Shape Annotations (TSA) for popular deep learning frameworks like NumPy, TensorFlow, and PyTorch, enabling users to name tensor dimensions for improved code clarity and debugging. It targets researchers and engineers working with complex tensor manipulations, offering a way to manage and verify tensor shapes more intuitively.
How It Works
tsalib leverages Python's type annotations and a custom shorthand notation (TSN) to associate names with tensor dimensions. It allows users to declare dimension variables (e.g., B, C, H, W = dvs('Batch(b):32 ...')
) and use these names directly in tensor creation and shape assertions. A key feature is the warp
operator, which composes multiple shape transformations (like reshape, permute) into a single, readable line using TSN. This approach simplifies complex tensor operations and enhances code maintainability.
Quick Start & Requirements
pip install tsalib
sympy
Highlighted Details
warp
operator for composing multiple shape transformations inline.join
, alignto
, reduce_dims
, and dot
operators for tensor manipulation.Maintenance & Community
update_dim_vars_len
).Licensing & Compatibility
Limitations & Caveats
The library's last update was in May 2020, indicating potential staleness. While it mentions support for multiple backends, the warp
operator is backend-dependent, and the README does not specify which backends are currently fully maintained or tested. The license is not clearly stated, which could be a barrier for commercial adoption.
5 years ago
Inactive