onnx2versal
Loading...
Searching...
No Matches
graph_qlinearsoftmax.h
1#ifndef __QLINEARSOFTMAX_GRAPH_H__
2#define __QLINEARSOFTMAX_GRAPH_H__
3
4#include <adf.h>
5#include <pad.h>
6#include "qlinearsoftmax.h"
7
8
33template <
34 template<typename, int, int, int, int, int, int, int, int> class PAD,
35 template<typename, int, int, int> class QLINEARSOFTMAX,
36 typename TT, int INP_H, int INP_W, int INP_W_PAD>
37class QLinearSoftmaxStreamGraph : public adf::graph {
38
39 private:
40 adf::kernel k[1];
41 std::vector<adf::kernel> pad;
42 std::string id;
43
44 public:
45 adf::port<input> pin[1];
46 adf::port<output> pout[1];
47
49 float x_scale,
50 float y_scale,
51 TT x_zero,
52 TT y_zero
53 ) {
54 k[0] = adf::kernel::create_object<QLINEARSOFTMAX<TT, INP_H, INP_W, INP_W_PAD>>(
55 x_scale, y_scale, x_zero, y_zero);
56 adf::source(k[0]) = "qlinearsoftmax.cc";
57 adf::headers(k[0]) = {"qlinearsoftmax.h"};
58 adf::runtime<ratio>(k[0]) = 0.6;
59 adf::stack_size(k[0]) = 2048;
60
61 if (INP_W_PAD > INP_W) {
62 pad.push_back(
63 adf::kernel::create_object<PAD<TT, 1, INP_H, INP_W, INP_W_PAD, 0, 0, 0, INP_W_PAD-INP_W>>(x_zero));
64 adf::source(pad[0]) = "pad.cc";
65 adf::headers(pad[0]) = {"pad.h"};
66 adf::runtime<ratio>(pad[0]) = 0.6;
67
68 adf::connect<adf::stream> (pin[0], pad[0].in[0]);
69 adf::connect<adf::stream, adf::window<INP_H*INP_W_PAD>> (pad[0].out[0], k[0].in[0]);
70 } else {
71 adf::connect<adf::window<INP_H*INP_W_PAD>> (pin[0], k[0].in[0]);
72 }
73
74 adf::connect<adf::stream> (k[0].out[0], pout[0]);
75 adf::samples_per_iteration(k[0].out[0]) = INP_H*INP_W_PAD;
76 }
77
78};
82#endif // __QLINEARSOFTMAX_GRAPH_H__
Single instance graph.
Definition graph_qlinearsoftmax.h:37