onnx2versal
Loading...
Searching...
No Matches
qlinearsoftmax.h
1#ifndef QLINEARSOFTMAX_H_
2#define QLINEARSOFTMAX_H_
3
4#include <adf.h>
5#include <assert.h>
6
7
28template <typename TT, int INP_H, int INP_W, int INP_W_PAD>
30
31 private:
32 float x_scale;
33 float y_scale;
34 TT x_zero;
35 TT y_zero;
36
37 float scale;
38
39 public:
41 float x_scale,
42 float y_scale,
43 TT x_zero,
44 TT y_zero
45 ): x_scale(x_scale), y_scale(y_scale), x_zero(x_zero), y_zero(y_zero) {};
46
47 void filter(
48 input_window<TT>* in,
49 output_stream<TT>* out
50 );
51
52 static void registerKernelClass() {
53 static_assert((std::is_same<TT, int8_t>::value) || (std::is_same<TT, uint8_t>::value));
54 REGISTER_FUNCTION(QLinearSoftmaxScalar::filter);
55 };
56};
57
58
64template <typename TT, int INP_H, int INP_W, int INP_W_PAD>
66
67 private:
68 float x_scale;
69 float y_scale;
70 TT x_zero;
71 TT y_zero;
72
73 int EXP_BITSHIFT = 18;
74 int OUT_BITSHIFT = 10;
75
76 // precompute
77 float fastexp_scale;
78 int16_t min_value;
79
80 public:
82 float x_scale,
83 float y_scale,
84 TT x_zero,
85 TT y_zero
86 );
87
88 void filter(
89 input_window<TT>* in,
90 output_stream<TT>* out
91 );
92
93 static void registerKernelClass() {
94 static_assert((std::is_same<TT, int8_t>::value) || (std::is_same<TT, uint8_t>::value));
95 static_assert(INP_W_PAD % 16 == 0);
96 REGISTER_FUNCTION(QLinearSoftmaxFloatmul::filter);
97 }
98};
99
100
106template <typename TT, int INP_H, int INP_W, int INP_W_PAD>
108
109 private:
110 float x_scale;
111 float y_scale;
112 TT x_zero;
113 TT y_zero;
114
115 int EXP_BITSHIFT;
116 int OUT_BITSHIFT = 4;
117
118 // precompute
119 int16_t fastexp_scale;
120 int32_t expsum_offset;
121 int16_t min_value;
122
123 public:
125 float x_scale,
126 float y_scale,
127 TT x_zero,
128 TT y_zero
129 );
130
131 void filter(
132 input_window<TT>* in,
133 output_stream<TT>* out
134 );
135
136 static void registerKernelClass() {
137 static_assert((std::is_same<TT, int8_t>::value) || (std::is_same<TT, uint8_t>::value));
138 static_assert(INP_W_PAD % 16 == 0);
139 REGISTER_FUNCTION(QLinearSoftmaxSingleaxis::filter);
140 }
141};
145#endif // QLINEARSOFTMAX_H_
Vector implementation using fastexp2 method, float multiplication for exp estimation QLinearSoftmaxFl...
Definition qlinearsoftmax.h:65
Scalar implementation. QLinearSoftmaxScalar<10,20,32> takes 517922 cycles for expf,...
Definition qlinearsoftmax.h:29
Vector implementation using fastexp2 method for single axis, QLinearSoftmaxSingleaxis<10,...
Definition qlinearsoftmax.h:107