Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RModel.cxx
Go to the documentation of this file.
1#include <limits>
2#include <algorithm>
3#include <cctype>
4
5#include "TMVA/RModel.hxx"
6
7
8
9
10namespace TMVA{
11namespace Experimental{
12namespace SOFIE{
13
15 fInputTensorInfos = std::move(other.fInputTensorInfos);
16 fReadyInputTensorInfos = std::move(other.fReadyInputTensorInfos);
17 fOutputTensorNames = other.fOutputTensorNames;
18 fOperators = std::move(other.fOperators);
19 fInitializedTensors = std::move(other.fInitializedTensors);
20 fIntermediateTensorInfos = std::move(other.fIntermediateTensorInfos);
21 fName = other.fName;
22 fFileName = other.fFileName;
23 fParseTime = other.fParseTime;
24 fGC = other.fGC;
25 fNeededBlasRoutines = other.fNeededBlasRoutines;
26 fNeededStdLib = other.fNeededStdLib;
27 }
28
30 fInputTensorInfos = std::move(other.fInputTensorInfos);
31 fReadyInputTensorInfos = std::move(other.fReadyInputTensorInfos);
32 fOutputTensorNames = other.fOutputTensorNames;
33 fOperators = std::move(other.fOperators);
34 fInitializedTensors = std::move(other.fInitializedTensors);
35 fIntermediateTensorInfos = std::move(other.fIntermediateTensorInfos);
36 fName = other.fName;
37 fFileName = other.fFileName;
38 fParseTime = other.fParseTime;
39 fGC = other.fGC;
40 fNeededBlasRoutines = other.fNeededBlasRoutines;
41 fNeededStdLib = other.fNeededStdLib;
42 return *this;
43 }
44
45 RModel::RModel(std::string name, std::string parsedtime): fFileName (name), fParseTime(parsedtime) {
46 fName = fFileName.substr(0, fFileName.rfind("."));
47 }
48
49 const std::vector<size_t>& RModel::GetTensorShape(std::string name){
50 auto f = fReadyInputTensorInfos.find(name);
51 if (f != fReadyInputTensorInfos.end()){
52 return f->second.shape;
53 }
54 auto f2 = fInitializedTensors.find(name);
55 if (f2 != fInitializedTensors.end()){
56 return f2->second.fShape;
57 }
58 auto f3 = fInputTensorInfos.find(name);
59 if (f3 != fInputTensorInfos.end()){
60 throw std::runtime_error("TMVA SOFIE tensor [" + name + "] is an input tensor with unspecified dimension parameter");
61 }
62 auto f4 = fIntermediateTensorInfos.find(name);
63 if (f4 != fIntermediateTensorInfos.end()){
64 return f4->second.shape;
65 }
66
67 throw std::runtime_error("TMVA SOFIE tensor [" + name + "] for which the shape is requested is not found");
68 }
69
71 auto f = fReadyInputTensorInfos.find(name);
72 if (f != fReadyInputTensorInfos.end()){
73 return f->second.type;
74 }
75 auto f2 = fInitializedTensors.find(name);
76 if (f2 != fInitializedTensors.end()){
77 return f2->second.fType;
78 }
79 auto f3 = fInputTensorInfos.find(name);
80 if (f3 != fInputTensorInfos.end()){
81 return f3->second.type;
82 }
83 auto f4 = fIntermediateTensorInfos.find(name);
84 if (f4 != fIntermediateTensorInfos.end()){
85 return f4->second.type;
86 }
87
88 throw std::runtime_error("TMVA SOFIE tensor [" + name + "] for which the shape is requested is not found");
89 }
90
91 bool RModel::CheckIfTensorAlreadyExist(std::string tensor_name){
92 if (fReadyInputTensorInfos.find(tensor_name) != fReadyInputTensorInfos.end()) return true;
93 if (fInitializedTensors.find(tensor_name) != fInitializedTensors.end()) return true;
94 if (fIntermediateTensorInfos.find(tensor_name) != fIntermediateTensorInfos.end()) return true;
95 return false;
96 }
97
98 void RModel::AddInputTensorInfo(std::string input_name, ETensorType type, std::vector<Dim> shape){
99 input_name = UTILITY::Clean_name(input_name);
100 if (CheckIfTensorAlreadyExist(input_name)){
101 throw std::runtime_error("TMVA-SOFIE: input tensor with name " + input_name + " already exists \n");
102 }
103
104 InputTensorInfo inputInfo { type, shape };
105 fInputTensorInfos[input_name] = inputInfo;
106 }
107
108 void RModel::AddInputTensorInfo(std::string input_name, ETensorType type, std::vector<size_t> shape){
109 input_name = UTILITY::Clean_name(input_name);
110 if (CheckIfTensorAlreadyExist(input_name)){
111 throw std::runtime_error("TMVA-SOFIE: input tensor with name " + input_name + " already exists \n");
112 }
113 TensorInfo inputInfo { type, shape };
114 fReadyInputTensorInfos[input_name] = inputInfo;
115 }
116
117 void RModel::AddOperator(std::unique_ptr<ROperator> op, int order_execution){
118 if (order_execution >= 0) {
119 fOperators.insert(fOperators.begin() + order_execution, std::move(op));
120 }else{
121 fOperators.push_back(std::move(op));
122 }
123 }
124
125 void RModel::AddInitializedTensor(std::string tensor_name, ETensorType type, std::vector<std::size_t> shape, std::shared_ptr<void> data){
126 tensor_name = UTILITY::Clean_name(tensor_name);
127 //NB: own data
128 if (CheckIfTensorAlreadyExist(tensor_name)){
129 throw std::runtime_error("TMVA-SOFIE: initialized tensor with name " + tensor_name + " already exists \n");
130 }
131 InitializedTensor new_tensor {type, shape, data};
132 fInitializedTensors[tensor_name] = new_tensor;
133
134 }
135
136 void RModel::AddIntermediateTensor(std::string tensor_name, ETensorType type, std::vector<std::size_t> shape){
137 tensor_name = UTILITY::Clean_name(tensor_name);
138 if (CheckIfTensorAlreadyExist(tensor_name)){
139 throw std::runtime_error("TMVA-SOFIE: intermediate tensor with name " + tensor_name + " already exists \n");
140 }
141 TensorInfo new_tensor {type, shape};
142 fIntermediateTensorInfos[tensor_name] = new_tensor;
143 }
144
145 void RModel::AddOutputTensorNameList(std::vector<std::string> outputtensornames){
146 for(auto& it : outputtensornames){
148 }
149 }
150
151 void RModel::UpdateInitializedTensor(std::string tensor_name, ETensorType type, std::vector<std::size_t> shape, std::shared_ptr<void> data){
152 tensor_name = UTILITY::Clean_name(tensor_name);
153 if (!CheckIfTensorAlreadyExist(tensor_name)){
154 throw std::runtime_error("TMVA-SOFIE: tensor " + tensor_name + " not found when trying to update it");
155 }
156 InitializedTensor new_tensor {type, shape, data};
157 fInitializedTensors[tensor_name] = new_tensor;
158 }
159
160 std::shared_ptr<void> RModel::GetInitializedTensorData(std::string tensor_name){
161 auto f = fInitializedTensors.find(tensor_name);
162 if (f == fInitializedTensors.end()){
163 throw std::runtime_error("TMVA-SOFIE: tensor " + tensor_name + " not found when trying to get its data");
164 }else{
165 return f->second.fData;
166 }
167 }
168
170 for (auto& i : fOperators){
171 i->Initialize(*this);
172 }
173 }
174
175 void RModel::Generate(bool useSession, bool useWeightFile){
176 fUseSession = useSession; // session flag is used in operator initialize
177 Initialize();
178 fGC += ("//Code generated automatically by TMVA for Inference of Model file [" + fFileName + "] at [" + fParseTime.substr(0, fParseTime.length()-1) +"] \n");
179 // add header guards
180 std::string hgname = fName;
181 std::transform(hgname.begin(), hgname.end(), hgname.begin(), [](unsigned char c){ return std::toupper(c);} );
182 hgname = "TMVA_SOFIE_" + hgname;
183 fGC += "\n#ifndef " + hgname + "\n";
184 fGC += "#define " + hgname + "\n\n";
185 for (auto& i: fNeededStdLib) {
186 fGC += "#include<" + i + ">\n";
187 }
188 // for the session we need to include SOFIE_Common functions
189 //needed for convolution operator (need to add a flag)
190 fGC += "#include \"TMVA/SOFIE_common.hxx\"\n";
191 if (useWeightFile)
192 fGC += "#include <fstream>\n";
193
194 fGC += "\nnamespace TMVA_SOFIE_" + fName + "{\n";
195 if (!fNeededBlasRoutines.empty()) {
196 fGC += ("namespace BLAS{\n");
197 for (auto &routine : fNeededBlasRoutines) {
198 if (routine == "Gemm") {
199 fGC += ("\textern \"C\" void sgemm_(const char * transa, const char * transb, const int * m, const int * n, const int * k,\n"
200 "\t const float * alpha, const float * A, const int * lda, const float * B, const int * ldb,\n"
201 "\t const float * beta, float * C, const int * ldc);\n");
202 } else if (routine == "Gemv") {
203 fGC += ("\textern \"C\" void sgemv_(const char * trans, const int * m, const int * n, const float * alpha, const float * A,\n"
204 "\t const int * lda, const float * X, const int * incx, const float * beta, const float * Y, const int * incy);\n");
205 } else if (routine == "Axpy") {
206 fGC += ("\textern \"C\" void saxpy_(const int * n, const float * alpha, const float * x,\n"
207 "\t const int * incx, float * y, const int * incy);\n");
208 } else if (routine == "Copy") {
209 fGC += ("\textern \"C\" void scopy_(const int *n, const float* x, const int *incx, float* y, const int* incy);\n");
210 }
211 }
212 fGC += ("}//BLAS\n");
213 }
214 if (useSession) {
215 fGC += "struct Session {\n";
216 }
217 for (auto& i: fInitializedTensors){
218 if (i.second.fType == ETensorType::FLOAT){
219 size_t length = 1;
220 for (auto & dim: i.second.fShape){
221 length *= dim;
222 }
223 if (!useWeightFile) {
224 fGC += "float tensor_" + i.first + "[" + std::to_string(length) + "] = {";
225 std::shared_ptr<float> data = std::static_pointer_cast<float>(i.second.fData);
226 std::stringstream floats;
227 for (size_t idx = 0; idx < length-1; idx++){
228 floats << std::setprecision(std::numeric_limits<float>::max_digits10) << data.get()[idx] << ", ";
229 }
230 floats << std::setprecision(std::numeric_limits<float>::max_digits10) << data.get()[length-1];
231 fGC += floats.str();
232 fGC += "};\n";
233 }
234 else {
235 fGC += "std::vector<float> fTensor_" + i.first + " = std::vector<float>(" + std::to_string(length) + ");\n";
236 fGC += "float * tensor_" + i.first + " = fTensor_" + i.first + ".data();\n";
237 }
238
239 }
240 }
241 for (auto&i: fIntermediateTensorInfos){
242 if (i.second.type == ETensorType::FLOAT){
243 size_t length = 1;
244 for (auto & dim: i.second.shape){
245 length *= dim;
246 }
247 //fGC += "float tensor_" + i.first + "[" + std::to_string(length) + "];\n";
248 fGC += "std::vector<float> fTensor_" + i.first + " = std::vector<float>(" + std::to_string(length) + ");\n";
249 fGC += "float * tensor_" + i.first + " = fTensor_" + i.first + ".data();\n";
250 }
251 }
252 if (useSession) {
253 // add here specific operator code that needs to define session data members
254 fGC += "\n";
255 for (size_t id = 0; id < fOperators.size(); id++) {
256 std::string opName = std::to_string(id);
257 fGC += fOperators[id]->GenerateSessionMembersCode(opName);
258 }
259 fGC += "\n";
260 fGC += "Session(std::string filename =\"\") {\n";
261 // here add initialization and reading of weight tensors
262 if (useWeightFile) {
263 fGC += " if (filename.empty()) filename = \"" + fName + ".dat\";\n";
265 fUseWeightFile = useWeightFile;
266 }
267 // add here initialization code
268 for (size_t id = 0; id < fOperators.size() ; id++){
269 fGC += fOperators[id]->GenerateInitCode();
270 }
271 fGC += "}\n\n";
272 }
273
274 size_t outputSize = fOutputTensorNames.size();
275 if (outputSize == 1) {
277 if (f == fIntermediateTensorInfos.end()){
278 throw std::runtime_error("TMVA-SOFIE: output tensor " + fOutputTensorNames[0] + " not found when trying to get its info");
279 }else{
280 if (f->second.type == ETensorType::FLOAT){
281 fGC += "std::vector<float> ";
282 }
283 }
284 } else {
285 std::vector<ETensorType> outputTensorsTypes(outputSize);
286 for (size_t i = 0; i < outputSize; i++) {
288 if (f == fIntermediateTensorInfos.end()) {
289 throw std::runtime_error("TMVA-SOFIE: output tensor " + fOutputTensorNames[i]
290 + " not found when trying to get its info");
291 } else {
292 outputTensorsTypes[i] = f->second.type;
293 }
294 }
295 ETensorType outputType = outputTensorsTypes[0];
296 for (size_t i = 0; i < outputSize; i++) {
297 if (outputTensorsTypes[i] != outputType) {
298 throw std::runtime_error("TMVA-SOFIE: output tensor " + fOutputTensorNames[i] + " is of different type.");
299 }
300 }
301 if (outputType == ETensorType::FLOAT) {
302 fGC += "std::vector<std::vector<float>> ";
303 }
304 }
305
306 fGC += "infer(";
307 for (auto& i: fReadyInputTensorInfos){
308 size_t length = 1;
309 for (auto& dim: i.second.shape){
310 length *= dim;
311 }
312 if (i.second.type == ETensorType::FLOAT){
313 fGC += "float* tensor_" + i.first + ",";
314 }
315 }
316 fGC.pop_back(); //remove last ","
317 fGC += "){\n";
318
319 for (size_t id = 0; id < fOperators.size() ; id++){
320 fGC+= (fOperators[id]->Generate(std::to_string(id)));
321 }
322 if (outputSize == 1) {
323 size_t outputLength = ConvertShapeToLength(GetTensorShape(fOutputTensorNames[0]));
324
325 fGC += "\tstd::vector<float> ret (tensor_" + fOutputTensorNames[0] + ", tensor_" + fOutputTensorNames[0] + " + " +
326 std::to_string(outputLength) + ");\n";
327 } else {
328 for (size_t i = 0; i < outputSize; i++) {
329 if (!fOutputTensorNames[i].empty()) {
330 size_t outputLength = ConvertShapeToLength(GetTensorShape(fOutputTensorNames[i]));
331 fGC += "\tstd::vector<float> ret_";
332 fGC += std::to_string(i);
333 fGC += " (tensor_" + fOutputTensorNames[i] + ", tensor_" + fOutputTensorNames[i] + " + " +
334 std::to_string(outputLength) + ");\n";
335 }
336 }
337 fGC += "\tstd::vector<std::vector<float>> ret({";
338 for (size_t i = 0; i < outputSize; i++) {
339 if (fOutputTensorNames[i].empty()) {
340 fGC += "{}";
341 } else {
342 fGC += "ret_";
343 fGC += std::to_string(i);
344 }
345 if (i < outputSize - 1) {
346 fGC += ",";
347 }
348 }
349 fGC += "});\n";
350 }
351 fGC += "\treturn ret;\n";
352 fGC += "}\n";
353 if (useSession) {
354 fGC += "};\n";
355 }
356 fGC += ("} //TMVA_SOFIE_" + fName + "\n");
357 fGC += "\n#endif // " + hgname + "\n";
358 }
359
361 // generate the code to read initialized tensors from a text data file
362 fGC += " std::ifstream f;\n";
363 fGC += " f.open(filename);\n";
364 fGC += " if (!f.is_open()){\n";
365 fGC += " throw std::runtime_error(\"tmva-sofie failed to open file for input weights\");\n";
366 fGC += " }\n";
367 fGC += " std::string tensor_name;\n";
368 fGC += " int length;\n";
369
370 //loop on tensors and parse the file
371 for (auto& i: fInitializedTensors){
372 if (i.second.fType == ETensorType::FLOAT){
373 size_t length = 1;
374 for (auto & dim: i.second.fShape){
375 length *= dim;
376 }
377 std::string tensor_name = "tensor_" + i.first;
378 std::string slength = std::to_string(length);
379 fGC += " f >> tensor_name >> length;\n";
380 fGC += " if (tensor_name != \"" + tensor_name + "\" ) {\n";
381 fGC += " std::string err_msg = \"TMVA-SOFIE failed to read the correct tensor name; expected name is " +
382 tensor_name + " , read \" + tensor_name;\n";
383 fGC += " throw std::runtime_error(err_msg);\n";
384 fGC += " }\n";
385 fGC += " if (length != " + slength + ") {\n";
386 fGC += " std::string err_msg = \"TMVA-SOFIE failed to read the correct tensor size; expected size is " +
387 slength + " , read \" + std::to_string(length) ;\n";
388 fGC += " throw std::runtime_error(err_msg);\n";
389 fGC += " }\n";
390 fGC += " for (int i =0; i < length; ++i) \n";
391 fGC += " f >> " + tensor_name + "[i];\n";
392 }
393 }
394 fGC += " f.close();\n";
395 }
396
397 void RModel::WriteInitializedTensorsToFile(std::string filename) {
398 // write the initialized tensors in a text file
399 if (filename == ""){
400 filename = fName + ".data";
401 }
402
403 std::ofstream f;
404 f.open(filename);
405 if (!f.is_open()){
406 throw std::runtime_error("tmva-sofie failed to open file for tensor weight data");
407 }
408 for (auto& i: fInitializedTensors){
409 if (i.second.fType == ETensorType::FLOAT){
410 size_t length = 1;
411 for (auto &dim : i.second.fShape) {
412 length *= dim;
413 }
414 std::string tensor_name = "tensor_" + i.first;
415 f << tensor_name << " " << length << "\n";
416 const float * data = (std::static_pointer_cast<float>(i.second.fData)).get();
417 for (size_t idx = 0; idx < length - 1; idx++) {
418 f << std::setprecision(std::numeric_limits<float>::max_digits10) << data[idx] << " ";
419 }
420 f << std::setprecision(std::numeric_limits<float>::max_digits10) << data[length - 1];
421 f << "\n";
422 }
423 }
424 f.close();
425 }
426
428 std::cout << "Model requires following inputs:\n";
429 for (auto& inputInfo: fInputTensorInfos){
430 std::cout << "Parameterised Tensor name: " << inputInfo.first << "\t";
431 std::cout << "type: " << ConvertTypeToString(inputInfo.second.type) << "\t";
432 std::cout << "shape: [";
433 for (size_t i = 0; i < inputInfo.second.shape.size(); i++){
434 if (inputInfo.second.shape[i].isParam){
435 std::cout << inputInfo.second.shape[i].param;
436 }else{
437 std::cout << inputInfo.second.shape[i].dim ;
438 }
439 if (i < inputInfo.second.shape.size() - 1) std::cout << ",";
440 }
441 std::cout << "]" << std::endl;
442 }
443
444 for (auto& inputInfo: fReadyInputTensorInfos){
445 std::cout << "Fully Specified Tensor name: " << inputInfo.first << "\t";
446 std::cout << "type: " << ConvertTypeToString(inputInfo.second.type) << "\t";
447 std::cout << "shape: [";
448 for (size_t i = 0; i < inputInfo.second.shape.size(); i++){
449 std::cout << inputInfo.second.shape[i];
450 if (i < inputInfo.second.shape.size() - 1) std::cout << ",";
451 }
452 std::cout << "]" << std::endl;
453 }
454
455 }
456
458 std::cout << "Model initialized the following tensors:\n";
459 for (auto& it: fInitializedTensors){
460 std::cout << "Tensor name: \"" << it.first << "\"\t";
461 std::cout << "type: " << ConvertTypeToString(it.second.fType) << "\t";
462 std::cout << "shape: [";
463 for (size_t i = 0; i < it.second.fShape.size(); i++){
464 std::cout << it.second.fShape[i];
465 if (i < it.second.fShape.size() - 1) std::cout << ",";
466 }
467 std::cout << "]" << std::endl;
468 }
469 }
470
472 std::cout << "Model specify the following intermediate tensors:\n";
473 for (auto& it: fIntermediateTensorInfos){
474 std::cout << "Tensor name: \"" << it.first << "\"\t";
475 std::cout << "type: " << ConvertTypeToString(it.second.type) << "\t";
476 std::cout << "shape: [";
477 for (size_t i = 0; i < it.second.shape.size(); i++){
478 std::cout << it.second.shape[i];
479 if (i < it.second.shape.size() - 1) std::cout << ",";
480 }
481 std::cout << "]" << std::endl;
482 }
483 }
484
485 void RModel::HeadInitializedTensors(std::string name, int n_print){
486 auto it = fInitializedTensors.find(name);
487 if (it == fInitializedTensors.end()){
488 std::cout << "Tensor " << name << " not found in model's intiialized tensor list" << std::endl;
489 return;
490 }
491
492 std::cout << "Tensor name: " << it->first << "\t";
493 std::cout << "type: " << ConvertTypeToString(it->second.fType) << "\t";
494 int length =1;
495 std::cout << "shape: [";
496 for (size_t i = 0; i < it->second.fShape.size(); i++){
497 std::cout << it->second.fShape[i];
498 length *= it->second.fShape[i];
499 if (i < it->second.fShape.size() - 1) std::cout << ",";
500 }
501 std::cout << "]" << std::endl;
502 bool ellipsis = true;
503 if (n_print > length){
504 n_print = length;
505 ellipsis = false;
506 }
507
508 std::cout << "data: [" << std::endl;
509 //switch(it->second.type){
510 // case ETensorType::FLOAT : {
511 if (it->second.fType == ETensorType::FLOAT) {
512 auto converted_data = std::static_pointer_cast<float>(it->second.fData).get();
513 for (int i =0; i < n_print; i++){
514 std::cout << converted_data[i];
515 if (i < n_print - 1) std::cout << " ,";
516 }
517 // break;
518 // }
519 }
520 if (ellipsis) std::cout << ", ...";
521 std::cout << "]" << std::endl;
522
523 }
524
525 void RModel::OutputGenerated(std::string filename){
526 if (filename == ""){
527 filename = fName + ".hxx";
528 }
529 std::ofstream f;
530 f.open(filename);
531 if (!f.is_open()){
532 throw std::runtime_error("tmva-sofie failed to open file for output generated inference code");
533 }
534 f << fGC;
535 f.close();
536
537 // write weights in a text file
538 size_t pos = filename.find(".hxx");
539 filename.replace(pos,4,".dat");
541 }
542
543 void RModel::Streamer(TBuffer &R__b){
544 if (R__b.IsReading()) {
545 RModel::Class()->ReadBuffer(R__b, this);
546 for(auto i=RModel::fInitializedTensors.begin(); i!=RModel::fInitializedTensors.end();++i){
547 i->second.CastPersistentToShared();
548 }
549 }
550 else {
551 for(auto i=RModel::fInitializedTensors.begin(); i!=RModel::fInitializedTensors.end();++i){
552 i->second.CastSharedToPersistent();
553 }
554 RModel::Class()->WriteBuffer(R__b, this);
555 }
556 }
557
558}//SOFIE
559}//Experimental
560}//TMVA
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
XFontStruct * id
Definition TGX11.cxx:109
char name[80]
Definition TGX11.cxx:110
int type
Definition TGX11.cxx:121
Buffer base class used for serializing objects.
Definition TBuffer.h:43
Bool_t IsReading() const
Definition TBuffer.h:86
void AddOutputTensorNameList(std::vector< std::string > outputtensornames)
Definition RModel.cxx:145
const ETensorType & GetTensorType(std::string name)
Definition RModel.cxx:70
void Generate(bool useSession=true, bool useWeightFile=true)
Definition RModel.cxx:175
void AddIntermediateTensor(std::string tensor_name, ETensorType type, std::vector< std::size_t > shape)
Definition RModel.cxx:136
std::unordered_set< std::string > fNeededBlasRoutines
Definition RModel.hxx:40
bool CheckIfTensorAlreadyExist(std::string tensor_name)
Definition RModel.cxx:91
std::vector< std::unique_ptr< ROperator > > fOperators
Definition RModel.hxx:32
void AddInputTensorInfo(std::string input_name, ETensorType type, std::vector< Dim > shape)
Definition RModel.cxx:98
std::unordered_map< std::string, TensorInfo > fIntermediateTensorInfos
Definition RModel.hxx:29
std::unordered_map< std::string, TensorInfo > fReadyInputTensorInfos
Definition RModel.hxx:27
void AddInitializedTensor(std::string tensor_name, ETensorType type, std::vector< std::size_t > shape, std::shared_ptr< void > data)
Definition RModel.cxx:125
RModel & operator=(RModel &&other)
Definition RModel.cxx:29
std::vector< std::string > fOutputTensorNames
Definition RModel.hxx:30
std::unordered_set< std::string > fNeededStdLib
Definition RModel.hxx:43
void AddOperator(std::unique_ptr< ROperator > op, int order_execution=-1)
Definition RModel.cxx:117
void HeadInitializedTensors(std::string name, int n_print=50)
Definition RModel.cxx:485
void OutputGenerated(std::string filename="")
Definition RModel.cxx:525
const std::vector< size_t > & GetTensorShape(std::string name)
Definition RModel.cxx:49
std::unordered_map< std::string, InputTensorInfo > fInputTensorInfos
Definition RModel.hxx:26
std::shared_ptr< void > GetInitializedTensorData(std::string tensor_name)
Definition RModel.cxx:160
void WriteInitializedTensorsToFile(std::string filename="")
Definition RModel.cxx:397
std::unordered_map< std::string, InitializedTensor > fInitializedTensors
Definition RModel.hxx:28
void UpdateInitializedTensor(std::string tensor_name, ETensorType type, std::vector< std::size_t > shape, std::shared_ptr< void > data)
Definition RModel.cxx:151
std::string Clean_name(std::string input_tensor_name)
std::string ConvertTypeToString(ETensorType type)
std::size_t ConvertShapeToLength(std::vector< size_t > shape)
create variable transformations