1#ifndef TMVA_SOFIE_ROPERATOR_RNN_I
2#define TMVA_SOFIE_ROPERATOR_RNN_I
5namespace Experimental {
10-> std::vector<ETensorType> {
17-> std::vector<std::vector<size_t>> {
18 size_t num_directions =
input[1][0];
19 size_t hidden_size =
input[1][1];
21 size_t seq_length =
input[0][0];
22 size_t batch_size =
input[0][1];
23 std::vector<std::vector<size_t>> ret(
24 {{seq_length, num_directions, batch_size, hidden_size},
25 {num_directions, batch_size, hidden_size}});
28 size_t batch_size =
input[0][0];
29 size_t seq_length =
input[0][1];
30 std::vector<std::vector<size_t>> ret(
31 {{batch_size, seq_length, num_directions, hidden_size},
32 {batch_size, num_directions, hidden_size}});
42 if (!model.CheckIfTensorAlreadyExist(
fNX)) {
43 throw std::runtime_error(
"TMVA SOFIE RNN Op input tensor " +
fNX +
44 " is not found in model.");
48 throw std::runtime_error(
"TMVA SOFIE RNN Op input tensor " +
fNX +
49 " is not of 3 dimensions.");
51 if (!model.CheckIfTensorAlreadyExist(
fNW)) {
52 throw std::runtime_error(
"TMVA SOFIE RNN Op input tensor " +
fNW +
53 " is not found in model.");
57 throw std::runtime_error(
"TMVA SOFIE RNN Op input tensor " +
fNW +
58 " is not of 3 dimensions.");
60 if (!model.CheckIfTensorAlreadyExist(
fNR)) {
61 throw std::runtime_error(
"TMVA SOFIE RNN Op input tensor " +
fNR +
62 " is not found in model.");
66 throw std::runtime_error(
"TMVA SOFIE RNN Op input tensor " +
fNR +
67 " is not of 3 dimensions.");
70 if (!model.CheckIfTensorAlreadyExist(
fNB)) {
71 throw std::runtime_error(
"TMVA SOFIE RNN op input tensor " +
fNB +
72 " is not found in model.");
76 throw std::runtime_error(
"TMVA SOFIE RNN op input tensor " +
fNB +
77 " is not of 2 or 4 dimensions.");
81 auto original_data = model.GetInitializedTensorData(
fNB);
82 size_t num_directions =
fShapeW[0];
85 if (
fType ==
"float") {
86 float *original_bias =
static_cast<float *
>(original_data.get());
87 float *new_bias =
new float[num_directions * seq_length *
90 for (
size_t direction = 0; direction < num_directions;
96 for (
size_t seq = 0; seq < seq_length; seq++) {
97 for (
size_t batch = 0; batch < batch_size; batch++) {
105 std::vector<size_t> new_bias_shape = {num_directions, seq_length,
107 std::shared_ptr<void> new_bias_ptr(new_bias, std::default_delete<
float[]>());
108 model.UpdateInitializedTensor(
fNB, model.GetTensorType(
fNB),
109 new_bias_shape, new_bias_ptr);
116 throw std::runtime_error(
"TMVA SOFIE RNN Op input tensor " +
121 throw std::runtime_error(
"TMVA SOFIE RNN Op input tensor " +
126 if (!model.CheckIfTensorAlreadyExist(
fNInitial_h)) {
127 throw std::runtime_error(
"TMVA SOFIE RNN Op input tensor " +
132 throw std::runtime_error(
"TMVA SOFIE RNN Op input tensor " +
138 if (!model.CheckIfTensorAlreadyExist(
fNY)) {
139 model.AddIntermediateTensor(
fNY, model.GetTensorType(
fNX),
fShapeY);
142 if (!
fNY_h.empty()) {
144 if (!model.CheckIfTensorAlreadyExist(
fNY_h)) {
145 model.AddIntermediateTensor(
fNY_h, model.GetTensorType(
fNX),
151 if (activation !=
"Relu" && activation !=
"Tanh" &&
152 activation !=
"Sigmoid" && activation !=
"Affine" &&
153 activation !=
"LeakyRelu" && activation !=
"ThresholdRelu" &&
154 activation !=
"ScaledTanh" && activation !=
"HardSigmoid" &&
155 activation !=
"Elu" && activation !=
"Softsign" &&
156 activation !=
"Softplus") {
157 throw std::runtime_error(
"TMVA SOFIE - Activation function " +
158 activation +
" not implemented");
163 throw std::runtime_error(
164 "TMVA SOFIE - Invalid RNN direction fAttrDirection = " +
168 throw std::runtime_error(
169 "TMVA SOFIE - fAttrHiddenSize must be equal to " +
173 throw std::runtime_error(
174 "TMVA SOFIE - Layout fAttrLayout = " + std::to_string(
fAttrLayout) +
175 " must be 0 (timewise) or 1 (batchwise)");
185 model.AddNeededStdLib(
"cmath");
192 opName =
"op_" + opName;
193 std::stringstream out;
195 size_t num_directions =
fShapeW[0];
198 size_t input_size =
fShapeX[2];
201 out <<
"std::vector<" <<
fType <<
"> fVec_" << opName <<
"_input = std::vector<" <<
fType <<
">("
202 << seq_length * batch_size * input_size <<
");\n";
203 out <<
"std::vector<" <<
fType <<
"> fVec_" << opName <<
"_initial_hidden_state = std::vector<" <<
fType <<
">("
206 out <<
"std::vector<" <<
fType <<
"> fVec_" << opName <<
"_feedforward = std::vector<" <<
fType <<
">("
210 out <<
"std::vector<" <<
fType <<
"> fVec_" << opName <<
"_hidden_state = std::vector<" <<
fType <<
">("
211 << seq_length * num_directions * batch_size *
fAttrHiddenSize <<
");\n";
223 OpName =
"op_" + OpName;
224 std::stringstream out;
228 size_t input_size =
fShapeX[2];
229 size_t num_directions =
fShapeW[0];
233 if (
fType ==
"float") {
234 out <<
SP <<
"float *" << OpName <<
"_input = tensor_" <<
fNX <<
";\n";
238 out <<
SP <<
fType <<
" * " << OpName <<
"_input = fVec_" << OpName <<
"_input.data();\n";
240 out <<
SP <<
fType <<
" " << OpName <<
"_input[" << seq_length * batch_size * input_size <<
"];\n";
241 out <<
SP <<
"for(size_t seq = 0; seq < " << seq_length <<
"; seq++) {\n";
242 out <<
SP <<
SP <<
"for(size_t batch = 0; batch < " << batch_size <<
"; batch++) {\n";
243 out <<
SP <<
SP <<
SP <<
"for(size_t i = 0; i < " << input_size <<
"; i++) {\n";
244 out <<
SP <<
SP <<
SP <<
SP << OpName <<
"_input[seq * " << batch_size * input_size
245 <<
" + batch * " << input_size <<
" + i] = " <<
"tensor_" <<
fNX <<
"[batch * "
246 << seq_length * input_size <<
" + seq * " << input_size <<
" + i];\n";
247 out <<
SP <<
SP <<
SP <<
"}\n";
248 out <<
SP <<
SP <<
"}\n";
255 out <<
SP <<
fType <<
" *" << OpName <<
"_initial_hidden_state = " <<
" tensor_"
259 out <<
SP <<
fType <<
" * " << OpName <<
"_initial_hidden_state = fVec_" << OpName
260 <<
"_initial_hidden_state.data();\n";
262 out <<
fType <<
" " << OpName <<
"_initial_hidden_state[" << num_directions * batch_size *
265 for (
size_t direction = 0; direction < num_directions; direction++) {
266 out <<
SP <<
"for(size_t batch = 0; batch < " << batch_size <<
"; batch++) {\n";
268 out <<
SP <<
SP <<
SP << OpName <<
"_initial_hidden_state["
272 out <<
SP <<
SP <<
"}\n";
279 out <<
SP <<
fType <<
" * " << OpName <<
"_feedforward = fVec_" << OpName
280 <<
"_feedforward.data();\n";
282 out <<
SP <<
fType <<
" " << OpName <<
"_feedforward[" << seq_length * batch_size *
fAttrHiddenSize <<
"] = {0};\n";
286 out <<
SP <<
fType <<
" *" << OpName <<
"_hidden_state = tensor_" <<
fNY <<
";\n";
289 out <<
SP <<
fType <<
" * " << OpName <<
"_hidden_state = fVec_" << OpName <<
"_hidden_state.data();\n";
291 out <<
SP <<
fType <<
" " << OpName <<
"_hidden_state[" << seq_length * num_directions *
295 out <<
SP <<
"char " << OpName <<
"_transA = 'N';\n";
296 out <<
SP <<
"char " << OpName <<
"_transB = 'T';\n";
297 out <<
SP <<
"int " << OpName <<
"_m = " << seq_length * batch_size <<
";\n";
299 out <<
SP <<
"int " << OpName <<
"_k = " << input_size <<
";\n";
300 if (
fType ==
"float") {
301 out <<
SP <<
"float " << OpName <<
"_alpha = 1.;\n";
302 out <<
SP <<
"float " << OpName <<
"_beta = .0;\n";
305 out <<
SP <<
"int " << OpName <<
"_bias_size = " << seq_length * batch_size *
fAttrHiddenSize <<
";\n";
306 out <<
SP <<
"int " << OpName <<
"_incx = 1;\n";
307 out <<
SP <<
"int " << OpName <<
"_incy = 1;\n";
310 for (
size_t direction = 0; direction < num_directions; direction++) {
312 if (
fType ==
"float") {
313 if (direction == 0) {
314 out <<
SP <<
"BLAS::sgemm_(&" << OpName <<
"_transB, &" << OpName <<
"_transA, &"
315 << OpName <<
"_n, &" << OpName <<
"_m, &" << OpName <<
"_k, &" << OpName
316 <<
"_alpha, tensor_" <<
fNW <<
", &" << OpName <<
"_k, " << OpName
317 <<
"_input, &" << OpName <<
"_k, &" << OpName <<
"_beta, " << OpName
318 <<
"_feedforward, &" << OpName <<
"_n);\n";
320 out <<
SP <<
"size_t " << OpName <<
"_w_offset = " <<
fAttrHiddenSize * input_size
322 out <<
SP <<
"BLAS::sgemm_(&" << OpName <<
"_transB, &" << OpName <<
"_transA, &"
323 << OpName <<
"_n, &" << OpName <<
"_m, &" << OpName <<
"_k, &" << OpName
324 <<
"_alpha, tensor_" <<
fNW <<
" + " << OpName <<
"_w_offset, &" << OpName
325 <<
"_k, " << OpName <<
"_input, &" << OpName <<
"_k, &" << OpName <<
"_beta, "
326 << OpName <<
"_feedforward, &" << OpName <<
"_n);\n";
331 if (
fType ==
"float") {
332 if (direction == 0) {
333 out <<
SP <<
"BLAS::saxpy_(&" << OpName <<
"_bias_size, &" << OpName <<
"_alpha, tensor_"
334 <<
fNB <<
", &" << OpName <<
"_incx, " << OpName <<
"_feedforward, &" << OpName <<
"_incy);\n";
336 out <<
SP <<
"size_t " << OpName <<
"_bias_offset = "
338 out <<
SP <<
"BLAS::saxpy_(&" << OpName <<
"_bias_size, &" << OpName <<
"_alpha, tensor_"
339 <<
fNB <<
" + " << OpName <<
"_bias_offset, &" << OpName <<
"_incx, " << OpName
340 <<
"_feedforward, &" << OpName <<
"_incy);\n";
346 out <<
SP <<
"for (size_t seq = 0; seq < " << seq_length <<
"; seq++) {\n";
349 out <<
SP <<
SP <<
"size_t h_offset = seq * "
352 out <<
SP <<
SP <<
"std::copy(" << OpName <<
"_feedforward + offset, " << OpName
353 <<
"_feedforward + offset + size, " << OpName <<
"_hidden_state + h_offset);\n";
357 out <<
SP <<
"for (size_t seq = 0; seq < " << seq_length <<
"; seq++) {\n";
359 out <<
SP <<
SP <<
"size_t index = " << seq_length - 1 <<
" - seq;\n";
361 out <<
SP <<
SP <<
"size_t index = seq;\n";
364 out <<
SP <<
SP <<
"int m2 = " << batch_size <<
";\n";
365 out <<
SP <<
SP <<
"size_t offset = index * "
369 out <<
SP <<
SP <<
"if (seq == 0) {\n";
372 out <<
SP <<
SP <<
SP <<
"size_t r_offset = "
374 out <<
SP <<
SP <<
SP <<
"size_t initial_hidden_state_offset = "
376 if (
fType ==
"float") {
377 out <<
SP <<
SP <<
SP <<
"BLAS::sgemm_(&" << OpName <<
"_transB, &" << OpName
378 <<
"_transA, &" << OpName <<
"_n, &m2, &" << OpName <<
"_n, &" << OpName
379 <<
"_alpha, tensor_" <<
fNR <<
" + r_offset, &" << OpName <<
"_n, " << OpName
380 <<
"_initial_hidden_state + initial_hidden_state_offset, &" << OpName <<
"_n, &"
381 << OpName <<
"_alpha, " << OpName <<
"_hidden_state + offset, &" << OpName <<
"_n);\n";
384 out <<
SP <<
SP <<
"} else {\n";
386 out <<
SP <<
SP <<
SP <<
"size_t r_offset = "
389 out <<
SP <<
SP <<
SP <<
"size_t previous_offset = (index + 1) * "
393 out <<
SP <<
SP <<
SP <<
"size_t previous_offset = (seq - 1) * "
397 if (
fType ==
"float") {
398 out <<
SP <<
SP <<
SP <<
"BLAS::sgemm_(&" << OpName <<
"_transB, &" << OpName <<
"_transA, &"
399 << OpName <<
"_n, &m2, &" << OpName <<
"_n, &" << OpName <<
"_alpha, tensor_" <<
fNR
400 <<
" + r_offset, &" << OpName <<
"_n, " << OpName <<
"_hidden_state + previous_offset, &"
401 << OpName <<
"_n, &" << OpName <<
"_alpha, " << OpName <<
"_hidden_state + offset, &"
402 << OpName <<
"_n);\n";
404 out <<
SP <<
SP <<
"}\n";
408 out <<
SP <<
SP <<
"for (size_t i = offset; i < offset + size; i++) {\n";
409 if (
fType ==
"float") {
410 out <<
SP <<
SP <<
SP <<
"float x = (" << OpName <<
"_hidden_state[i] > " << -
fAttrClip
411 <<
") ? " << OpName <<
"_hidden_state[i] : " << -
fAttrClip <<
";\n";
413 out <<
SP <<
SP <<
SP << OpName <<
"_hidden_state[i] = (x < " <<
fAttrClip
415 out <<
SP <<
SP <<
"}\n";
420 out <<
SP <<
SP <<
"for (size_t i = offset; i < offset + size; i++) {\n";
421 out <<
SP <<
SP <<
SP <<
"if (" << OpName <<
"_hidden_state[i] < 0.)\n";
422 out <<
SP <<
SP <<
SP <<
SP << OpName <<
"_hidden_state[i] = 0.;\n";
423 out <<
SP <<
SP <<
"}\n";
425 out <<
SP <<
SP <<
"for (size_t i = offset; i < offset + size; i++) {\n";
426 if (
fType ==
"float") {
427 out <<
SP <<
SP <<
SP <<
"float ex = std::exp(-2 * " << OpName <<
"_hidden_state[i]);\n";
429 out <<
SP <<
SP <<
SP <<
SP << OpName <<
"_hidden_state[i] = (1. - ex) / (1. + ex);\n";
430 out <<
SP <<
SP <<
"}\n";
432 out <<
SP <<
SP <<
"for (size_t i = offset; i < offset + size; i++) {\n";
433 out <<
SP <<
SP <<
SP <<
SP << OpName <<
"_hidden_state[i] = 1. / (1. + std::exp(-" << OpName
434 <<
"_hidden_state[i]));\n";
435 out <<
SP <<
SP <<
"}\n";
437 out <<
SP <<
SP <<
"for (size_t i = offset; i < offset + size; i++) {\n";
440 out <<
SP <<
SP <<
"}\n";
442 out <<
SP <<
SP <<
"for (size_t i = offset; i < offset + size; i++) {\n";
443 if (
fType ==
"float") {
445 <<
" * "<< OpName <<
"_hidden_state[i]);\n";
448 <<
" * (1. - ex) / (1. + ex);\n";
449 out <<
SP <<
SP <<
"}\n";
451 out <<
SP <<
SP <<
"for (size_t i = offset; i < offset + size; i++) {\n";
452 if (
fType ==
"float") {
455 out <<
SP <<
SP <<
SP <<
"float b = (a > 0.) ? a : 0.;\n";
457 out <<
SP <<
SP <<
SP <<
SP << OpName <<
"_hidden_state[i] = (b < 1.) ? b : 1.;\n";
458 out <<
SP <<
SP <<
"}\n";
460 out <<
SP <<
SP <<
"for (size_t i = offset; i < offset + size; i++) {\n";
461 out <<
SP <<
SP <<
SP <<
"if (" << OpName <<
"_hidden_state[i] < 0.)\n";
463 <<
" * " << OpName <<
"_hidden_state[i];\n";
464 out <<
SP <<
SP <<
"}\n";
466 out <<
SP <<
SP <<
"for (size_t i = offset; i < offset + size; i++) {\n";
467 out <<
SP <<
SP <<
SP <<
"if (" << OpName <<
"_hidden_state[i] < "
469 out <<
SP <<
SP <<
SP <<
SP << OpName <<
"_hidden_state[i] = 0.;\n";
470 out <<
SP <<
SP <<
"}";
472 out <<
SP <<
SP <<
"for (size_t i = offset; i < offset + size; i++) {\n";
473 out <<
SP <<
SP <<
SP <<
"if (" << OpName <<
"_hidden_state[i] < 0.)\n";
475 <<
" * std::exp(" << OpName <<
"_hidden_state[i] - 1.);\n";
476 out <<
SP <<
SP <<
"}\n";
478 out <<
SP <<
SP <<
"for (size_t i = offset; i < offset + size; i++) {\n";
479 out <<
SP <<
SP <<
SP <<
SP << OpName <<
"_hidden_state[i] = " << OpName
480 <<
"_hidden_state[i] / (1. + abs(" << OpName <<
"_hidden_state[i]));\n";
481 out <<
SP <<
SP <<
"}\n";
483 out <<
SP <<
SP <<
"for (size_t i = offset; i < offset + size; i++) {\n";
484 out <<
SP <<
SP <<
SP <<
SP << OpName <<
"_hidden_state[i] = log(1. + std::exp("
485 << OpName <<
"_hidden_state[i]));\n";
486 out <<
SP <<
SP <<
"}\n";
494 out <<
SP <<
"for (size_t seq = 0; seq < " << seq_length <<
"; seq++) {\n";
495 out <<
SP <<
SP <<
"for (size_t batch = 0; batch < " << batch_size <<
"; batch++) {\n";
498 if (num_directions == 1) {
499 out <<
SP <<
SP <<
SP <<
SP <<
SP << OpName <<
"_hidden_state[seq * "
503 out <<
SP <<
SP <<
SP <<
SP <<
SP << OpName <<
"_hidden_state[seq * "
506 out <<
SP <<
SP <<
SP <<
SP <<
SP << OpName <<
"_hidden_state[seq * "
510 out <<
SP <<
SP <<
SP <<
SP <<
"}\n";
511 out <<
SP <<
SP <<
SP <<
"}\n";
512 out <<
SP <<
SP <<
"}\n";
518 if (!
fNY_h.empty()) {
522 out <<
SP <<
"std::copy(" << OpName <<
"_hidden_state, " << OpName <<
"_hidden_state + "
523 << yh_size <<
", tensor_" <<
fNY_h <<
");\n";
526 out <<
SP <<
"std::copy(" << OpName <<
"_hidden_state + " <<
offset <<
", " << OpName
527 <<
"_hidden_state + " <<
offset <<
" + " << yh_size <<
", tensor_" <<
fNY_h <<
");\n";
529 if (num_directions == 2) {
530 out <<
SP <<
"std::copy(" << OpName <<
"_hidden_state + " << yh_size <<
", " << OpName
531 <<
"_hidden_state + " << 2 * yh_size <<
", tensor_" <<
fNY_h <<
" + " << yh_size <<
");\n";
535 out <<
SP <<
"for (size_t batch = 0; batch < " << batch_size <<
"; batch++) {\n";
537 out <<
SP <<
SP <<
"std::copy(" << OpName <<
"_hidden_state + offset, " << OpName
541 out <<
SP <<
"for (size_t batch = 0; batch < " << batch_size <<
"; batch++) {\n";
543 out <<
SP <<
SP <<
"size_t offset = seq * " << num_directions * batch_size *
fAttrHiddenSize
546 out <<
SP <<
SP <<
"std::copy(" << OpName <<
"_hidden_state + offset, " << OpName
547 <<
"_hidden_state + offset + " <<
fAttrHiddenSize <<
", tensor_" <<
fNY_h <<
" + yh_offset);\n";
550 if (num_directions == 2) {
551 out <<
SP <<
"for (size_t batch = 0; batch < " << batch_size <<
"; batch++) {\n";
556 out <<
SP <<
SP <<
"std::copy(" << OpName <<
"_hidden_state + offset, " << OpName
557 <<
"_hidden_state + offset + " <<
fAttrHiddenSize <<
", tensor_" <<
fNY_h <<
" + yh_offset);\n";
564 for (
size_t direction = 0; direction < num_directions; direction++) {
565 out <<
SP <<
"for (size_t seq = 0; seq < " << seq_length <<
"; seq++) {\n";
566 out <<
SP <<
SP <<
"for (size_t batch = 0; batch < " << batch_size <<
"; batch++) {\n";
569 out <<
SP <<
SP <<
SP <<
"size_t y_offset = batch * " << seq_length * num_directions *
fAttrHiddenSize
571 out <<
SP <<
SP <<
SP <<
"std::copy(" << OpName <<
"_hidden_state + offset, " << OpName
572 <<
"_hidden_state + offset + " <<
fAttrHiddenSize <<
", tensor_" <<
fNY <<
" + y_offset);\n";
573 out <<
SP <<
SP <<
"}\n";
577 if (!
fNY_h.empty()) {
579 out <<
SP <<
"for (size_t batch = 0; batch < " << batch_size <<
"; batch++) {\n";
581 out <<
SP <<
SP <<
"size_t yh_offset = batch * " << num_directions *
fAttrHiddenSize <<
";\n";
582 out <<
SP <<
SP <<
"std::copy(" << OpName <<
"_hidden_state + offset, " << OpName
583 <<
"_hidden_state + offset + " <<
fAttrHiddenSize <<
", tensor_" <<
fNY_h <<
" + yh_offset);\n";
586 out <<
SP <<
"for (size_t batch = 0; batch < " << batch_size <<
"; batch++) {\n";
588 out <<
SP <<
SP <<
"size_t seq = " << seq_length - 1 <<
";\n";
592 out <<
SP <<
SP <<
"size_t offset = seq * " << num_directions * batch_size *
fAttrHiddenSize
594 out <<
SP <<
SP <<
"size_t yh_offset = batch * " << num_directions *
fAttrHiddenSize <<
";\n";
595 out <<
SP <<
SP <<
"std::copy(" << OpName <<
"_hidden_state + offset, " << OpName
596 <<
"_hidden_state + offset + " <<
fAttrHiddenSize <<
", tensor_" <<
fNY_h <<
" + yh_offset);\n";
599 if (num_directions == 2) {
600 out <<
SP <<
"for (size_t batch = 0; batch < " << batch_size <<
"; batch++) {\n";
603 out <<
SP <<
SP <<
"size_t yh_offset = batch * " << num_directions *
fAttrHiddenSize <<
" + "
605 out <<
SP <<
SP <<
"std::copy(" << OpName <<
"_hidden_state + offset, " << OpName
606 <<
"_hidden_state + offset + " <<
fAttrHiddenSize <<
", tensor_" <<
fNY_h <<
" + yh_offset);\n";
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
std::vector< size_t > fShapeB
Shape of the bias.
std::vector< ETensorType > TypeInference(std::vector< ETensorType > input)
Infers the type of the output tensors.
std::vector< float > fAttrActivationBeta
Scaling values used by some activation functions.
std::vector< std::vector< size_t > > ShapeInference(std::vector< std::vector< size_t > > input)
Infers the shape of the output tensors.
size_t fAttrHiddenSize
Number of the hidden layers.
std::string fNInitial_h
Name of the initial value of the hidden states.
std::vector< size_t > fShapeR
Shape of the recurrence.
std::string fNW
Name of the weights.
std::string fNB
Name of the bias.
std::vector< size_t > fShapeY
Shape of the output.
float fAttrClip
Clip threshold.
std::string fType
Type of the tensors.
size_t fAttrLayout
Data layout.
std::string fNY
Name of the output.
std::string fNSequence_lens
Name of the length of the sequences.
std::vector< size_t > fShapeSequence_lens
Shape of the length of the sequences.
std::string Generate(std::string OpName)
Generates the inference code.
std::string fNR
Name of the recurrence.
std::vector< float > fAttrActivationAlpha
Scaling values used by some activation functions.
std::vector< size_t > fShapeX
Shape of the input.
std::string fAttrDirection
Direction of processing.
std::string fNX
Name of the input.
void Initialize(RModel &model)
Initialize the model.
std::string GenerateSessionMembersCode(std::string opName)
std::string fNY_h
Name of the last sequence of the output.
std::vector< size_t > fShapeInitial_h
Shape of the initial value of the hidden states.
std::vector< size_t > fShapeW
Shape of the weights.
std::vector< std::string > fAttrActivations
Activation functions.
std::vector< size_t > fShapeY_h
Shape of the last sequence of the output.
const std::string SP
space used to correctly indent the generated C++ code
bool fUseSession
flag to identify if using the session class
create variable transformations
static uint64_t sum(uint64_t i)