tblis/lib.rs
1//! TBLIS wrapper and several minimal implementations.
2//!
3//! # API Documentation Summary
4//!
5//! ## About safety
6//!
7//! Most functions in this crate are marked as `unsafe` because they do not check the validity of
8//! tensor data and mutability.
9//!
10//! ## About function [`tblis_einsum`]
11//!
12//! This is the most important function of this crate.
13//!
14//! For the parameters of this function, also refer to crate [opt-einsum-path](https://github.com/RESTGroup/opt-einsum-path), document of function [`contract_path`](https://docs.rs/opt-einsum-path/latest/opt_einsum_path/contract/fn.contract_path.html).
15//!
16//! ## Most important functions, structs and traits
17//!
18//! | Item | Description |
19//! |--|--|
20//! | fn [`tblis_einsum`] | Einstein summation |
21//! | fn [`tblis_einsum_ndarray`] | Einstein summation with ndarray |
22//! | struct [`TblisTensor`] | Tensor struct of this crate |
23//! | trait [`TblisFloatAPI`] | Float trait for TBLIS operations (f32, f64, c32, c64) |
24//!
25//! ## Functions
26//!
27//! | Item | Description |
28//! |--|--|
29//! | [`tblis_einsum`] | (high-level) Einstein summation |
30//! | [`tblis_einsum_ndarray`] | (high-level) Einstein summation with ndarray |
31//! | [`tblis_einsum_f`] | (high-level) Einstein summation (failable) |
32//! | [`tblis_einsum_ndarray_f`] | (high-level) Einstein summation with ndarray (failable) |
33//! | [`tblis_tensor_add`] | (1t-level) $B = \alpha A + \beta B$ |
34//! | [`tblis_tensor_scale`] | (1t-level) $A = \alpha A$ |
35//! | [`tblis_tensor_set`] | (1t-level) $A = \alpha$ |
36//! | [`tblis_tensor_shift`] | (1t-level) $A = \alpha + \beta A$ |
37//! | [`tblis_tensor_reduce`] | (1t-level) $\gamma = \mathrm{op}(A)$ |
38//! | [`tblis_tensor_dot`] | (1t-level) $\gamma = A B$ |
39//! | [`tblis_tensor_mult`] | (3t-level) $C = \alpha A B + \beta C$ |
40//! | [`tblis_get_num_threads`] | Get the number of threads used by TBLIS |
41//! | [`tblis_set_num_threads`] | Set the number of threads used by TBLIS |
42//!
43//! ## Traits
44//!
45//! | Item | Description |
46//! |--|--|
47//! | [`TblisFloatAPI`] | Float trait for TBLIS operations (f32, f64, c32, c64) |
48//! | [`ToTblisTensor`] | Tensor view convert to TBLIS (mutable) tensor<br>Method function [`ToTblisTensor::to_tblis_tensor`] |
49//! | [`ArrayFromTblisTensor`] | Convert from TBLIS tensor to ndarray object<br>Method function [`ArrayFromTblisTensor::into_array`]<br>Only available for crate feature `ndarray` |
50//!
51//! ## Configurations
52//!
53//! | Item | Description |
54//! |--|--|
55//! | [`TblisReduceOp`] | Reduction operations for [`tblis_tensor_reduce`]<br>- Supported operations: sum, sumabs/norm1, max, maxabs/norminf, min, minabs, norm2 |
56//! | [`TblisZeroCfg`]<br>[`TblisZeroCfgBuilder`] | Zero parameter configuration for TBLIS operations<br>- Used in [`tblis_tensor_set`]<br>- Aliased as [`TblisSetCfg`] |
57//! | [`TblisUniCfg`]<br>[`TblisUniCfgBuilder`] | One parameter configuration for TBLIS operations<br>- By default $\alpha = 1$, no conjugate<br>- Used in [`tblis_tensor_scale`], [`tblis_tensor_shift`], [`tblis_tensor_reduce`]<br>- Aliased as [`TblisScaleCfg`], [`TblisShiftCfg`], [`TblisReduceCfg`] |
58//! | [`TblisBiCfg`]<br>[`TblisBiCfgBuilder`] | Two parameter configuration for TBLIS operations<br>- By default $\alpha = 1, \beta = 1$, no conjugate<br>- Used in [`tblis_tensor_add`], [`tblis_tensor_dot`]<br>- Aliased as [`TblisAddCfg`], [`TblisDotCfg`] |
59//! | [`TblisTriCfg`]<br>[`TblisTriCfgBuilder`] | Three parameter configuration for TBLIS operations<br>- By default $\alpha = 1, \beta = 0$, no conjugate<br>- Used in [`tblis_tensor_mult`]<br>- Aliased as [`TblisMultCfg`] |
60#![doc = include_str!("../readme.md")]
61
62pub mod alloc_vec;
63pub mod char_parse;
64pub mod containers;
65pub mod einsum_impl;
66pub mod float_trait;
67pub mod tensor_ops;
68pub mod threading;
69
70#[cfg(feature = "ndarray")]
71pub mod ndarray_impl;
72
73pub mod prelude {
74 pub use crate::containers::*;
75 pub use crate::einsum_impl::*;
76 pub use crate::float_trait::*;
77 pub use crate::tensor_ops::*;
78 pub use crate::threading::*;
79
80 #[cfg(feature = "ndarray")]
81 pub use crate::ndarray_impl::*;
82}
83
84#[allow(unused_imports)]
85use prelude::*;