-
Notifications
You must be signed in to change notification settings - Fork 0
/
Conv2d3x3.aten
39 lines (35 loc) · 1.07 KB
/
Conv2d3x3.aten
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
@package = "main";
import "io";
func Conv2d(input Tensor<1, 3, 2048, 2048, float32>,
kernel Tensor<16, 3, 3, 3, float32>,
output Tensor<1, 16, 2046, 2046, float32>) {
pfor (n := 0; 1; 1) {
pfor (k := 0; 16; 1) {
pfor (oh := 0; 2046; 1) {
pfor (ow := 0; 2046; 1) {
pfor (c := 0; 3; 1) {
pfor (r := 0; 3; 1) {
pfor (s := 0; 3; 1) {
output[n, k, oh, ow] = output[n, k, oh, ow] + input[n, c, oh + r, ow + s] * kernel[k, c, r, s];
};
};
};
};
};
};
};
};
func main() {
// NCHW
var input Tensor<1, 3, 2048, 2048, float32>;
// KCRS
var kernel Tensor<16, 3, 3, 3, float32>;
// padding = 0, stride = 1
var output Tensor<1, 16, 2046, 2046, float32>;
// timing.
start := io.clock();
Conv2d(input, kernel, output);
end := io.clock();
io.print(end - start);
io.newLine();
};