Skip to main content

axonml_tensor/
lib.rs

1//! N-dimensional tensor library for AxonML.
2//!
3//! Exports `Tensor<T>` (generic over Scalar types) with NumPy-style
4//! broadcasting, strided zero-copy views, CPU + CUDA GPU matmul (with GEMV
5//! fast path for m=1 decode), quantized matmul dispatch (Q4_K/Q6_K in-shader
6//! dequant via `cuda_ops`), lazy tensors with algebraic optimization, sparse
7//! COO tensors, factory functions (zeros/ones/randn/arange/linspace/eye/full),
8//! and shape/stride utilities. Re-exports `Device`, `DType`, `Error`, `Result`
9//! from `axonml-core`.
10//!
11//! Modules: `tensor`, `shape`, `creation`, `ops`, `view`, `cuda_ops`, `lazy`,
12//! `sparse`.
13//!
14//! # File
15//! `crates/axonml-tensor/src/lib.rs`
16//!
17//! # Author
18//! Andrew Jewell Sr. — AutomataNexus LLC
19//! ORCID: 0009-0005-2158-7060
20//!
21//! # Updated
22//! April 14, 2026 11:15 PM EST
23//!
24//! # Disclaimer
25//! Use at own risk. This software is provided "as is", without warranty of any
26//! kind, express or implied. The author and AutomataNexus shall not be held
27//! liable for any damages arising from the use of this software.
28
29#![cfg_attr(not(feature = "std"), no_std)]
30#![warn(missing_docs)]
31#![warn(clippy::all)]
32#![warn(clippy::pedantic)]
33// ML/tensor-specific allowances
34#![allow(clippy::cast_possible_truncation)]
35#![allow(clippy::cast_sign_loss)]
36#![allow(clippy::cast_precision_loss)]
37#![allow(clippy::cast_possible_wrap)]
38#![allow(clippy::missing_errors_doc)]
39#![allow(clippy::missing_panics_doc)]
40#![allow(clippy::must_use_candidate)]
41#![allow(clippy::module_name_repetitions)]
42#![allow(clippy::similar_names)]
43#![allow(clippy::many_single_char_names)]
44#![allow(clippy::too_many_arguments)]
45#![allow(clippy::doc_markdown)]
46#![allow(clippy::cast_lossless)]
47#![allow(clippy::needless_pass_by_value)]
48#![allow(clippy::redundant_closure_for_method_calls)]
49#![allow(clippy::uninlined_format_args)]
50#![allow(clippy::ptr_arg)]
51#![allow(clippy::return_self_not_must_use)]
52#![allow(clippy::not_unsafe_ptr_arg_deref)]
53#![allow(clippy::items_after_statements)]
54#![allow(clippy::unreadable_literal)]
55#![allow(clippy::if_same_then_else)]
56#![allow(clippy::needless_range_loop)]
57#![allow(clippy::trivially_copy_pass_by_ref)]
58#![allow(clippy::unnecessary_wraps)]
59#![allow(clippy::match_same_arms)]
60#![allow(clippy::unused_self)]
61#![allow(clippy::too_many_lines)]
62#![allow(clippy::single_match_else)]
63#![allow(clippy::fn_params_excessive_bools)]
64#![allow(clippy::struct_excessive_bools)]
65#![allow(clippy::format_push_string)]
66#![allow(clippy::erasing_op)]
67#![allow(clippy::type_repetition_in_bounds)]
68#![allow(clippy::iter_without_into_iter)]
69#![allow(clippy::should_implement_trait)]
70#![allow(clippy::use_debug)]
71#![allow(clippy::case_sensitive_file_extension_comparisons)]
72#![allow(clippy::large_enum_variant)]
73#![allow(clippy::panic)]
74#![allow(clippy::struct_field_names)]
75#![allow(clippy::missing_fields_in_debug)]
76#![allow(clippy::upper_case_acronyms)]
77#![allow(clippy::assigning_clones)]
78#![allow(clippy::option_if_let_else)]
79#![allow(clippy::manual_let_else)]
80#![allow(clippy::explicit_iter_loop)]
81#![allow(clippy::default_trait_access)]
82#![allow(clippy::only_used_in_recursion)]
83#![allow(clippy::manual_clamp)]
84#![allow(clippy::ref_option)]
85#![allow(clippy::multiple_bound_locations)]
86#![allow(clippy::comparison_chain)]
87#![allow(clippy::manual_assert)]
88#![allow(clippy::unnecessary_debug_formatting)]
89
90// =============================================================================
91// Modules
92// =============================================================================
93
94pub mod creation;
95#[cfg(feature = "cuda")]
96pub mod cuda_ops;
97pub mod lazy;
98pub mod ops;
99pub mod shape;
100pub mod sparse;
101pub mod tensor;
102pub mod view;
103
104// =============================================================================
105// Re-exports
106// =============================================================================
107
108pub use axonml_core::{DType, Device, Error, Result};
109pub use creation::*;
110pub use lazy::{LazyOp, LazyTensor};
111pub use shape::{Shape, Strides};
112pub use tensor::Tensor;
113
114// =============================================================================
115// Prelude
116// =============================================================================
117
118/// Convenient imports for common usage.
119pub mod prelude {
120    pub use crate::shape::{Shape, Strides};
121    pub use crate::tensor::Tensor;
122    pub use crate::{arange, full, linspace, ones, rand, randn, zeros};
123    pub use axonml_core::{DType, Device, Error, Result};
124}