Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROperator_Gemm.hxx
Go to the documentation of this file.
1#ifndef TMVA_SOFIE_ROPERATOR_GEMM
2#define TMVA_SOFIE_ROPERATOR_GEMM
3
4
6#include "TMVA/ROperator.hxx"
7#include "TMVA/RModel.hxx"
8
9#include <sstream>
10#include <algorithm>
11#include <iterator>
12#include <iomanip>
13#include <limits>
14#include <cassert>
15
16namespace TMVA{
17namespace Experimental{
18namespace SOFIE{
19
20
21 template <typename T>
23 {
24
25 private:
26 bool fIsDynamic = false;
27 bool fBroadcastBias = false;
28 bool fCheckBiasShapeAtRuntime = false; // flag to identify the need to do a run time check of bias shape compatibility in case of dynamic shapes and uni-directional broadcasting
29
30 float fAttrAlpha = 1.0;
31 float fAttrBeta = 1.0;
34
35 std::string fNA;
36 std::string fNB;
37 std::string fNC = "";
38 std::string fNY;
39 std::string fType;
41 std::vector<Dim> fShapeA;
42 std::vector<Dim> fShapeB;
43 std::vector<size_t> fShapeC;
44 std::vector<Dim> fDimShapeC;
45 std::vector<Dim> fShapeY;
46 RModel * fModel = nullptr;
47
48 public:
49
51 ROperator_Gemm(float alpha, float beta, int_t transA, int_t transB, std::string nameA, std::string nameB, std::string nameY, EActivationType activation=EActivationType::UNDEFINED):
52 fAttrAlpha(alpha), fAttrBeta(beta), fAttrTransA(transA), fAttrTransB(transB), fNA(UTILITY::Clean_name(nameA)),
53 fNB(UTILITY::Clean_name(nameB)), fNY(UTILITY::Clean_name(nameY))
54 {
56 fType = "float";
57 static_assert(std::is_same_v<T, float>,
58 "TMVA::SOFIE - Unsupported type parsing a Gemm operator");
61 }
62
63 ROperator_Gemm(float alpha, float beta, int_t transA, int_t transB, std::string nameA, std::string nameB, std::string nameC, std::string nameY, EActivationType activation=EActivationType::UNDEFINED):
64 fAttrAlpha(alpha), fAttrBeta(beta), fAttrTransA(transA), fAttrTransB(transB), fNA(UTILITY::Clean_name(nameA)),
65 fNB(UTILITY::Clean_name(nameB)), fNC(UTILITY::Clean_name(nameC)), fNY(UTILITY::Clean_name(nameY)), fActivation(activation)
66 {
68 fType = "float";
69
72 }
73
74 std::vector<ETensorType> TypeInference(std::vector<ETensorType> input) override {
75 ETensorType out = input[0];
76 return {out};
77 }
78
79 template <typename U>
80 std::vector<U> DoShapeInference(const std::vector<std::vector<U>> & input){
81 if (input.size() > 3) throw std::runtime_error("TMVA SOFIE Gemm Op Shape Inference only need 2 or 3 input tensor");
82 // accept tensor with input dimensions > 2
83 // example: A = (d1,d2,...,N1,N2) B = (d1,d2,...,N2,N3) --> Y = (d1,d2,..,N1,N3)
84 for (auto& i: input){
85 if (i.size() < 2){
86 throw std::runtime_error("TMVA SOFIE Gemm Op Shape Inference only accept input tensor with >=2 dimensions");
87 }
88 }
89
90 // when there are 3 inputs shape of Y is the one of C
91 if (input.size() == 3){
92 //shape of C is shape of Y
93 return input[2];
94 }
95 // ioffset cannot be less than 2
96 int ioffset = input[0].size()-2; // in case of tensors with dim > 2
97
98 std::vector<U> s_a(input[0].begin() + ioffset, input[0].begin() + ioffset + 2);
99 std::vector<U> s_b(input[1].begin() + ioffset, input[1].begin() + ioffset + 2);
100 // reverse in case of transpose
101 if (fAttrTransA){
102 std::reverse(s_a.begin(), s_a.end());
103 }
104 if (fAttrTransB){
105 std::reverse(s_b.begin(), s_b.end());
106 }
107 std::vector<U> s_y;
108 s_y.reserve(input[0].size());
109 if (input[0].size() > 2 && input[1].size() == input[0].size()) {
110 // in case of dim > 2 first dimensions are equal to the input ones not
111 // equal to 1 (e.g. (1,2,3) * (2,3,4) -> (2,2,4))
112 // here could probably use the Broadcasting function UTILITY::MultidirectionalBroadcastShape
113 for (size_t i = 0; i < input[0].size()-2; i++) {
114 Dim valueA = input[0][i];
115 Dim valueB = input[1][i];
116 if (valueA.GetVal() != valueB.GetVal()) {
117 if (valueB.GetVal() == "1")
118 s_y.push_back(input[0][i]);
119 else if (valueA.GetVal() == "1")
120 s_y.push_back(input[1][i]);
121 else if (!valueA.isParam && !valueB.isParam)
122 throw std::runtime_error("TMVA SOFIE Gemm Op - invalid input shapes " + valueA.GetVal() + " and "
123 + valueB.GetVal());
124 else if (valueA.isParam && valueB.isParam){
125 // check which parameter is first in RModel list
126 auto & dimNames = fModel->GetDimShapeNames();
127 auto p1 = std::find(dimNames.begin(), dimNames.end(), valueA.param);
128 auto p2 = std::find(dimNames.begin(), dimNames.end(), valueB.param);
129 if (p1 < p2) s_y.push_back(input[0][i]);
130 else s_y.push_back(input[1][i]);
131 }
132 else if (!valueA.isParam)
133 s_y.push_back(input[0][i]);
134 else if (!valueB.isParam)
135 s_y.push_back(input[1][i]);
136 else
137 throw std::runtime_error("TMVA SOFIE Gemm Op - invalid input shapes " + valueA.GetVal() + " and "
138 + valueB.GetVal());
139 }
140 else
141 s_y.push_back(input[0][i]);
142 }
143 }
144
145 s_y.push_back(s_a[0]);
146 s_y.push_back(s_b[1]);
147 return s_y;
148 }
149
150 std::vector<std::vector<size_t>> ShapeInference(std::vector<std::vector<size_t>> input) override {
151 std::vector<std::vector<size_t>> ret;
153 return ret;
154 }
155 std::vector<Dim> DynamicShapeInference(const std::vector<std::vector<Dim>> & input){
157 }
158
159
160
161 void Initialize(RModel& model) override {
162 //TODO: propagate A or B as specified by ONNX standard
163 fModel = &model;
164
165 if ((model.CheckIfTensorAlreadyExist(fNA) == false) || (model.CheckIfTensorAlreadyExist(fNB) == false) ){ //input must be a graph input, or already initialized intermediate tensor
166 throw std::runtime_error("TMVA SOFIE Gemm Op Input Tensor " + fNA + " or " + fNB + " is not found in model");
167 }
168 if (fNC != ""){
169 if (model.CheckIfTensorAlreadyExist(fNC) == false){ //input must be a graph input, or already initialized intermediate tensor
170 throw std::runtime_error("TMVA SOFIE Gemm Op Input Tensor " + fNC + " is not found in model");
171 }
172 }
173 if (model.IsDynamicTensor(fNA) || model.IsDimInputTensor(fNA) ) {
175 fIsDynamic = true;
176 } else {
177 auto shapeA_int = model.GetTensorShape(fNA);
179 }
180 // case A is of dim1 we prepend a 1 but we need to remove later
181 bool prependOne = false;
182 if (fShapeA.size() == 1) {
183 fShapeA.insert(fShapeA.begin(), Dim(1));
184 prependOne = true;
185 }
186
187 if (model.IsDynamicTensor(fNB) || model.IsDimInputTensor(fNB)) {
189 fIsDynamic = true;
190 }
191 else {
192 auto shapeB_int = model.GetTensorShape(fNB);
194 }
195 // case B is dim1 we append a 1 but we need to remove later
196 bool appendOne = false;
197 if (fShapeB.size() == 1) {
198 fShapeB.insert(fShapeB.end(), Dim(1));
199 appendOne = true;
200 }
201 // assume if not shape is 2 that extra values are 1.
202 // implement also MatMul case where we stack matrices (see numpy.matmul)
203 if (fShapeA.size() != fShapeB.size()) {
204 // if different dimensions we prepend 1 values
205 if (fShapeA.size() < fShapeB.size()) {
206 fShapeA.insert(fShapeA.begin(), fShapeB.size()-fShapeA.size(), Dim(1));
207 } else if (fShapeB.size() < fShapeA.size()) {
208 fShapeB.insert(fShapeB.begin(), fShapeA.size()-fShapeB.size(), Dim(1));
209 }
210 }
211
213 std::vector<size_t> shapeY = ConvertShapeToInt(fShapeY);
214
215 // bias is normally not dynamic (not support it for time being)
216 if (fNC != ""){
217 if (model.IsDynamicTensor(fNC))
219 else {
220 fShapeC = model.GetTensorShape(fNC);
222 }
223 // for dynamic outputs broadcasting is always needed
224 bool broadcast_needed = false;
225 if (fIsDynamic && shapeY.empty())
226 broadcast_needed = true;
227 else
228 // consider broadcasting also if they have different length
230
231
232 if (broadcast_needed) {
233 fBroadcastBias = true;
234 // check if broadcasting is compatible and note that prepend 1 to shapeC
236 // return flag must not have bit equal to 2 since this is a unidirectional broadcast of C->Y
237 //
238 if ((r.first & 2) == 2) {
239 throw std::runtime_error("TMVA SOFIE Gemm Op - bias tensor of shape " + ConvertDimShapeToString(fDimShapeC) + " cannot be uni-directional broadcasted to " + ConvertDimShapeToString(fShapeY));
240 } else if (r.first == 4) {
241 // we need to do a run time check of bias shape if it is compatible
243 }
245 }
246 }
247
248 // remove appended or prepended value of 1 in Y
249 if (prependOne) {
250 if (fIsDynamic)
251 fShapeY.erase(fShapeY.begin());
252 else
253 shapeY.erase(shapeY.begin());
254 }
255 if (appendOne) {
256 if (fIsDynamic)
257 fShapeY.erase(fShapeY.end()-1);
258 else
259 shapeY.erase(shapeY.end()-1);
260 }
261
262 if (!fIsDynamic)
264 else
266
267 if (model.Verbose()){
268 std::cout << "Gemm (or MatMul) " << " ---> " << fNY << " shape ";
269 if (fIsDynamic)
270 std::cout << ConvertDimShapeToString(fShapeY) << std::endl;
271 else
272 std::cout << ConvertShapeToString(shapeY) << std::endl;
273 }
274
275 model.AddNeededStdLib("algorithm");
276 }
277
278 std::string Generate(std::string opName) override {
279 opName = "op_" + opName;
280
281 // if (fShapeA.empty() || fShapeB.empty() || fShapeY.empty() || (fNC != "" && fShapeC.empty())) {
282 // throw std::runtime_error("TMVA SOFIE Gemm Op called to Generate without being initialized first");
283 // }
284 std::stringstream out;
285 out << "\n//--------- Gemm " << opName << " " << ConvertDimShapeToString(fShapeA) << " * " << ConvertDimShapeToString(fShapeB)
286 << " -> " << ConvertDimShapeToString(fShapeY) << "\n";
287 // need to consider case A and B have dim > 2 (for MatMul)
288 int64_t dimA = fShapeA.size();
289 int64_t dimB = fShapeB.size();
290 int64_t dimY = fShapeY.size();
291 int64_t dimC = fDimShapeC.size();
292 if (dimA != dimB || dimA != dimY || (fBroadcastBias && dimC != dimY)) {
293 std::cout << " shape A " << ConvertDimShapeToString(fShapeA)
294 << " shape B " << ConvertDimShapeToString(fShapeB)
295 << " shape C " << ConvertDimShapeToString(fDimShapeC)
296 << " shape Y " << ConvertDimShapeToString(fShapeY) << std::endl;
297 throw std::runtime_error("TMVA SOFIE Gemm(MatMul) has invalid shape for inputs or output");
298 }
299 auto m = (fAttrTransA ? fShapeA[dimA-1].GetVal() : fShapeA[dimA-2].GetVal());
300 auto n = (fAttrTransB ? fShapeB[dimB-2].GetVal() : fShapeB[dimB-1].GetVal());
301 auto k = (fAttrTransA ? fShapeA[dimA-2].GetVal() : fShapeA[dimA-1].GetVal());
302 // size of A: if (transposeA) is m*k else k*m
303 // size of B n*k
304 std::vector<Dim> sY = {fShapeY[dimY-2], fShapeY[dimY-1]};
305 // extra dimensions in case of stacked MatMul
306 std::vector<Dim> sExtraY;
307 for (int64_t i = 0; i < dimY-2; i++) {
308 sExtraY.push_back(fShapeY[i]);
309 }
310 auto lengthGemm = ConvertDimShapeToLength(sY); // size of the Gemm operation
311 auto lengthExtra_Y = ConvertDimShapeToLength(sExtraY); // extra length in case input tensors are of dim>2 (MatMul)
312 std::string lengthExtra_C;
313 std::vector<Dim> sExtraC;
314 std::vector<Dim> sC;
315 bool haveExtraC = false;
316 if (dimC > 2) {
317 sC = {fDimShapeC[dimC-2], fDimShapeC[dimC-1]};
318 for (int64_t i = 0; i < dimC-2; i++) {
319 sExtraC.push_back(fDimShapeC[i]);
320 }
322 if (lengthExtra_C != "1") haveExtraC = true;
323 } else if (dimC > 0) {
324 for (int64_t i = 0; i < dimC; i++) {
325 sC.push_back(fDimShapeC[i]);
326 }
327 }
328
329 // case bias is present
330 if (!fNC.empty()){
331 // when the 2 last dims of bias and Y are not compatible we need to perform a run time broadcast
332 if (sC != sY) fBroadcastBias = true;
333 if (!fBroadcastBias) {
334 // add a check in case broadcasting was not needed or done outside of session
335 // C should have smaller dimension of Y
336 if (!fIsDynamic) {
337 if ((std::stoi(lengthGemm) != std::stoi(ConvertDimShapeToLength(sC))) ||
338 ( haveExtraC && std::stoi(lengthExtra_Y) != std::stoi(lengthExtra_C)))
339 throw std::runtime_error("TMVA SOFIE Gemm Op " + opName + " Bias tensor " + fNC + " has not correct size "
340 + ConvertShapeToString(fShapeC) + " output length " + lengthGemm);
341 } else {
342 // add a dynamic check (C should not be a dynamic tensor)
343 out << SP << "assert(" << lengthGemm << " == " << ConvertDimShapeToLength(sC) << ");\n";
344 if (haveExtraC) out << SP << "assert(" << lengthExtra_Y << " == " << lengthExtra_C << ");\n";
345 }
346 }
347 } else {
348 fBroadcastBias = false;
349 //in this case fAttrBeta needs to be equal to zero otherwise second time we run we will use
350 // the previous result
351 if (fAttrBeta != 0) {
352 // some model don't have bias but Beta is not zero - force it to zero
353 fAttrBeta = 0;
354 std::cout << "WARNING: TMVA SOFIE Gemm Op " + opName + " Bias tensor is not present but beta value in Gemm is not zero - force it to zero\n";
355 }
356 }
357
358 // include MatMul case where we stack the Gemm operations
359 // exclude case where we have only 1's in the additional dims
360 bool doStackMul = dimY > 2 && ( fIsDynamic || std::stoi(lengthExtra_Y) > 1);
361 // compute input offset for stack multiplications
362 std::string lengthExtra_A;
363 std::string lengthExtra_B;
364 std::string increment_A;
365 std::string increment_B;
366
367 if (doStackMul) {
368 std::vector<Dim> sA(fShapeA.begin(), fShapeA.begin()+dimA-2);
369 std::vector<Dim> sB(fShapeB.begin(), fShapeB.begin()+dimB-2);
370 std::vector<Dim> mA = {fShapeA[dimA-2], fShapeA[dimA-1]};
371 std::vector<Dim> mB = {fShapeB[dimB-2], fShapeB[dimB-1]};
374 // if A ( b, m, k) and B (b, k, n) these are the strides of A and B ( m*k for A and n*k for B )
377 }
378 bool extraA = (doStackMul && lengthExtra_A != "1");
379 bool extraB = (doStackMul && lengthExtra_B != "1");
381 // run time check for bias broadcasting
382 std::string biasShapeType = opName + "_biasShapeType";
384 // create a flag according to bias shape:
385 // = 1 for (1,Y2)
386 // = 2 for (Y1,1)
387 // = 3 for a scalar
388 out << SP << "int " << biasShapeType << " = 0;\n";
389 // case vector of columns
390 if (sC[0].GetVal() != "1" && sC[1].GetVal() != sY[1].GetVal())
391 out << SP << "if (" << sC[0] << " == 1 && " << sC[1] << " == " << sY[1] << ")\n";
392 else if (sC[0].GetVal() == "1")
393 out << SP << "if (" << sC[1] << " == " << sY[1] << ")\n";
394 else if (sC[1].GetVal() == sY[1].GetVal())
395 out << SP << "if (" << sC[0] << " == 1)\n";
396
397 out << SP << SP << biasShapeType << " = 1;\n";
398
399 // case vector of rows
400 if (sC[1].GetVal() != "1" && sC[0].GetVal() != sY[0].GetVal())
401 out << SP << "else if (" << sC[1] << " == 1 && " << sC[0] << " == " << sY[0] << ")\n";
402 else if (sC[1].GetVal() == "1")
403 out << SP << "else if (" << sC[0] << " == " << sY[0] << ")\n";
404 else if (sC[0].GetVal() == sY[0].GetVal())
405 out << SP << "else if (" << sC[1] << " == 1)\n";
406
407 out << SP << SP << biasShapeType << " = 2;\n";
408
409 // case scalar
410 if (sC[0].GetVal() != "1" && sC[1].GetVal() != "1")
411 out << SP << "else if (" << sC[0] << " == 1 && " << sC[1] << " == 1 )\n";
412 else if (sC[0].GetVal() == "1")
413 out << SP << "else if (" << sC[1] << " == 1)\n";
414 else if (sC[1].GetVal() == "1")
415 out << SP << "else if (" << sC[0] << " == 1)\n";
416 out << SP << SP << biasShapeType << " = 3;\n";
417 out << SP << "else\n";
418 out << SP << SP << "throw std::runtime_error(\"TMVA SOFIE Gemm Op - bias tensor "
419 << ConvertDimShapeToString(fDimShapeC) << " cannot be broadcasted to "
420 << ConvertDimShapeToString(fShapeY) << "\");\n";
421 }
422 auto SP2 = SP;
423 if (doStackMul) {
424 out << SP << "size_t " << opName << "_y_offset = 0;\n"; // needed if we stack the gemm operations
425 if (extraA)
426 out << SP << "size_t " << opName << "_A_offset = 0;\n";
427 if (extraB)
428 out << SP << "size_t " << opName << "_B_offset = 0;\n";
429 if (extraC)
430 out << SP << "size_t " << opName << "_C_offset = 0;\n";
431 out << SP << "for (size_t i = 0; i < " << lengthExtra_Y << "; i++){\n";
432 SP2 += SP;
433 }
434 // do the bias broadcasting at run time by
435 // initializing output Y vector with bias values
436 if (fBroadcastBias) {
437
438 fAttrBeta = 1.;
439
440 // loop on first output dimension
441 out << SP2 << "for (size_t j = 0; j < " << sY[0] << "; j++) { \n";
442 out << SP2 << SP << "size_t y_index = ";
443 if (doStackMul) // add offset in case of stack multiplications (not sure if bias is present in these cases)
444 out << opName << "_y_offset + ";
445 if (sY[1].GetVal() != "1")
446 out << sY[1] << " * j;\n";
447 else
448 out << "j;\n";
449
450 std::string prefix = SP2 + SP + "TMVA::Experimental::SOFIE::";
451 std::string target = "tensor_" + fNY;
452 if (sC.size() != 2) {
453 throw std::runtime_error("TMVA SOFIE Gemm Op - invalid rank for bias tensor " + ConvertDimShapeToString(fDimShapeC) + ConvertDimShapeToString(sC));
454 } if (sC[0].GetVal() == "1" && sC[1].GetVal() == sY[1].GetVal()) {
455 out << prefix << "Copy(" << target << " + y_index, tensor_" << fNC << ", " << sY[1] << ");\n";
456 } else if (sC[1].GetVal() == "1" && sC[0].GetVal() == sY[0].GetVal()) {
457 out << prefix << "Fill(" << target << " + y_index, tensor_" << fNC << "[j], " << sY[1] << ");\n";
458 } else if (sC[0].GetVal() == "1" && sC[1].GetVal() == "1") {
459 // scalar case
460 out << prefix << "Fill(" << target << " + y_index, tensor_" << fNC << "[0], " << sY[1] << ");\n";
461 } else if (fCheckBiasShapeAtRuntime) {
462 // in the generic dynamic case we check at run time that bias is compatible
463 // we check that bias[0] = 1 or equal to SY[0] and that bias[1] = 1 or equal to SY[1]
464 // tbd: this run-time check coul;d be moved outside the loop for better run time efficiency
465 out << SP2 << SP << "if (" << biasShapeType << " == 1)\n"; // case vector of columns
466 out << SP << prefix << "Copy(" << target << " + y_index, tensor_" << fNC << ", " << sY[1] << ");\n";
467 out << SP2 << SP << "else if (" << biasShapeType << " == 2)\n"; // case vector of rows
468 out << SP << prefix << "Fill(" << target << " + y_index, tensor_" << fNC << "[j], " << sY[1] << ");\n";
469 out << SP2 << SP << "else \n"; // scalar case
470 out << SP << prefix << "Fill(" << target << " + y_index, tensor_" << fNC << "[0], " << sY[1] << ");\n";
471 } else {
472 throw std::runtime_error("TMVA SOFIE Gemm Op - invalid shape for bias tensor " + ConvertDimShapeToString(fDimShapeC));
473 }
474
475 out << SP2 << "}\n";
476 }
477
478 if (fType == "float"){
479
480 out << SP2 << "TMVA::Experimental::SOFIE::Gemm_Call(" << "tensor_" << fNY;
481 if (doStackMul) out << " + " << opName << "_y_offset";
482 out << ", "
483 << (fAttrTransB ? "true, " : "false, ")
484 << (fAttrTransA ? "true, " : "false, ")
485 << n << ", " << m << ", " << k << ", ";
486 out << std::setprecision(std::numeric_limits<float>::max_digits10) << fAttrAlpha << ", tensor_" << fNB;
487 if (extraB) out << " + " << opName << "_B_offset";
488 out << ", tensor_" << fNA;
489 if (extraA) out << " + " << opName << "_A_offset";
490 out << ", " << std::setprecision(std::numeric_limits<float>::max_digits10) << fAttrBeta << ",";
491 // in the case of bias and no broadcasting needed - I need to add bias as an extra tensor in Gemm call
492 if (!fNC.empty() && !fBroadcastBias) {
493 out << "tensor_" << fNC;
494 if (extraC) {
495 out << " + " << opName << "_C_offset";
496 }
497 } else {
498 out << "nullptr";
499 }
500 out << ");\n";
501
502 }
503
504 if (doStackMul) {
505 out << SP << SP << opName << "_y_offset += " << lengthGemm << ";\n";
506 if (lengthExtra_A != "1")
507 out << SP << SP << opName << "_A_offset += " << increment_A << ";\n";
508 if (lengthExtra_B != "1")
509 out << SP << SP << opName << "_B_offset += " << increment_B << ";\n";
510 if (extraC)
511 // increment_C is lengthGEmm
512 out << SP << SP << opName << "_C_offset += " << lengthGemm << ";\n";
513 out << SP << "}\n"; // end of loop on the stacked multiplication
514 }
515
516 // fuse with Relu
518 out << SP << "//--- applying RELU to output\n";
519 std::string tnsr = "tensor_" + fNY;
521 out << SP << "TMVA::Experimental::SOFIE::Relu(" << tnsr << ", " << tnsr << ", " << reluSize << ");\n";
522 }
523
524 return out.str();
525 }
526
527 std::vector<std::string> GetBlasRoutines() override { return {"Gemm", "Gemv"}; }
528
529 };
530
531
532}//SOFIE
533}//Experimental
534}//TMVA
535
536
537#endif //TMVA_SOFIE_ROPERATOR_GEMM
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
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 r
const_iterator begin() const
const_iterator end() const
void AddNeededStdLib(std::string libname)
std::vector< size_t > GetTensorShape(const std::string &name) const
Definition RModel.cxx:64
bool IsDynamicTensor(const std::string &name) const
Definition RModel.cxx:286
void AddIntermediateTensor(std::string tensor_name, ETensorType type, std::vector< Dim > dim_shape)
Definition RModel.cxx:301
bool CheckIfTensorAlreadyExist(std::string tensor_name)
Definition RModel.cxx:157
void AddDynamicTensor(std::string tensor_name, ETensorType type, std::vector< Dim > shape)
Definition RModel.cxx:318
bool IsDimInputTensor(const std::string &name) const
Definition RModel.cxx:291
std::vector< Dim > GetDynamicTensorShape(const std::string &name) const
Definition RModel.cxx:111
ETensorType GetTensorType(std::string name) const
Definition RModel.cxx:125
const std::vector< std::string > & GetDimShapeNames() const
Definition RModel.hxx:208
ROperator_Gemm(float alpha, float beta, int_t transA, int_t transB, std::string nameA, std::string nameB, std::string nameC, std::string nameY, EActivationType activation=EActivationType::UNDEFINED)
std::vector< Dim > DynamicShapeInference(const std::vector< std::vector< Dim > > &input)
std::vector< ETensorType > TypeInference(std::vector< ETensorType > input) override
ROperator_Gemm(float alpha, float beta, int_t transA, int_t transB, std::string nameA, std::string nameB, std::string nameY, EActivationType activation=EActivationType::UNDEFINED)
std::vector< std::vector< size_t > > ShapeInference(std::vector< std::vector< size_t > > input) override
std::vector< U > DoShapeInference(const std::vector< std::vector< U > > &input)
std::string Generate(std::string opName) override
void Initialize(RModel &model) override
std::vector< std::string > GetBlasRoutines() override
std::vector< std::string_view > fInputTensorNames
Definition ROperator.hxx:50
const std::string SP
space used to correctly indent the generated C++ code
Definition ROperator.hxx:45
std::vector< std::string_view > fOutputTensorNames
Definition ROperator.hxx:51
const Int_t n
Definition legend1.C:16
std::vector< size_t > MultidirectionalBroadcastShape(std::vector< std::vector< size_t > >)
std::string ConvertDimShapeToString(const std::vector< Dim > &shape)
std::vector< Dim > ConvertShapeToDim(const std::vector< size_t > &shape)
Convert shape from integer format to dynamic one (based on Dim)
std::vector< size_t > ConvertShapeToInt(const std::vector< Dim > &shape)
Convert shape based on Dim to integer format.
std::string ConvertDimShapeToLength(const std::vector< Dim > &shape)
std::string ConvertShapeToString(const std::vector< size_t > &shape)
create variable transformations
TMarker m
Definition textangle.C:8