Skip to main content

prism_tensor/
lib.rs

1//! Prism standard-library tensor-compute sub-crate.
2//!
3//! `prism-tensor` realizes the tensor Layer-3 of the standard library
4//! named in [Wiki ADR-031][09-adr-031]: declares `TensorAxis` and
5//! `ActivationAxis` through the [`axis!`][09-adr-030] SDK macro and
6//! supplies parametric CPU integer-precision reference impls
7//! preserving bit-determinism per fixed `(HostTypes, HostBounds,
8//! AxisTuple)` selection (per ADR-030's per-axis
9//! substitution-determinism note).
10//!
11//! ## Scope
12//!
13//! - **`TensorAxis`** — fixed-shape matmul. Parametric:
14//!   [`CpuI8MatmulSquare<DIM>`] for `DIM × DIM` `i8` × `i8` → `i16`
15//!   matrices with `DIM ≤ MAX_TENSOR_DIM` (16). Aliases:
16//!   [`CpuI8Tensor4x4Matmul`], [`CpuI8Tensor8x8Matmul`],
17//!   [`CpuI8Tensor16x16Matmul`].
18//! - **`ActivationAxis`** — element-wise nonlinearity. Parametric:
19//!   [`CpuI8VectorActivation<N>`] for length-`N` `i8` vectors with
20//!   `N ≤ MAX_ACTIVATION_LEN` (256). Aliases:
21//!   [`CpuI8VectorActivation16`], [`CpuI8VectorActivation32`],
22//!   [`CpuI8VectorActivation64`], [`CpuI8VectorActivation128`],
23//!   [`CpuI8VectorActivation256`].
24//!
25//! ## ConstrainedTypeShape declarations
26//!
27//! Per ADR-031's `Tensor<Element, Shape>` shape commitment:
28//!
29//! - **[`MatrixShape<ROWS, COLS, ELEM_BYTES>`]** — rank-2 tensor shape.
30//! - **[`VectorShape<N, ELEM_BYTES>`]** — rank-1 tensor shape.
31//!
32//! Higher-rank tensors compose through `partition_product!` per
33//! ADR-033/044; the axis layer fixes the atom shape.
34//!
35//! ## Closure under uor-foundation (ADR-013)
36//!
37//! Every axis trait declared here has
38//! `::uor_foundation::pipeline::AxisExtension` as a supertrait;
39//! parametric impls hand-write their `AxisExtension` impl since the
40//! `axis!`-emitted companion macro takes `:ident`.
41//!
42//! ## See also
43//!
44//! - [Wiki: 09 Architecture Decisions § ADR-030 — `axis!` SDK macro][09-adr-030]
45//! - [Wiki: 09 Architecture Decisions § ADR-031 — `prism` is the standard library][09-adr-031]
46//!
47//! [09-adr-030]: https://github.com/UOR-Foundation/UOR-Framework/wiki/09-Architecture-Decisions
48//! [09-adr-031]: https://github.com/UOR-Foundation/UOR-Framework/wiki/09-Architecture-Decisions
49
50#![no_std]
51#![cfg_attr(docsrs, feature(doc_cfg))]
52
53pub mod activation;
54pub mod tensor;
55pub mod verbs;
56
57pub use activation::{
58    ActivationAxis, CpuI8VectorActivation, CpuI8VectorActivation128, CpuI8VectorActivation16,
59    CpuI8VectorActivation256, CpuI8VectorActivation32, CpuI8VectorActivation64, MAX_ACTIVATION_LEN,
60};
61pub use tensor::{
62    CpuI8MatmulSquare, CpuI8Tensor16x16Matmul, CpuI8Tensor4x4Matmul, CpuI8Tensor8x8Matmul,
63    MatrixShape, TensorAxis, VectorShape, MAX_TENSOR_DIM,
64};
65
66/// Wiki ADR-031 standard-library version banner.
67pub const STANDARD_LIBRARY_VERSION: &str = env!("CARGO_PKG_VERSION");