Skip to main content

ruda_tensor/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2#![warn(missing_docs)]
3#![cfg_attr(docsrs, feature(doc_cfg))]
4
5//! This library provides the core types that define how Ruda tensor data is represented, stored, and interpreted.
6
7#[macro_use]
8extern crate derive_new;
9
10extern crate alloc;
11
12use ruda_core::tensor::data;
13pub use data::*;
14
15pub use ruda_core::tensor::distribution;
16pub use distribution::*;
17pub use ruda_core::tensor::element;
18pub use ruda_core::make_element;
19pub use element::*;
20
21pub mod device;
22pub mod primitive;
23pub mod ops;
24pub mod collective;
25/// Native frozen AWQ projections and their packed-weight input derivatives.
26pub mod frozen_awq;
27/// Original RUDA byte-packed NF4 frozen projections and input derivatives.
28pub mod frozen_nf4;
29/// Native selected router weights and complete local MoE training operations.
30pub mod moe;
31/// Original native expert-parallel dispatch/receive/combine contracts.
32pub mod moe_exchange;
33#[cfg(feature = "distributed")]
34pub mod distributed;
35
36/// [`Backend`] trait and required types.
37pub mod backend;
38pub use backend::*;
39
40/// Backend tensor primitives and operations.
41pub mod tensor;
42
43/// Tensor operation graphs and backend resource handles.
44#[cfg(feature = "graph")]
45pub mod graph;
46
47// Re-exported types
48pub use ruda_core::reader::*; // Useful so that backends don't have to add `ruda_core` as a dependency.
49pub use ruda_core::bytes::{AllocationProperty, Bytes};
50pub use ruda_core::device_handle::DeviceHandle;
51pub use ruda_core::stream_id::StreamId;
52pub use ruda_core::tensor::{BoolDType, BoolStore, DType, FloatDType, IntDType};
53pub use half::{bf16, f16};
54
55/// Shape definition.
56pub mod shape {
57    pub use ruda_core::tensor::shape::*;
58}
59pub use shape::*;
60
61/// Slice utilities.
62pub mod slice {
63    pub use ruda_core::tensor::{s, slice::*};
64}
65pub use slice::*;
66
67/// Indexing utilities.
68pub mod indexing {
69    pub use ruda_core::tensor::indexing::*;
70}
71pub use indexing::*;
72
73/// Quantization data representation.
74pub mod quantization {
75    pub use crate::tensor::quantization::*;
76    pub use ruda_core::tensor::quantization::{
77        BlockSize, QuantLevel, QuantMode, QuantParam, QuantPropagation, QuantScheme, QuantStore,
78        QuantValue, QuantizedBytes,
79    };
80}
81
82/// Convenience macro to link to the `ruda-tensor` API docs.
83///
84/// Usage:
85/// ```rust,ignore
86/// # use ruda_tensor::doc_tensor;
87/// doc_tensor!();        // Links to `Tensor` struct
88/// doc_tensor!("zeros"); // Links to `Tensor::zeros` method
89/// ```
90#[macro_export]
91macro_rules! doc_tensor {
92    () => {
93        "[`Tensor`](crate::api::Tensor)"
94    };
95
96    ($method:literal) => {
97        concat!(
98            "[`Tensor::",
99            $method,
100            "`](crate::api::Tensor::",
101            $method,
102            ")"
103        )
104    };
105}
106
107/// Public tensor API built on the shared backend contracts and primitives.
108#[cfg(feature = "api")]
109pub mod api;