axonml_tensor/
lib.rs

1//! Axonml Tensor - N-Dimensional Array for Machine Learning
2//!
3//! This crate provides the core `Tensor` type that serves as the foundation
4//! for all machine learning operations in Axonml. Tensors are multi-dimensional
5//! arrays with support for automatic broadcasting, device placement, and
6//! efficient memory sharing through views.
7//!
8//! # Key Features
9//! - N-dimensional tensor with arbitrary shape
10//! - Automatic broadcasting for operations
11//! - Efficient views and slicing (zero-copy where possible)
12//! - Device-agnostic (CPU, CUDA, Vulkan, etc.)
13//! - Generic over data type (f32, f64, i32, etc.)
14//!
15//! # Example
16//! ```rust
17//! use axonml_tensor::{zeros, ones, Tensor};
18//!
19//! // Create tensors using factory functions
20//! let a = zeros::<f32>(&[2, 3]);
21//! let b = ones::<f32>(&[2, 3]);
22//!
23//! // Arithmetic operations
24//! let c = a.add(&b).unwrap();
25//! let d = c.mul_scalar(2.0);
26//!
27//! // Reductions
28//! let sum = d.sum();
29//! let mean = d.mean();
30//! ```
31//!
32//! @version 0.1.0
33//! @author `AutomataNexus` Development Team
34
35#![cfg_attr(not(feature = "std"), no_std)]
36#![warn(missing_docs)]
37#![warn(clippy::all)]
38#![warn(clippy::pedantic)]
39// ML/tensor-specific allowances
40#![allow(clippy::cast_possible_truncation)]
41#![allow(clippy::cast_sign_loss)]
42#![allow(clippy::cast_precision_loss)]
43#![allow(clippy::cast_possible_wrap)]
44#![allow(clippy::missing_errors_doc)]
45#![allow(clippy::missing_panics_doc)]
46#![allow(clippy::must_use_candidate)]
47#![allow(clippy::module_name_repetitions)]
48#![allow(clippy::similar_names)]
49#![allow(clippy::many_single_char_names)]
50#![allow(clippy::too_many_arguments)]
51#![allow(clippy::doc_markdown)]
52#![allow(clippy::cast_lossless)]
53#![allow(clippy::needless_pass_by_value)]
54#![allow(clippy::redundant_closure_for_method_calls)]
55#![allow(clippy::uninlined_format_args)]
56#![allow(clippy::ptr_arg)]
57#![allow(clippy::return_self_not_must_use)]
58#![allow(clippy::not_unsafe_ptr_arg_deref)]
59#![allow(clippy::items_after_statements)]
60#![allow(clippy::unreadable_literal)]
61#![allow(clippy::if_same_then_else)]
62#![allow(clippy::needless_range_loop)]
63#![allow(clippy::trivially_copy_pass_by_ref)]
64#![allow(clippy::unnecessary_wraps)]
65#![allow(clippy::match_same_arms)]
66#![allow(clippy::unused_self)]
67#![allow(clippy::too_many_lines)]
68#![allow(clippy::single_match_else)]
69#![allow(clippy::fn_params_excessive_bools)]
70#![allow(clippy::struct_excessive_bools)]
71#![allow(clippy::format_push_string)]
72#![allow(clippy::erasing_op)]
73#![allow(clippy::type_repetition_in_bounds)]
74#![allow(clippy::iter_without_into_iter)]
75#![allow(clippy::should_implement_trait)]
76#![allow(clippy::use_debug)]
77#![allow(clippy::case_sensitive_file_extension_comparisons)]
78#![allow(clippy::large_enum_variant)]
79#![allow(clippy::panic)]
80#![allow(clippy::struct_field_names)]
81#![allow(clippy::missing_fields_in_debug)]
82#![allow(clippy::upper_case_acronyms)]
83#![allow(clippy::assigning_clones)]
84#![allow(clippy::option_if_let_else)]
85#![allow(clippy::manual_let_else)]
86#![allow(clippy::explicit_iter_loop)]
87#![allow(clippy::default_trait_access)]
88#![allow(clippy::only_used_in_recursion)]
89#![allow(clippy::manual_clamp)]
90#![allow(clippy::ref_option)]
91#![allow(clippy::multiple_bound_locations)]
92#![allow(clippy::comparison_chain)]
93#![allow(clippy::manual_assert)]
94#![allow(clippy::unnecessary_debug_formatting)]
95
96// =============================================================================
97// Modules
98// =============================================================================
99
100pub mod creation;
101pub mod ops;
102pub mod shape;
103pub mod tensor;
104pub mod view;
105
106// =============================================================================
107// Re-exports
108// =============================================================================
109
110pub use creation::*;
111pub use axonml_core::{DType, Device, Error, Result};
112pub use shape::{Shape, Strides};
113pub use tensor::Tensor;
114
115// =============================================================================
116// Prelude
117// =============================================================================
118
119/// Convenient imports for common usage.
120pub mod prelude {
121    pub use crate::shape::{Shape, Strides};
122    pub use crate::tensor::Tensor;
123    pub use crate::{arange, full, linspace, ones, rand, randn, zeros};
124    pub use axonml_core::{DType, Device, Error, Result};
125}