concision_core/
lib.rs

1/*
2    Appellation: concision-core <library>
3    Contrib: @FL03
4*/
5//! This crate provides the core implementations for the `cnc` framework, defining various
6//! traits, types, and utilities essential for building neural networks.
7//!
8//! - [`ParamsBase`]: A structure for defining the parameters within a neural network.
9//! - [`Backward`]: This trait establishes a common interface for backward propagation.
10//! - [`Forward`]: This trait denotes a single forward pass through a layer of a neural network
11//!
12//! ## Features
13//!
14//! The crate is heavily feature-gate, enabling users to customize their experience based on
15//! their needs.
16//!
17//! - `init`: Enables (random) initialization routines for models, parameters, and tensors.
18//! - `utils`: Provides various utilities for developing machine learning models.
19//!
20//! ### Dependency-specific Features
21//!
22//! Additionally, the crate provides various dependency-specific features that can be enabled:
23//!
24//! - `anyhow`: Enables the use of the `anyhow` crate for error handling.
25//! - `approx`: Enables approximate equality checks for floating-point numbers.
26//! - `complex`: Enables complex number support.
27//! - `json`: Enables JSON serialization and deserialization capabilities.
28//! - `rand`: Enables random number generation capabilities.
29//! - `serde`: Enables serialization and deserialization capabilities.
30//! - `tracing`: Enables tracing capabilities for debugging and logging.
31//!
32#![allow(
33    clippy::missing_safety_doc,
34    clippy::module_inception,
35    clippy::needless_doctest_main,
36    clippy::upper_case_acronyms
37)]
38#![cfg_attr(not(feature = "std"), no_std)]
39#![crate_type = "lib"]
40
41#[cfg(feature = "alloc")]
42extern crate alloc;
43
44#[cfg(feature = "rand")]
45#[doc(no_inline)]
46pub use rand;
47#[cfg(feature = "rand")]
48#[doc(no_inline)]
49pub use rand_distr;
50
51/// this module establishes generic random initialization routines for models, params, and
52/// tensors.
53#[doc(inline)]
54#[cfg(feature = "cnc_init")]
55pub use concision_init as init;
56/// this module implements various utilities useful for developing machine learning models
57#[doc(inline)]
58#[cfg(feature = "cnc_utils")]
59pub use concision_utils as utils;
60
61#[cfg(feature = "cnc_init")]
62pub use self::init::prelude::*;
63#[cfg(feature = "cnc_utils")]
64pub use self::utils::prelude::*;
65
66#[doc(inline)]
67pub use self::{
68    activate::prelude::*, error::*, loss::prelude::*, ops::prelude::*, params::prelude::*,
69    tensor::prelude::*, traits::*,
70};
71
72#[macro_use]
73pub(crate) mod macros {
74    #[macro_use]
75    pub mod seal;
76}
77/// this module is dedicated to activation function
78pub mod activate;
79/// this module provides the base [`Error`] type for the library
80pub mod error;
81/// this module focuses on the loss functions used in training neural networks.
82pub mod loss;
83/// this module provides the [`ParamsBase`] type for the library, which is used to define the
84/// parameters of a neural network.
85pub mod params;
86/// the [`tensor`] module provides various traits and types for handling n-dimensional tensors.
87pub mod tensor;
88
89pub mod ops {
90    //! This module provides the core operations for tensors, including filling, padding,
91    //! reshaping, and tensor manipulation.
92    #[doc(inline)]
93    pub use self::prelude::*;
94
95    pub mod fill;
96    pub mod mask;
97    pub mod norm;
98    pub mod pad;
99    pub mod reshape;
100
101    pub(crate) mod prelude {
102        #[doc(inline)]
103        pub use super::fill::*;
104        #[doc(inline)]
105        pub use super::mask::*;
106        #[doc(inline)]
107        pub use super::norm::*;
108        #[doc(inline)]
109        pub use super::pad::*;
110        #[doc(inline)]
111        pub use super::reshape::*;
112    }
113}
114
115pub mod traits {
116    //! This module provides the core traits for the library, such as  [`Backward`] and
117    //! [`Forward`]
118    #[doc(inline)]
119    pub use self::prelude::*;
120
121    mod apply;
122    mod clip;
123    mod codex;
124    mod convert;
125    mod gradient;
126    mod like;
127    mod propagation;
128    mod shape;
129    mod wnb;
130
131    mod prelude {
132        #[doc(inline)]
133        pub use super::apply::*;
134        #[doc(inline)]
135        pub use super::clip::*;
136        #[doc(inline)]
137        pub use super::codex::*;
138        #[doc(inline)]
139        pub use super::convert::*;
140        #[doc(inline)]
141        pub use super::gradient::*;
142        #[doc(inline)]
143        pub use super::like::*;
144        #[doc(inline)]
145        pub use super::propagation::*;
146        #[doc(inline)]
147        pub use super::shape::*;
148        #[doc(inline)]
149        pub use super::wnb::*;
150    }
151}
152
153#[doc(hidden)]
154pub mod prelude {
155    #[cfg(feature = "cnc_init")]
156    pub use concision_init::prelude::*;
157    #[cfg(feature = "cnc_utils")]
158    pub use concision_utils::prelude::*;
159
160    #[doc(no_inline)]
161    pub use crate::activate::prelude::*;
162    #[doc(no_inline)]
163    pub use crate::loss::prelude::*;
164    #[doc(no_inline)]
165    pub use crate::ops::prelude::*;
166    #[doc(no_inline)]
167    pub use crate::params::prelude::*;
168    #[doc(inline)]
169    pub use crate::tensor::prelude::*;
170    #[doc(no_inline)]
171    pub use crate::traits::*;
172}