Expand description
Tensor types and numeric primitives for the yscv framework.
§Tensor type
Tensor is the core n-dimensional array. It stores contiguous, 64-byte
aligned f32 data and carries its own shape and strides. FP16 and BF16
storage is supported via DType and the conversion helpers
Tensor::to_dtype, Tensor::from_f16, and Tensor::from_bf16.
§Supported dtypes
| Variant | Backing store | Notes |
|---|---|---|
F32 | AlignedVec<f32> | Default, SIMD-accelerated ops |
F16 | AlignedVec<u16> | IEEE 754 half-precision bit patterns |
BF16 | AlignedVec<u16> | Brain floating-point bit patterns |
Arithmetic operations require F32. Convert with Tensor::to_dtype
before performing math on F16/BF16 tensors.
§Broadcasting
Binary operations (add, sub, mul, div, pow, etc.) follow
NumPy-style broadcasting rules:
- Shapes are right-aligned. Missing leading dimensions are treated as 1.
- Dimensions of size 1 are stretched to match the other operand.
- If dimensions differ and neither is 1, the operation returns
TensorError::BroadcastIncompatible.
Example: [3, 1, 5] + [4, 5] broadcasts to [3, 4, 5].
Structs§
- Aligned
Vec - A Vec-like container that guarantees 32-byte alignment for the data pointer.
- Tensor
- A compact, contiguous multi-dtype tensor representation.
Enums§
- DType
- Element data type for tensor storage.
- Device
- Logical device where a tensor resides.
- Tensor
Error - Errors returned by tensor construction and math operations.