Expand description
§API document of rstsr-core
rstsr-core is the core of RSTSR series:
- It defines data structure and some traits (interface) of tensor, storage, device.
- It realizes two basic devices:
DeviceCpuSerialandDeviceFaer, sorstsr-corealone is a functional tensor toolkit library.
If you are more aware of matmul efficiency, or by other considerations (we will try to implement BLAS and Lapack features in future), you may find DeviceOpenBLAS in rstsr-openblas helpful. We hope to implement more devices in future.
§User document
User document refers to readthedocs. This document is still in construction.
§Cheat sheet
For NumPy/SciPy users, the rstsr facade crate ships a cheat sheet mapping common operations to their RSTSR equivalents:
- the core operations page — printing and layout, creation, indexing, manipulation, operators, reductions, sorting;
- the linear algebra page — the faer-backed
rt::linalgfamily.
Each row is verified by an integration test (rstsr/tests/cheatsheet_*.rs) and by a NumPy/SciPy parity script; the authoring conventions live in the skill api-cheatsheet-conventions.
§API specifications
API specifications is provided for summary of important identifiers (structs, traits and functions) in rstsr-core.
Currently, more detailed documentation for each identifiers are still constructing.
We also provide fulfillment for Array API standard. This fulfillment check shows how much functionalities we have achieved to be a basic tensor (array) library.
For NumPy users, in this meantime, fulfillment for Array API standard shows the similar parts of RSTSR and NumPy; and these parts in API specifications shows the difference between RSTSR and NumPy:
- Tensor Structure and Ownership
- RSTSR Specific Identifiers
- Storage-dependent manipulation
- Developer Area
§Variable naming convention
§Abbreviations of type annotations
| Abbreviation | Meaning |
|---|---|
TR | Tensor type (struct TensorBase) |
T | Data type (can be f64, Complex<f32>, etc) |
B | Backend (device) type (applies DeviceAPI) |
D | Dimensional (applies DimAPI) |
S | Storage (struct storage::exports::Storage) |
R | Data with lifetime and mutability (applies DataCloneAPI) |
C | Content (usually Vec<T> for CPU devices) |
§Variable or Names
| Rule | Convention |
|---|---|
suffix API | Traits. To avoid naming collision with structs or other crates. Example: DeviceAPI, AsArrayAPI |
suffix _f | Fallible functions. Those functions pairs with a function that panics when error. Example: zeros_f, sin_f, reshape_f |
prefix ext_ | Functions that fulfill the Array API mixed-dtype promotion contract: the operands may have different data types, and the result is computed in their promoted common data type (the same rule as NumPy). The same-dtype functions instead require matching operand data types. Example: ext_add, ext_matmul, ext_vecdot, ext_outer |
prefix to_ or no prefix (manipulation functions) | Ensures that input is reference. Example: reshape, transpose, to_dim |
prefix into_ (some manipulation functions) | Only changes layout, and does not change data with its lifetime and mutability. Example: into_broadcast, into_transpose, into_dyn |
prefix into_ output is always Tensor (some manipulation functions) | Give owned tensor. This special case will occur when there is possiblity to generate a new tensor by manipulation function. For these cases, prefix to_ and change_ will give output TensorCow, prefix into_ will give Tensor. Example: into_shape, into_layout |
prefix change_ output is always TensorCow (some manipulation functions) | Give copy-on-write tensor by consuming input. This special case will occur when there is possiblity to generate a new tensor by manipulation function. Example: change_shape, change_layout |
type annotation Args | Input tuple type as overloadable parameters. Example: zeros, asarray |
type annotation Inp | Additional annotation that rust requires for type deduction. Example: zeros, asarray |
Re-exports§
pub use tensorbase::Tensor;pub use tensorbase::TensorAny;pub use tensorbase::TensorArc;pub use tensorbase::TensorBase;pub use tensorbase::TensorCow;pub use tensorbase::TensorMut;pub use tensorbase::TensorRef;pub use tensorbase::TensorReference;pub use tensorbase::TensorView;pub use tensorbase::TensorViewMut;
Modules§
- api_
specification - API Specification of crate
rstsr-core - array_
api_ standard - Array API standard Fulfillment
- dev_
utilities 🔒 - device_
cpu_ serial - Backend for CPU, serial only.
- device_
faer - Backend for CPU, some using rayon for parallel, but matmul and linalg implemented by faer.
- feature_
rayon - This module contains some features for rayon (parallel).
- format
- Tensor formatting:
DisplayandDebugimplementations for tensor types. - operators
- Operations on tensors.
- order_
semantics - Device default orders:
RowMajorandColMajor - prelude
- User-facing prelude of rstsr-core.
- prelude_
dev - Developer prelude of rstsr-core: convenience re-exports for writing
device implementations, operators, and tests against rstsr-core internals
(core/alloc utilities, macro tools, and the exports of internal crates).
User code should prefer
crate::preludeinstead. - storage
- Basic storage type and trait definitions.
- tensor
- Tensor functions organized by category: creation, indexing, manipulation, element-wise operators, reduction, and linalg, plus ownership, device, and external-type conversions.
- tensorbase
- Fundamental tensor types:
TensorBaseand the ownership aliases specialized from it (Tensor,TensorView,TensorMut,TensorCow,TensorArc), plus the fully generic aliasTensorAny.
Macros§
- allclose
- tensor_
from_ nested - Create a tensor from a nested array literal (for development purposes).