1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/// A tensor layout.

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum Layout {
    Strided,
    Sparse,
    SparseCsr,
    Mkldnn,
    SparseCsc,
    SparseBsr,
    SparseBsc,
    NumOptions,
}

impl Layout {
    // This should be kept in sync with include/c10/core/Layout.h
    pub fn to_i8(&self) -> i8 {
        match self {
            Self::Strided => 0,
            Self::Sparse => 1,
            Self::SparseCsr => 2,
            Self::Mkldnn => 3,
            Self::SparseCsc => 4,
            Self::SparseBsr => 5,
            Self::SparseBsc => 6,
            Self::NumOptions => 7,
        }
    }
}