-
Notifications
You must be signed in to change notification settings - Fork 551
/
graph.h
executable file
·73 lines (61 loc) · 2.31 KB
/
graph.h
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
/*
Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: MIT
*/
#ifndef GRAPH_MODULE_H
#define GRAPH_MODULE_H
#include "kernels.h"
#include <adf.h>
using namespace adf;
const int COL=256;
const int ROW=384;
const int K_COL=256;
const int K_ROW=64;
class SimpleGraph : public adf::graph {
public :
output_plio out;
input_plio in;
private:
kernel k_mean;
kernel k_deviation;
kernel k_norm;
shared_buffer<bfloat16> mtxA;
public:
SimpleGraph() {
in=input_plio::create("Datain0", plio_128_bits, "data/input0.csv");
out=output_plio::create("Dataout0", plio_128_bits, "data/output0.txt");
k_mean = adf::kernel::create(mean<K_COL,K_ROW, ROW*COL/K_ROW/K_COL>);
source(k_mean) = "mean.cc";
runtime<ratio>(k_mean) = 0.9;
k_deviation = adf::kernel::create(deviation<K_COL,K_ROW, ROW*COL/K_ROW/K_COL>);
source(k_deviation) = "deviation.cc";
runtime<ratio>(k_deviation) = 0.9;
k_norm = adf::kernel::create(norm<K_COL,K_ROW, ROW*COL/K_ROW/K_COL>);
source(k_norm) = "norm.cc";
runtime<ratio>(k_norm) = 0.9;
repetition_count(k_mean)=ROW*COL/K_ROW/K_COL;
repetition_count(k_deviation)=ROW*COL/K_ROW/K_COL;
repetition_count(k_norm)=ROW*COL/K_ROW/K_COL;
mtxA = shared_buffer<bfloat16>::create({COL,ROW}, 1, 3);
write_access(mtxA.in[0]) = tiling({.buffer_dimension={COL,ROW}, .tiling_dimension={COL,ROW}, .offset={0,0} });
read_access(mtxA.out[0]) = tiling({.buffer_dimension={COL,ROW}, .tiling_dimension={COL,ROW}, .offset={0,0} });
read_access(mtxA.out[1]) = tiling({.buffer_dimension={COL,ROW}, .tiling_dimension={COL,ROW}, .offset={0,0} });
read_access(mtxA.out[2]) = tiling({.buffer_dimension={COL,ROW}, .tiling_dimension={COL,ROW}, .offset={0,0} });
connect(in.out[0], mtxA.in[0]);
connect(mtxA.out[0], k_mean.in[0]);
connect(mtxA.out[1], k_deviation.in[0]);
connect(mtxA.out[2], k_norm.in[0]);
connect(k_mean.out[0], k_deviation.in[1]);
connect(k_deviation.out[0], k_norm.in[1]);
connect(k_norm.out[0], out.in[0]);
dimensions(k_mean.in[0])={K_ROW*K_COL};//elements
dimensions(k_mean.out[0])={1};
dimensions(k_deviation.in[0])={K_ROW*K_COL};
dimensions(k_deviation.in[1])={1};
dimensions(k_deviation.out[0])={2};
dimensions(k_norm.in[0])={K_ROW*K_COL};
dimensions(k_norm.in[1])={2};
dimensions(k_norm.out[0])={K_ROW*K_COL};
}
};
#endif