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
#[macro_export]
macro_rules! pulsed_op_to_typed_op {
() => {
fn to_typed(&self) -> Box<dyn TypedOp> {
tract_core::dyn_clone::clone_box(self)
}
};
}
#[macro_export]
macro_rules! register_all_mod {
($($m: ident),*) => {
pub fn register_all(inventory: &mut HashMap<TypeId, OpPulsifier>) {
$( $m::register_all(inventory); )*
}
}
}
#[macro_export]
macro_rules! register_all {
($($op: ty: $func: expr),*) => {
pub fn register_all(inventory: &mut HashMap<TypeId, OpPulsifier>) {
$(
inventory.insert(
std::any::TypeId::of::<$op>(),
OpPulsifier {
type_id: std::any::TypeId::of::<$op>(),
func: |source: &TypedModel,
node: &TypedNode,
target: &mut PulsedModel,
mapping: &HashMap<OutletId, OutletId>,
symbol: &Symbol,
pulse: &TDim|
-> TractResult<Option<TVec<OutletId>>> {
let op = node.op_as::<$op>().unwrap();
($func)(op, source, node, target, mapping, symbol, pulse)
},
name: stringify!($op)
}
);)*
}
};
}