onnx2versal
Loading...
Searching...
No Matches
graph_mac.h
1#ifndef __MAC_GRAPH_H__
2#define __MAC_GRAPH_H__
3
4#include <assert.h>
5#include <adf.h>
6#include "mac.h"
7#include "graph_utils.h"
8
9
33template <template<typename, int, int, int> class MAC,
34 typename TT, int B, int W, int IS_RELU>
35class MacGraph : public adf::graph {
36
37 private:
38 static constexpr int TTSIZE = sizeof(TT);
39 adf::kernel k[1];
40 std::string id;
41
42 public:
43 adf::port<input> pin[1];
44 adf::port<output> pout[1];
45
47 std::vector<TT> weights,
48 std::vector<TT> bias,
49 int repeat_cnt = 1
50 ) {
51 static_assert(W*TTSIZE < MAX_PARAM_BYTES);
52 k[0] = adf::kernel::create_object<MAC<TT, B, W, IS_RELU>>(weights, bias);
53 adf::source(k[0]) = "mac.cc";
54 adf::headers(k[0]) = {"mac.h"};
55 adf::runtime<ratio>(k[0]) = 0.6;
56 adf::repetition_count(k[0]) = repeat_cnt;
57
58 adf::connect<adf::window<B*W*TTSIZE>> (pin[0], k[0].in[0]);
59 adf::connect<adf::window<B*W*TTSIZE>> (k[0].out[0], pout[0]);
60 }
61
62};
66#endif // __MAC_GRAPH_H__
Single instance graph.
Definition graph_mac.h:35