onnx2versal
Loading...
Searching...
No Matches
graph_pad.h
1#ifndef __PAD_GRAPH_H__
2#define __PAD_GRAPH_H__
3
4#include <assert.h>
5#include <adf.h>
6#include "pad.h"
7#include "graph_utils.h"
8
9
35template <template<typename, int, int, int, int, int, int, int, int> class PAD,
36 typename TT, int B, int INP_H, int INP_W, int INP_W_PAD,int H0, int H1, int W0, int W1>
37class Pad2DStreamGraph : public adf::graph {
38
39 private:
40 static constexpr int OUT_H = INP_H + H0 + H1;
41 static constexpr int OUT_W = INP_W + W0 + W1;
42 adf::kernel k[1];
43
44 public:
45 adf::port<input> pin[1];
46 adf::port<output> pout[1];
47
49 static_assert(H0 >= 0 && H1 >= 0 && W0 >= 0 && W1 >= 0);
50 k[0] = adf::kernel::create_object<PAD<TT, B, INP_H, INP_W, INP_W_PAD, H0, H1, W0, W1>>();
51 adf::source(k[0]) = "pad.cc";
52 adf::headers(k[0]) = {"pad.h"};
53 adf::runtime<ratio>(k[0]) = 0.6;
54
55 adf::connect<adf::stream> (pin[0], k[0].in[0]);
56 adf::connect<adf::stream> (k[0].out[0], pout[0]);
57
58 adf::samples_per_iteration(k[0].in[0]) = B*INP_H*INP_W_PAD;
59 adf::samples_per_iteration(k[0].out[0]) = B*OUT_H*OUT_W;
60 }
61
62};
63
64
73template <template<typename, int, int, int, int, int, int, int, int> class PAD,
74 typename TT, int B, int INP_H, int INP_W, int INP_W_PAD,int H0, int H1, int W0, int W1>
75class Pad2DWindowScalarGraph : public adf::graph {
76
77 private:
78 static constexpr int OUT_H = INP_H + H0 + H1;
79 static constexpr int OUT_W = INP_W + W0 + W1;
80 adf::kernel k[1];
81
82 public:
83 adf::port<input> pin[1];
84 adf::port<output> pout[1];
85
87 static_assert(INP_H*INP_W_PAD*sizeof(TT) <= MAX_PARAM_BYTES);
88 static_assert(H0 >= 0 && H1 >= 0 && W0 >= 0 && W1 >= 0);
89
90 k[0] = adf::kernel::create_object<PAD<TT, B, INP_H, INP_W, INP_W_PAD, H0, H1, W0, W1>>();
91 adf::source(k[0]) = "pad.cc";
92 adf::headers(k[0]) = {"pad.h"};
93 adf::runtime<ratio>(k[0]) = 0.6;
94 adf::repetition_count(k[0]) = B;
95
96 adf::connect<adf::window<INP_H*INP_W_PAD*sizeof(TT)>> (pin[0], k[0].in[0]);
97 adf::connect<adf::window<OUT_H*OUT_W*sizeof(TT)>> (k[0].out[0], pout[0]);
98 }
99
100};
101
102
111template <template<typename, int, int, int, int, int, int, int, int> class PAD,
112 typename TT, int B, int INP_H, int INP_W, int INP_W_PAD,int H0, int H1, int W0, int W1>
113class Pad2DStream2WindowGraph : public adf::graph {
114
115 private:
116 static constexpr int OUT_H = INP_H + H0 + H1;
117 static constexpr int OUT_W = INP_W + W0 + W1;
118 adf::kernel k[1];
119
120 public:
121 adf::port<input> pin[1];
122 adf::port<output> pout[1];
123
125 static_assert(INP_H*INP_W_PAD*sizeof(TT) <= MAX_PARAM_BYTES);
126 static_assert(H0 >= 0 && H1 >= 0 && W0 >= 0 && W1 >= 0);
127
128 k[0] = adf::kernel::create_object<PAD<TT, B, INP_H, INP_W, INP_W_PAD, H0, H1, W0, W1>>();
129 adf::source(k[0]) = "pad.cc";
130 adf::headers(k[0]) = {"pad.h"};
131 adf::runtime<ratio>(k[0]) = 0.6;
132 adf::repetition_count(k[0]) = B;
133
134 adf::connect<adf::stream> (pin[0], k[0].in[0]);
135 adf::connect<adf::window<OUT_H*OUT_W*sizeof(TT)>> (k[0].out[0], pout[0]);
136 }
137
138};
142#endif // __PAD_GRAPH_H__
Single instance graph for Pad2D.
Definition graph_pad.h:113
Single instance graph for Pad2D.
Definition graph_pad.h:37
Single instance graph for Pad2D.
Definition graph_pad.h:75