onnx2versal
Loading...
Searching...
No Matches
pool.h
1#ifndef POOL_H_
2#define POOL_H_
3
4#include <adf.h>
5#include <assert.h>
6
7
25template <typename TT, int INP_H, int INP_W, int OUT_H, int OUT_W, int B, int C, int KH, int KW, int STEP_H, int STEP_W>
27 public:
28 void filter(
29 input_window<TT>* in, // BHWC (1x24x24x6)
30 output_window<TT>* out // BPQC (1x12x12x6)
31 );
32 static void registerKernelClass() {
33 REGISTER_FUNCTION(MaxpoolScalarBHWC::filter);
34 }
35};
36
37
42template <typename TT, int INP_H, int INP_W, int OUT_H, int OUT_W, int B, int C, int KH, int KW, int STEP_H, int STEP_W>
44 public:
45 void filter(
46 input_window<TT>* in, // BCHW (1x6x24x24)
47 output_window<TT>* out // BCPQ (1x6x12x12)
48 );
49 static void registerKernelClass() {
50 REGISTER_FUNCTION(MaxpoolScalarBCHW::filter);
51 }
52};
53
54
60template <typename TT, int INP_H, int INP_W, int OUT_H, int OUT_W, int B, int C, int KH, int KW, int STEP_H, int STEP_W>
62 public:
63 void filter(
64 input_window<float>* in_window, // BCHW (1x6x24x24)
65 output_window<float>* out_window // BCPQ (1x6x12x12)
66 );
67 static void registerKernelClass() {
68 static_assert(INP_W % 8 == 0);
69 static_assert(OUT_W % 4 == 0);
70 static_assert(KH == 2);
71 static_assert(KW == 2);
72 static_assert((std::is_same<TT, float>::value));
73 REGISTER_FUNCTION(Maxpool2x2FloatBCHW::filter);
74 }
75};
76
77
83template <typename TT, int INP_H, int INP_W, int OUT_H, int OUT_W, int B, int C, int KH, int KW, int STEP_H, int STEP_W>
85 static constexpr int RUN_16CHUNK = INP_W % 32 != 0;
86 public:
87 void filter(
88 input_window<TT>* in_window, // BCHW (1x6x24x24)
89 output_window<TT>* out_window // BCPQ (1x6x12x12)
90 );
91 static void registerKernelClass() {
92 static_assert(INP_W % 16 == 0);
93 static_assert(OUT_W % 8 == 0);
94 static_assert(KH == 2);
95 static_assert(KW == 2);
96 static_assert((std::is_same<TT, int8_t>::value) || (std::is_same<TT, uint8_t>::value));
97 REGISTER_FUNCTION(Maxpool2x2Int8BCHW::filter);
98 }
99};
100
101
107template <typename TT, int INP_H, int INP_W, int OUT_H, int OUT_W, int B, int C, int KH, int KW, int STEP_H, int STEP_W>
109 static constexpr int RUN_16CHUNK = INP_W % 32 != 0;
110 public:
111 void filter(
112 input_window<TT>* in_window, // BCHW (1x6x24x24)
113 output_window<TT>* out_window // BCPQ (1x6x12x12)
114 );
115 static void registerKernelClass() {
116 static_assert(INP_W % 32 == 0);
117 static_assert(OUT_W % 16 == 0);
118 static_assert(KH == 3);
119 static_assert(KW == 3);
120 static_assert(STEP_W == 2);
121 static_assert(STEP_H == 2);
122 static_assert((std::is_same<TT, TT>::value) || (std::is_same<TT, uint8_t>::value));
123 REGISTER_FUNCTION(Maxpool3x3Int8BCHW::filter);
124 }
125};
126
127
132template <typename TT, int INP_H, int INP_W, int OUT_H, int OUT_W, int B, int C, int KH, int KW, int STEP_H, int STEP_W>
134 public:
135 void filter(
136 input_window<TT>* in, // BCHW (1x6x24x24)
137 output_window<TT>* out // BCPQ (1x6x12x12)
138 );
139 static void registerKernelClass() {
140 REGISTER_FUNCTION(AvgpoolScalarBCHW::filter);
141 }
142};
146#endif // POOL_H_
Scalar implementation for BCHW avgpool, AvgpoolScalarBCHW::filter<24,32,16,1,6> total = 15766.
Definition pool.h:133
Vector implementation for float BCHW maxpool with 2x2 kernel, requires INP_W%8==0,...
Definition pool.h:61
Vector implementation for int8 BCHW maxpool with 2x2 kernel, requires INP_W%16==0,...
Definition pool.h:84
void filter(input_window< TT > *in_window, output_window< TT > *out_window)
Definition pool.cc:149
Vector implementation for int8 BCHW maxpool with 2x2 kernel, requires INP_W%16==0,...
Definition pool.h:108
Scalar implementation for BCHW maxpool, MaxpoolScalarBCHW::filter<24,32,16,1,6> total = 11302.
Definition pool.h:43
Scalar implementation for BHWC maxpool, MaxpoolScalarBHWC::filter<24,32,16,1,6> total = 7673.
Definition pool.h:26