opt_einsum_path/
typing.rs1use crate::*;
2
3pub type SizeType = f64;
4pub type TensorShapeType = Vec<usize>;
5pub type PathType = Vec<Vec<usize>>;
6pub type ArrayIndexType = BTreeSet<char>;
7pub type SizeDictType = BTreeMap<char, usize>;
8pub use crate::paths::OptimizeKind;
9
10#[derive(Debug, Clone)]
11pub struct ContractionType {
12 pub indices: Vec<usize>,
13 pub idx_rm: ArrayIndexType,
14 pub einsum_str: String,
15 pub remaining: Option<Vec<String>>,
16 pub do_blas: Option<&'static str>,
17}
18
19#[derive(Debug, Clone, Copy, PartialEq)]
20pub enum SizeLimitType {
21 None,
22 MaxInput,
23 Size(SizeType),
24}
25
26impl From<bool> for SizeLimitType {
29 fn from(b: bool) -> Self {
30 match b {
31 true => SizeLimitType::MaxInput,
32 false => SizeLimitType::None,
33 }
34 }
35}
36
37impl From<SizeType> for SizeLimitType {
38 fn from(size: SizeType) -> Self {
39 SizeLimitType::Size(size)
40 }
41}
42
43impl From<Option<SizeType>> for SizeLimitType {
44 fn from(size: Option<SizeType>) -> Self {
45 match size {
46 Some(s) => SizeLimitType::Size(s),
47 None => SizeLimitType::None,
48 }
49 }
50}
51
52impl From<&'static str> for SizeLimitType {
53 fn from(size: &'static str) -> Self {
54 match size.replace(['_', ' '], "-").to_lowercase().as_str() {
55 "max-input" => SizeLimitType::MaxInput,
56 "" | "none" | "no-limit" => SizeLimitType::None,
57 _ => panic!("Invalid MemoryLimitType string: {size}"),
58 }
59 }
60}
61
62