-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathhalide.rs
141 lines (133 loc) · 3.78 KB
/
halide.rs
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
use ruler::{
enumo::{Filter, Metric, Ruleset, Workload},
recipe_utils::{recursive_rules, run_workload, Lang},
Limits,
};
use crate::Pred;
pub fn halide_rules() -> Ruleset<Pred> {
let mut all_rules = Ruleset::default();
let bool_only = recursive_rules(
Metric::Atoms,
5,
Lang::new(&["0", "1"], &["a", "b", "c"], &[&["!"], &["&&", "||", "^"]]),
all_rules.clone(),
);
all_rules.extend(bool_only);
let rat_only = recursive_rules(
Metric::Atoms,
5,
Lang::new(
&["-1", "0", "1"],
&["a", "b", "c"],
&[&["-"], &["+", "-", "*", "min", "max"]],
),
all_rules.clone(),
);
all_rules.extend(rat_only.clone());
let pred_only = recursive_rules(
Metric::Atoms,
5,
Lang::new(
&["-1", "0", "1"],
&["a", "b", "c"],
&[&["-"], &["<", "<=", "==", "!="], &["select"]],
),
all_rules.clone(),
);
all_rules.extend(pred_only);
let full = recursive_rules(
Metric::Atoms,
4,
Lang::new(
&["-1", "0", "1"],
&["a", "b", "c"],
&[
&["-", "!"],
&[
"&&", "||", "^", "+", "-", "*", "min", "max", "<", "<=", "==", "!=",
],
&["select"],
],
),
all_rules.clone(),
);
all_rules.extend(full);
let nested_bops_arith = Workload::new(&["(bop e e)", "v"])
.plug("e", &Workload::new(&["(bop v v)", "(uop v)", "v"]))
.plug("bop", &Workload::new(&["+", "-", "*", "<", "max", "min"]))
.plug("uop", &Workload::new(&["-", "!"]))
.plug("v", &Workload::new(&["a", "b", "c"]))
.filter(Filter::Canon(vec![
"a".to_string(),
"b".to_string(),
"c".to_string(),
]));
let new = run_workload(
nested_bops_arith,
all_rules.clone(),
Limits::synthesis(),
Limits::minimize(),
true,
);
all_rules.extend(new);
let nested_bops_full = Workload::new(&["(bop e e)", "v"])
.plug("e", &Workload::new(&["(bop v v)", "(uop v)", "v"]))
.plug(
"bop",
&Workload::new(&["&&", "||", "!=", "<=", "==", "<", "max", "min"]),
)
.plug("uop", &Workload::new(&["-", "!"]))
.plug("v", &Workload::new(&["a", "b", "c"]))
.filter(Filter::Canon(vec![
"a".to_string(),
"b".to_string(),
"c".to_string(),
]));
let new = run_workload(
nested_bops_full,
all_rules.clone(),
Limits::synthesis(),
Limits::minimize(),
true,
);
all_rules.extend(new.clone());
// NOTE: The following workloads do NOT use all_rules as prior rules
// Using all_rules as prior_rules leads to OOM
let select_base = Workload::new([
"(select V V V)",
"(select V (OP V V) V)",
"(select V V (OP V V))",
"(select V (OP V V) (OP V V))",
"(OP V (select V V V))",
])
.plug("V", &Workload::new(["a", "b", "c", "d"]));
let arith = select_base
.clone()
.plug("OP", &Workload::new(["+", "-", "*"]));
let new = run_workload(
arith,
rat_only.clone(),
Limits::synthesis(),
Limits {
iter: 1,
node: 100_000,
match_: 100_000,
},
true,
);
all_rules.extend(new);
let arith = select_base.plug("OP", &Workload::new(["min", "max"]));
let new = run_workload(
arith,
rat_only.clone(),
Limits::synthesis(),
Limits {
iter: 1,
node: 100_000,
match_: 100_000,
},
true,
);
all_rules.extend(new);
all_rules
}