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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use core::fmt::Debug;
pub trait Shape: Clone + Debug {
fn shape() -> &'static [usize];
fn squeeze_first_dim() -> bool {
false
}
fn shape_i64vec() -> Vec<i64> {
Self::shape().iter().map(|e| *e as i64).collect::<Vec<_>>()
}
}
#[macro_export]
macro_rules! shape {
($struct_:ident, [$($elem_:expr),+]) => {
#[derive(Clone, Debug)]
struct $struct_ {}
impl border_core::Shape for $struct_ {
fn shape() -> &'static [usize] {
&[$($elem_),+]
}
}
};
($struct_:ident, [$($elem_:expr),+], squeeze_first_dim) => {
#[derive(Clone, Debug)]
struct $struct_ {}
impl border_core::Shape for $struct_ {
fn shape() -> &'static [usize] {
&[$($elem_),+]
}
fn squeeze_first_dim() -> bool {
true
}
}
};
}