forked from dillonhuff/clockwork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
glb_channel_reduction.cpp
187 lines (158 loc) · 11.9 KB
/
glb_channel_reduction.cpp
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include "app.h"
#include "ubuffer.h"
#include "codegen.h"
#include "prog.h"
/*
prog glb_channel_reduction() {
prog prg;
prg.compute_unit_file = "glb_channel_reduction_compute.h";
prg.name = "glb_channel_reduction";
// Stencil<uint16_t, 8, 248, 248> &input_host_stencil = arg_0;
prg.add_input("input_host_stencil");
prg.buffer_port_widths["input_host_stencil"] = 16;
// Stencil<uint16_t, 248, 248> &hw_output_stencil = arg_1;
prg.add_output("hw_output_stencil");
prg.buffer_port_widths["hw_output_stencil"] = 16;
////producing input_gb.stencil
auto input_gb_s0_y = prg.add_loop("input_gb_s0_y", 0, 64);
auto input_gb_s0_x = input_gb_s0_y->add_loop("input_gb_s0_x", 0, 64);
auto input_gb_s0_c = input_gb_s0_x->add_loop("input_gb_s0_c", 0, 8);
//store is: input_gb.stencil(input_gb_s0_c, input_gb_s0_x, input_gb_s0_y) = input_host.stencil(input_gb_s0_c, input_gb_s0_x, input_gb_s0_y)
auto hcompute_input_gb_stencil = input_gb_s0_c->add_op("op_hcompute_input_gb_stencil");
hcompute_input_gb_stencil->add_function("hcompute_input_gb_stencil");
hcompute_input_gb_stencil->add_load("input_host_stencil", "input_gb_s0_y", "input_gb_s0_x", "input_gb_s0_c");
prg.buffer_port_widths["input_glb_stencil"] = 16;
hcompute_input_gb_stencil->add_store("input_glb_stencil", "input_gb_s0_y", "input_gb_s0_x", "input_gb_s0_c");
//consuming input_gb.stencil
////producing output_gb.stencil
auto output_gb_s0_y_y_gb = prg.add_loop("output_gb_s0_y_y_gb", 0, 4);
auto output_gb_s0_x_x_gb = output_gb_s0_y_y_gb->add_loop("output_gb_s0_x_x_gb", 0, 4);
////producing hw_input.stencil
auto hw_input_s0_y = output_gb_s0_x_x_gb->add_loop("hw_input_s0_y", 0, 16);
auto hw_input_s0_x = hw_input_s0_y->add_loop("hw_input_s0_x", 0, 16);
auto hw_input_s0_c = hw_input_s0_x->add_loop("hw_input_s0_c", 0, 8);
//store is: hw_input.stencil(hw_input_s0_c, hw_input_s0_x, hw_input_s0_y) = input_gb.stencil(hw_input_s0_c, ((output_gb_s0_x_x_gb*62) + hw_input_s0_x), ((output_gb_s0_y_y_gb*62) + hw_input_s0_y))
auto hcompute_hw_input_stencil = hw_input_s0_c->add_op("op_hcompute_hw_input_stencil");
hcompute_hw_input_stencil->add_function("hcompute_hw_input_stencil");
hcompute_hw_input_stencil->add_load("input_glb_stencil", "((output_gb_s0_y_y_gb*32) + hw_input_s0_y)", "((output_gb_s0_x_x_gb*32) + hw_input_s0_x)", "hw_input_s0_c");
prg.buffer_port_widths["hw_input_stencil"] = 16;
hcompute_hw_input_stencil->add_store("hw_input_stencil", "hw_input_s0_y", "hw_input_s0_x", "hw_input_s0_c");
//consuming hw_input.stencil
////producing conv.stencil
auto conv_s0_y = output_gb_s0_x_x_gb->add_loop("conv_s0_y", 0, 16);
auto conv_s0_x = conv_s0_y->add_loop("conv_s0_x", 0, 16);
//store is: conv.stencil(conv_s0_x, conv_s0_y) = (uint16)0
auto hcompute_conv_stencil = conv_s0_x->add_op("op_hcompute_conv_stencil");
hcompute_conv_stencil->add_function("hcompute_conv_stencil");
prg.buffer_port_widths["conv_stencil"] = 16;
hcompute_conv_stencil->add_store("conv_stencil", "conv_s0_y", "conv_s0_x");
auto conv_s1_y = output_gb_s0_x_x_gb->add_loop("conv_s1_y", 0, 16);
auto conv_s1_x = conv_s1_y->add_loop("conv_s1_x", 0, 16);
//store is: conv.stencil(conv_s1_x, conv_s1_y) = (hw_input.stencil(0, conv_s1_x, conv_s1_y) + (conv.stencil(conv_s1_x, conv_s1_y) + (hw_input.stencil(1, conv_s1_x, conv_s1_y) + (hw_input.stencil(2, conv_s1_x, conv_s1_y) + (hw_input.stencil(3, conv_s1_x, conv_s1_y) + (hw_input.stencil(4, conv_s1_x, conv_s1_y) + (hw_input.stencil(5, conv_s1_x, conv_s1_y) + (hw_input.stencil(7, conv_s1_x, conv_s1_y) + hw_input.stencil(6, conv_s1_x, conv_s1_y)))))))))
auto hcompute_conv_stencil_1 = conv_s1_x->add_op("op_hcompute_conv_stencil_1");
hcompute_conv_stencil_1->add_function("hcompute_conv_stencil_1");
hcompute_conv_stencil_1->add_load("conv_stencil", "conv_s1_y", "conv_s1_x");
hcompute_conv_stencil_1->add_load("hw_input_stencil", "conv_s1_y", "conv_s1_x", "0");
hcompute_conv_stencil_1->add_load("hw_input_stencil", "conv_s1_y", "conv_s1_x", "1");
hcompute_conv_stencil_1->add_load("hw_input_stencil", "conv_s1_y", "conv_s1_x", "2");
hcompute_conv_stencil_1->add_load("hw_input_stencil", "conv_s1_y", "conv_s1_x", "3");
hcompute_conv_stencil_1->add_load("hw_input_stencil", "conv_s1_y", "conv_s1_x", "4");
hcompute_conv_stencil_1->add_load("hw_input_stencil", "conv_s1_y", "conv_s1_x", "5");
hcompute_conv_stencil_1->add_load("hw_input_stencil", "conv_s1_y", "conv_s1_x", "7");
hcompute_conv_stencil_1->add_load("hw_input_stencil", "conv_s1_y", "conv_s1_x", "6");
hcompute_conv_stencil_1->add_store("conv_stencil", "conv_s1_y", "conv_s1_x");
//consuming conv.stencil
auto output_gb_s0_y_y_cgra = output_gb_s0_x_x_gb->add_loop("output_gb_s0_y_y_cgra", 0, 16);
auto output_gb_s0_x_x_cgra = output_gb_s0_y_y_cgra->add_loop("output_gb_s0_x_x_cgra", 0, 16);
//store is: output_gb.stencil(((output_gb_s0_x_x_gb*62) + output_gb_s0_x_x_cgra), ((output_gb_s0_y_y_gb*62) + output_gb_s0_y_y_cgra)) = conv.stencil(output_gb_s0_x_x_cgra, output_gb_s0_y_y_cgra)
auto hcompute_output_gb_stencil = output_gb_s0_x_x_cgra->add_op("op_hcompute_output_gb_stencil");
hcompute_output_gb_stencil->add_function("hcompute_output_gb_stencil");
hcompute_output_gb_stencil->add_load("conv_stencil", "output_gb_s0_y_y_cgra", "output_gb_s0_x_x_cgra");
prg.buffer_port_widths["output_glb_stencil"] = 16;
hcompute_output_gb_stencil->add_store("output_glb_stencil", "((output_gb_s0_y_y_gb*32) + output_gb_s0_y_y_cgra)", "((output_gb_s0_x_x_gb*32) + output_gb_s0_x_x_cgra)");
//consuming output_gb.stencil
auto hw_output_s0_y_yi = prg.add_loop("hw_output_s0_y_yi", 0, 64);
auto hw_output_s0_x_xi = hw_output_s0_y_yi->add_loop("hw_output_s0_x_xi", 0, 64);
//store is: hw_output.stencil(hw_output_s0_x_xi, hw_output_s0_y_yi) = output_gb.stencil(hw_output_s0_x_xi, hw_output_s0_y_yi)
auto hcompute_hw_output_stencil = hw_output_s0_x_xi->add_op("op_hcompute_hw_output_stencil");
hcompute_hw_output_stencil->add_function("hcompute_hw_output_stencil");
hcompute_hw_output_stencil->add_load("output_glb_stencil", "hw_output_s0_y_yi", "hw_output_s0_x_xi");
hcompute_hw_output_stencil->add_store("hw_output_stencil", "hw_output_s0_y_yi", "hw_output_s0_x_xi");
return prg;
}*/
prog glb_channel_reduction() {
prog prg;
prg.compute_unit_file = "glb_channel_reduction_compute.h";
prg.name = "glb_channel_reduction";
// Stencil<uint16_t, 8, 128, 128> &input_host_stencil = arg_0;
prg.add_input("input_host_stencil");
prg.buffer_port_widths["input_host_stencil"] = 16;
// Stencil<uint16_t, 128, 128> &hw_output_stencil = arg_1;
prg.add_output("hw_output_stencil");
prg.buffer_port_widths["hw_output_stencil"] = 16;
////producing input_gb.stencil
auto input_gb_s0_y = prg.add_loop("input_gb_s0_y", 0, 128);
auto input_gb_s0_x = input_gb_s0_y->add_loop("input_gb_s0_x", 0, 128);
auto input_gb_s0_c = input_gb_s0_x->add_loop("input_gb_s0_c", 0, 8);
//store is: input_gb.stencil(input_gb_s0_c, input_gb_s0_x, input_gb_s0_y) = input_host.stencil(input_gb_s0_c, input_gb_s0_x, input_gb_s0_y)
auto hcompute_input_gb_stencil = input_gb_s0_c->add_op("op_hcompute_input_gb_stencil");
hcompute_input_gb_stencil->add_function("hcompute_input_gb_stencil");
hcompute_input_gb_stencil->add_load("input_host_stencil", "input_gb_s0_y", "input_gb_s0_x", "input_gb_s0_c");
prg.buffer_port_widths["input_glb_stencil"] = 16;
hcompute_input_gb_stencil->add_store("input_glb_stencil", "input_gb_s0_y", "input_gb_s0_x", "input_gb_s0_c");
//consuming input_gb.stencil
////producing output_gb.stencil
auto output_gb_s0_y_y_gb = prg.add_loop("output_gb_s0_y_y_gb", 0, 16);
////producing hw_input.stencil
auto hw_input_s0_y = output_gb_s0_y_y_gb->add_loop("hw_input_s0_y", 0, 8);
auto hw_input_s0_x = hw_input_s0_y->add_loop("hw_input_s0_x", 0, 128);
auto hw_input_s0_c = hw_input_s0_x->add_loop("hw_input_s0_c", 0, 8);
//store is: hw_input.stencil(hw_input_s0_c, hw_input_s0_x, hw_input_s0_y) = input_gb.stencil(hw_input_s0_c, hw_input_s0_x, ((output_gb_s0_y_y_gb*64) + hw_input_s0_y))
auto hcompute_hw_input_stencil = hw_input_s0_c->add_op("op_hcompute_hw_input_stencil");
hcompute_hw_input_stencil->add_function("hcompute_hw_input_stencil");
hcompute_hw_input_stencil->add_load("input_glb_stencil", "((output_gb_s0_y_y_gb*8) + hw_input_s0_y)", "hw_input_s0_x", "hw_input_s0_c");
prg.buffer_port_widths["hw_input_stencil"] = 16;
hcompute_hw_input_stencil->add_store("hw_input_stencil", "hw_input_s0_y", "hw_input_s0_x", "hw_input_s0_c");
//consuming hw_input.stencil
////producing conv.stencil
auto conv_s0_y = output_gb_s0_y_y_gb->add_loop("conv_s0_y", 0, 8);
auto conv_s0_x = conv_s0_y->add_loop("conv_s0_x", 0, 128);
//store is: conv.stencil(conv_s0_x, conv_s0_y) = (uint16)0
auto hcompute_conv_stencil = conv_s0_x->add_op("op_hcompute_conv_stencil");
hcompute_conv_stencil->add_function("hcompute_conv_stencil");
prg.buffer_port_widths["conv_stencil"] = 16;
hcompute_conv_stencil->add_store("conv_stencil", "conv_s0_y", "conv_s0_x");
auto conv_s1_y = output_gb_s0_y_y_gb->add_loop("conv_s1_y", 0, 8);
auto conv_s1_x = conv_s1_y->add_loop("conv_s1_x", 0, 128);
//store is: conv.stencil(conv_s1_x, conv_s1_y) = (hw_input.stencil(0, conv_s1_x, conv_s1_y) + (conv.stencil(conv_s1_x, conv_s1_y) + (hw_input.stencil(1, conv_s1_x, conv_s1_y) + (hw_input.stencil(2, conv_s1_x, conv_s1_y) + (hw_input.stencil(3, conv_s1_x, conv_s1_y) + (hw_input.stencil(4, conv_s1_x, conv_s1_y) + (hw_input.stencil(5, conv_s1_x, conv_s1_y) + (hw_input.stencil(7, conv_s1_x, conv_s1_y) + hw_input.stencil(6, conv_s1_x, conv_s1_y)))))))))
auto hcompute_conv_stencil_1 = conv_s1_x->add_op("op_hcompute_conv_stencil_1");
hcompute_conv_stencil_1->add_function("hcompute_conv_stencil_1");
hcompute_conv_stencil_1->add_load("conv_stencil", "conv_s1_y", "conv_s1_x");
hcompute_conv_stencil_1->add_load("hw_input_stencil", "conv_s1_y", "conv_s1_x", "0");
hcompute_conv_stencil_1->add_load("hw_input_stencil", "conv_s1_y", "conv_s1_x", "1");
hcompute_conv_stencil_1->add_load("hw_input_stencil", "conv_s1_y", "conv_s1_x", "2");
hcompute_conv_stencil_1->add_load("hw_input_stencil", "conv_s1_y", "conv_s1_x", "3");
hcompute_conv_stencil_1->add_load("hw_input_stencil", "conv_s1_y", "conv_s1_x", "4");
hcompute_conv_stencil_1->add_load("hw_input_stencil", "conv_s1_y", "conv_s1_x", "5");
hcompute_conv_stencil_1->add_load("hw_input_stencil", "conv_s1_y", "conv_s1_x", "7");
hcompute_conv_stencil_1->add_load("hw_input_stencil", "conv_s1_y", "conv_s1_x", "6");
hcompute_conv_stencil_1->add_store("conv_stencil", "conv_s1_y", "conv_s1_x");
//consuming conv.stencil
auto output_gb_s0_y_y_cgra = output_gb_s0_y_y_gb->add_loop("output_gb_s0_y_y_cgra", 0, 8);
auto output_gb_s0_x_x_cgra = output_gb_s0_y_y_cgra->add_loop("output_gb_s0_x_x_cgra", 0, 128);
//store is: output_gb.stencil(output_gb_s0_x_x_cgra, ((output_gb_s0_y_y_gb*64) + output_gb_s0_y_y_cgra)) = conv.stencil(output_gb_s0_x_x_cgra, output_gb_s0_y_y_cgra)
auto hcompute_output_gb_stencil = output_gb_s0_x_x_cgra->add_op("op_hcompute_output_gb_stencil");
hcompute_output_gb_stencil->add_function("hcompute_output_gb_stencil");
hcompute_output_gb_stencil->add_load("conv_stencil", "output_gb_s0_y_y_cgra", "output_gb_s0_x_x_cgra");
prg.buffer_port_widths["output_glb_stencil"] = 16;
hcompute_output_gb_stencil->add_store("output_glb_stencil", "((output_gb_s0_y_y_gb*8) + output_gb_s0_y_y_cgra)", "output_gb_s0_x_x_cgra");
//consuming output_gb.stencil
auto hw_output_s0_y_yi = prg.add_loop("hw_output_s0_y_yi", 0, 128);
auto hw_output_s0_x_xi = hw_output_s0_y_yi->add_loop("hw_output_s0_x_xi", 0, 128);
//store is: hw_output.stencil(hw_output_s0_x_xi, hw_output_s0_y_yi) = output_gb.stencil(hw_output_s0_x_xi, hw_output_s0_y_yi)
auto hcompute_hw_output_stencil = hw_output_s0_x_xi->add_op("op_hcompute_hw_output_stencil");
hcompute_hw_output_stencil->add_function("hcompute_hw_output_stencil");
hcompute_hw_output_stencil->add_load("output_glb_stencil", "hw_output_s0_y_yi", "hw_output_s0_x_xi");
hcompute_hw_output_stencil->add_store("hw_output_stencil", "hw_output_s0_y_yi", "hw_output_s0_x_xi");
return prg;
}