13namespace Experimental {
17 return static_cast<std::underlying_type_t<Options>
>(opA) |
static_cast<std::underlying_type_t<Options>
>(opB);
19std::underlying_type_t<Options>
operator|(std::underlying_type_t<Options> opA,
Options opB) {
20 return opA |
static_cast<std::underlying_type_t<Options>
>(opB);
59 return f->second.shape;
63 return f2->second.shape();
67 throw std::runtime_error(
"TMVA SOFIE tensor [" +
name +
"] is an input tensor with unspecified dimension parameter");
71 return f4->second.shape;
74 throw std::runtime_error(
"TMVA SOFIE tensor [" +
name +
"] is a dynamic tensor. Use GetDynamicTensorShape instead of GetTensorShape");
76 throw std::runtime_error(
"TMVA SOFIE tensor [" +
name +
"] for which the shape is requested is not found");
81 return f->second.shape;
84 return f->second.shape;
94 return f->second.type;
98 return f2->second.type();
102 return f3->second.type;
106 return f4->second.type;
110 return f5->second.type;
113 throw std::runtime_error(
"TMVA SOFIE tensor [" +
name +
"] for which the type is requested is not found");
128 throw std::runtime_error(
"TMVA-SOFIE: input tensor with name " + input_name +
" already exists \n");
138 throw std::runtime_error(
"TMVA-SOFIE: input tensor with name " + input_name +
" already exists \n");
150 auto libs = op->GetStdLibs();
151 for (
auto& stdlib : libs) {
154 if (order_execution >= 0) {
165 throw std::runtime_error(
"TMVA-SOFIE: initialized tensor with name " + tensor_name +
" already exists \n");
175 throw std::runtime_error(
"TMVA-SOFIE: initialized tensor with name " + tensor_name +
" already exists \n");
198 if (!int_shape.empty())
207 throw std::runtime_error(
"TMVA-SOFIE: intermediate tensor with name " + tensor_name +
" already exists \n");
216 throw std::runtime_error(
"TMVA-SOFIE: intermediate tensor with name " + tensor_name +
" already exists \n");
221 for (
auto &
d : shape) {
226 if (
d.dim !=
size_t(-1)) {
236 for(
auto& it : outputtensornames) {
242 for(
auto& it:curr_output_tensors) {
251 throw std::runtime_error(
"TMVA-SOFIE: tensor " + tensor_name +
" not found when trying to update it");
260 throw std::runtime_error(
"TMVA-SOFIE: tensor " + tensor_name +
" not found when trying to get its data");
262 return f->second.sharedptr();
269 throw std::runtime_error(
"TMVA-SOFIE: initialized tensor " + tensor_name +
" not found when trying to get its info");
271 t->second.SetNotWritable();
283 for (
auto &
input : originalInputTensorInfos) {
284 if (verbose) std::cout <<
"looking at the tensor " <<
input.first << std::endl;
291 if (!
input.second.shape.empty()) {
292 auto & d0 =
input.second.shape[0];
294 if (verbose) std::cout <<
"Fix the batch size to " << batchSize << std::endl;
295 d0 =
Dim{
static_cast<size_t>(batchSize)};
298 for (
auto &
d :
input.second.shape) {
299 if (
d.isParam && (
d.param ==
"bs" ||
d.param ==
"batch_size")) {
300 d =
Dim{
static_cast<size_t>(batchSize)};
301 if (verbose) std::cout <<
"Input shape has bs or batch_size as names. Fix the batch size to " << batchSize << std::endl;
308 if (!shape.empty()) {
317 for (
auto &
d :
input.second.shape) {
332 bool modelHasWeights =
false;
335 modelHasWeights =
true;
339 if (!modelHasWeights)
347 std::cout <<
"Initializing operator " << i <<
" " <<
typeid(
r).
name() << std::endl;
349 op->Initialize(*
this);
356 fGC +=
"// initialized tensors\n";
363 std::stringstream strs;
365 strs <<
"float tensor_" << i.first <<
"[" <<
length <<
"] = {";
366 float const *
data = i.second.data<
float>();
367 for (
size_t idx = 0; idx <
length; idx++) {
368 strs << std::setprecision(std::numeric_limits<float>::max_digits10) <<
data[idx];
369 if (idx <
length-1) strs <<
", ";
374 strs <<
"int64_t tensor_" << i.first <<
"[" <<
length <<
"] = {";
375 int64_t
const *
data = i.second.data<int64_t>();
376 for (
size_t idx = 0; idx <
length; idx++) {
378 if (idx <
length-1) strs <<
", ";
387 fGC +=
"std::vector<float> fTensor_" + i.first +
" = std::vector<float>(" + std::to_string(
length) +
");\n";
388 fGC +=
"float * tensor_" + i.first +
" = fTensor_" + i.first +
".data();\n";
396 fGC +=
"\n//--- declare and allocate the intermediate tensors\n";
400 fGC +=
"std::vector<float> fTensor_" + i.first +
" = std::vector<float>(" + std::to_string(
length) +
");\n";
401 fGC +=
"float * tensor_" + i.first +
" = fTensor_" + i.first +
".data();\n";
404 fGC +=
"std::vector<double> fTensor_" + i.first +
" = std::vector<double>(" + std::to_string(
length) +
");\n";
405 fGC +=
"double * tensor_" + i.first +
" = fTensor_" + i.first +
".data();\n";
408 fGC +=
"std::vector<int64_t> fTensor_" + i.first +
" = std::vector<int64_t>(" + std::to_string(
length) +
");\n";
409 fGC +=
"int64_t * tensor_" + i.first +
" = fTensor_" + i.first +
".data();\n";
412 fGC +=
"std::vector<bool> fTensor_" + i.first +
" = std::vector<bool>(" + std::to_string(
length) +
");\n";
419 fGC +=
"//--- declare the dynamic tensors\n";
422 fGC +=
"std::vector<float> fTensor_" + i.first +
";\n";
423 fGC +=
"float * tensor_" + i.first +
" = nullptr;\n";
425 fGC +=
"std::vector<double> fTensor_" + i.first +
";\n";
426 fGC +=
"double * tensor_" + i.first +
" = nullptr;\n";
428 fGC +=
"std::vector<int64_t> fTensor_" + i.first +
";\n";
429 fGC +=
"int64_t * tensor_" + i.first +
" = nullptr;\n";
436 fGC +=
"//---- allocate the intermediate dynamic tensors\n";
437 std::stringstream out;
440 out <<
SP <<
"if (" <<
length <<
" > 0) {\n";
441 out <<
SP <<
SP <<
"fTensor_" << i.first <<
".resize(" <<
length <<
");\n";
442 out <<
SP <<
SP <<
"tensor_" << i.first <<
" = fTensor_" << i.first <<
".data();\n";
453 throw std::runtime_error(
"TMVA-SOFIE: output size=0 are not supported");
455 std::string outputType;
459 if (outputSize == 1) {
460 fGC +=
"std::vector<" + outputType +
"> ";
463 for (
size_t i = 1; i < outputSize; i++) {
465 throw std::runtime_error(
"TMVA-SOFIE: different output tensor types are not supported");
467 fGC +=
"std::vector<std::vector<" + outputType +
">> ";
472 std::unordered_map<std::string, int> inputParams;
478 for (
auto &
d : shape) {
479 std::string pName =
d.param;
481 if (
d.isParam && inputParams.count(pName) == 0) {
482 fGC +=
"size_t " +
d.param +
",";
483 inputParams[pName] = i_input;
489 fGC +=
"float* tensor_" +
name +
",";
493 fGC +=
"int32_t* tensor_" +
name +
",";
497 fGC +=
"int64_t* tensor_" +
name +
",";
501 fGC +=
"double* tensor_" +
name +
",";
505 fGC +=
"bool* tensor_" +
name +
",";
509 throw std::runtime_error(
"TMVA-SOFIE: input tensor " +
name +
510 " is of a data type which is not yet supported.");
519 for (
size_t id = 0;
id <
fOperators.size();
id++) {
523 if (outputSize == 1) {
528 fGC +=
SP +
"return fTensor_" + tensorName +
";\n";
534 fGC +=
SP +
"std::vector<bool> ret (fTensor_" + tensorName +
".begin(), fTensor_" + tensorName +
535 ".begin() + " + outputLength +
");\n";
537 fGC +=
SP +
"std::vector<" + outputType +
"> ret (tensor_" + tensorName +
", tensor_" + tensorName +
" + " +
538 outputLength +
");\n";
540 fGC +=
SP +
"return ret;\n";
544 fGC +=
SP +
"std::vector<std::vector<" + outputType +
">> ret({";
545 for (
size_t i = 0; i < outputSize; i++) {
547 if (!tensorName.empty()) {
549 fGC +=
"fTensor_" + tensorName;
553 fGC +=
"std::vector<bool>(fTensor_" + tensorName +
".begin(), fTensor_" + tensorName +
".begin() + " +
554 outputLength +
");\n";
556 fGC +=
"std::vector<" + outputType +
">(tensor_" + tensorName +
", tensor_" + tensorName +
" + " +
560 if (i < outputSize - 1)
567 fGC +=
SP +
"return ret;\n";
572void RModel::Generate(std::underlying_type_t<Options> options,
int batchSize,
long pos,
bool verbose) {
588 std::runtime_error(
"TMVA-SOFIE: RModel::Generate: cannot use a separate weight file without generating a Session class");
591 if (
static_cast<std::underlying_type_t<Options>
>(
Options::kGNN) & options)
602 fGC +=
"struct Session {\n";
612 for (
size_t id = 0;
id <
fOperators.size();
id++) {
613 std::string opName = std::to_string(
id);
619 std::string fileName =
fName;
626 fGC +=
"Session(std::string filename =\"" + fileName +
"\"";
630 fGC +=
"Session(std::string = \"\"";
637 fGC +=
" size_t " +
p.first +
" = " +
p.second;
643 fGC +=
"\n//--- reading weights from file\n";
653 for (
size_t id = 0;
id <
fOperators.size() ;
id++) {
666 fGC += (
"} //TMVA_SOFIE_" +
fName +
"\n");
667 fGC +=
"\n#endif // " + hgname +
"\n";
676 fGC +=
" std::ifstream f;\n";
677 fGC +=
" f.open(filename);\n";
678 fGC +=
" if (!f.is_open()) {\n";
679 fGC +=
" throw std::runtime_error(\"tmva-sofie failed to open file \" + filename + \" for input weights\");\n";
683 fGC +=
" f.seekg(" + std::to_string(pos) +
");\n";
686 fGC +=
" std::string tensor_name;\n";
687 fGC +=
" size_t length;\n";
692 if (!i.second.IsWeightTensor())
continue;
693 std::string tensor_name =
"tensor_" + i.first;
697 std::string slength = std::to_string(
length);
698 fGC +=
" f >> tensor_name >> length;\n";
699 fGC +=
" if (tensor_name != \"" + tensor_name +
"\" ) {\n";
700 fGC +=
" std::string err_msg = \"TMVA-SOFIE failed to read the correct tensor name; expected name is " +
701 tensor_name +
" , read \" + tensor_name;\n";
702 fGC +=
" throw std::runtime_error(err_msg);\n";
704 fGC +=
" if (length != " + slength +
") {\n";
705 fGC +=
" std::string err_msg = \"TMVA-SOFIE failed to read the correct tensor size; expected size is " +
706 slength +
" , read \" + std::to_string(length) ;\n";
707 fGC +=
" throw std::runtime_error(err_msg);\n";
709 fGC +=
" for (size_t i = 0; i < length; ++i)\n";
710 fGC +=
" f >> " + tensor_name +
"[i];\n";
711 fGC +=
" if (f.fail()) {\n";
712 fGC +=
" throw std::runtime_error(\"TMVA-SOFIE failed to read the values for tensor " + tensor_name +
"\");\n";
715 std::runtime_error(
"tmva-sofie tensor " + tensor_name +
" with type " +
ConvertTypeToString(i.second.type()) +
" cannot be read from a file");
718 fGC +=
" f.close();\n";
724 fGC +=
" std::unique_ptr<TFile> rootFile(TFile::Open(filename.c_str(), \"READ\"));\n";
725 fGC +=
" if (!rootFile->IsOpen()) {\n";
726 fGC +=
" throw std::runtime_error(\"tmva-sofie failed to open ROOT file for input weights\");\n";
729 std::string dirName =
fName +
"_weights";
730 fGC +=
" if (!rootFile->GetKey(\"" + dirName +
"\")) {\n";
731 fGC +=
" throw std::runtime_error(\"tmva-sofie failed to open ROOT directory for input weights\");\n";
736 if (!i.second.IsWeightTensor())
continue;
738 std::string tensor_name =
"tensor_" + i.first;
740 fGC +=
" fTensor_" + i.first +
" = *reinterpret_cast<std::vector<float>*>(rootFile->Get(\"";
741 fGC += dirName +
"/" + tensor_name +
"\"));\n";
743 fGC +=
" fTensor_" + i.first +
" = *reinterpret_cast<std::vector<double>*>(rootFile->Get(\"";
744 fGC += dirName + +
"/" + tensor_name +
"\"));\n";
746 fGC +=
" fTensor_" + i.first +
" = *reinterpret_cast<std::vector<int64_t>*>(rootFile->Get(\"";
747 fGC += dirName +
"/" + tensor_name +
"\"));\n";
749 std::runtime_error(
"tmva-sofie tensor " + tensor_name +
" with type " +
ConvertTypeToString(i.second.type()) +
" cannot be read from a ROOT file");
759 std::string fileExtension;
762 fileExtension =
".dat";
765 fileExtension =
".root";
768 fileExtension =
".dat";
780 throw std::runtime_error(
"SOFIE-GNN yet not supports writing to a ROOT file.");
784 std::string dirName =
fName +
"_weights";
786 if (outputFile->GetKey(dirName.c_str()))
787 outputFile->rmdir(dirName.c_str());
789 auto outputDir = outputFile->mkdir(dirName.c_str());
793 if (!item.second.IsWeightTensor())
continue;
794 std::string tensorName =
"tensor_" + item.first;
798 const float*
data = item.second.data<
float>();
800 outputDir->WriteObjectAny(&tensorDataVector,
"std::vector<float>", tensorName.c_str());
803 const double*
data = item.second.data<
double>();
805 outputDir->WriteObjectAny(&tensorDataVector,
"std::vector<double>", tensorName.c_str());
808 const int64_t*
data = item.second.data<int64_t>();
810 outputDir->WriteObjectAny(&tensorDataVector,
"std::vector<int64_t>", tensorName.c_str());
813 std::runtime_error(
"tmva-sofie tensor " + tensorName +
" with type " +
ConvertTypeToString(item.second.type()) +
814 " cannot be written to a ROOT file");
817 outputFile->Write(
filename.c_str());
832 std::runtime_error(
"tmva-sofie failed to open file " +
filename +
" for tensor weight data");
835 if (!i.second.IsWeightTensor()) {
839 std::string tensor_name =
"tensor_" + i.first;
840 f << tensor_name <<
" " <<
length <<
"\n";
842 const float *
data = i.second.data<
float>();
843 for (
size_t idx = 0; idx <
length; idx++) {
846 if (
value != 0. && std::abs(
value) < std::numeric_limits<float>::min() )
value = 0;
847 f << std::setprecision(std::numeric_limits<float>::max_digits10) <<
value;
848 f << ( (idx <
length-1) ?
" " :
"\n" );
852 std::runtime_error(
"tmva-sofie tensor " + tensor_name +
" with type " +
ConvertTypeToString(i.second.type()) +
" cannot be written to a file");
855 std::runtime_error(
"tmva-sofie failed to write tensor data to file for " + tensor_name);
857 long curr_pos =
f.tellp();
866 std::cout <<
"Model requires following inputs:\n";
868 std::cout <<
"Parametraised Tensor name: " << inputInfo.first <<
"\t";
870 std::cout <<
"shape: [";
871 for (
size_t i = 0; i < inputInfo.second.shape.size(); i++) {
872 if (inputInfo.second.shape[i].isParam) {
873 std::cout << inputInfo.second.shape[i].param;
875 std::cout << inputInfo.second.shape[i].dim ;
877 if (i < inputInfo.second.shape.size() - 1) std::cout <<
",";
879 std::cout <<
"]" << std::endl;
883 std::cout <<
"Fully Specified Tensor name: " << inputInfo.first <<
"\t";
885 std::cout <<
"shape: [";
886 for (
size_t i = 0; i < inputInfo.second.shape.size(); i++) {
887 std::cout << inputInfo.second.shape[i];
888 if (i < inputInfo.second.shape.size() - 1) std::cout <<
",";
890 std::cout <<
"]" << std::endl;
896 std::cout <<
"Model initialized the following tensors:\n";
898 std::cout <<
"Tensor name: \"" << it.first <<
"\"\t";
900 std::cout <<
"shape: [";
901 for (
size_t i = 0; i < it.second.shape().
size(); i++) {
902 std::cout << it.second.shape()[i];
903 if (i < it.second.shape().size() - 1) std::cout <<
",";
906 if (it.second.IsConstantTensor()) std::cout <<
" (Constant)";
907 else if (!it.second.IsWeightTensor()) std::cout <<
" (Not Writable)";
908 std::cout << std::endl;
914 std::cout <<
"Model specify the following intermediate tensors:\n";
916 std::cout <<
"Tensor name: \"" << it.first <<
"\"\t";
918 std::cout <<
"shape: [";
919 for (
size_t i = 0; i < it.second.shape.size(); i++) {
920 std::cout << it.second.shape[i];
921 if (i < it.second.shape.size() - 1) std::cout <<
",";
923 std::cout <<
"]" << std::endl;
929 std::cout <<
"Model specify the following dynamic tensors:\n";
931 std::cout <<
"Tensor name: \"" << it.first <<
"\"\t";
933 std::cout <<
"shape: [";
934 for (
size_t i = 0; i < it.second.shape.size(); i++) {
935 std::cout << it.second.shape[i].GetVal();
936 if (i < it.second.shape.size() - 1) std::cout <<
",";
938 std::cout <<
"]" << std::endl;
944 std::cout <<
"Model specify the following output tensors:\n";
946 std::cout <<
"Tensor name: \"" << it <<
"\"\t";
958 std::cout <<
"Tensor " <<
name <<
" not found in model's initialized tensor list" << std::endl;
962 std::cout <<
"Tensor name: " << it->first <<
"\t";
965 std::cout <<
"shape: [";
966 for (
size_t i = 0; i < it->second.shape().
size(); i++) {
967 std::cout << it->second.shape()[i];
968 length *= it->second.shape()[i];
969 if (i < it->second.shape().size() - 1) std::cout <<
",";
971 std::cout <<
"]" << std::endl;
972 bool ellipsis =
true;
978 std::cout <<
"data: [" << std::endl;
980 auto converted_data = it->second.data<
float>();
981 for (
int i =0; i < n_print; i++) {
982 std::cout << converted_data[i];
983 if (i < n_print - 1) std::cout <<
" ,";
986 if (ellipsis) std::cout <<
", ...";
987 std::cout <<
"]" << std::endl;
1013void RModel::Streamer(
TBuffer &R__b) {
1015 RModel::Class()->ReadBuffer(R__b,
this);
1017 i->second.CastPersistentToShared();
1022 i->second.CastSharedToPersistent();
1024 RModel::Class()->WriteBuffer(R__b,
this);
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
winID h TVirtualViewer3D TVirtualGLPainter p
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 filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
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
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 length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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 Atom_t Time_t type
Buffer base class used for serializing objects.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
void GenerateHeaderInfo(std::string &hgname)
std::unordered_set< std::string > fNeededBlasRoutines
void OutputGenerated(std::string filename="", bool append=false)
std::unordered_set< std::string > fNeededStdLib
WeightFileType fWeightFile
void AddBlasRoutines(std::vector< std::string > routines)
void AddNeededStdLib(std::string libname)
const ETensorType & GetTensorType(std::string name)
std::unordered_map< std::string, DynamicTensorInfo > fDynamicTensorInfos
bool IsDynamicTensor(const std::string &name) const
void AddIntermediateTensor(std::string tensor_name, ETensorType type, std::vector< Dim > dim_shape)
void GenerateIntermediateTensorInfo()
std::vector< Dim > GetDynamicTensorShape(std::string name)
void PrintIntermediateTensors()
void PrintOutputTensors()
bool CheckIfTensorAlreadyExist(std::string tensor_name)
std::vector< std::unique_ptr< ROperator > > fOperators
void OutputGenerated(std::string filename="", bool append=false)
void AddInputTensorInfo(std::string input_name, ETensorType type, std::vector< Dim > shape)
std::unordered_map< std::string, TensorInfo > fIntermediateTensorInfos
void AddOutputTensorNameList(std::vector< std::string > output_tensor_names)
std::unordered_map< std::string, TensorInfo > fReadyInputTensorInfos
void AddConstantTensor(std::string tensor_name, ETensorType type, std::vector< std::size_t > shape, std::shared_ptr< void > data)
void AddDynamicTensor(std::string tensor_name, ETensorType type, std::vector< Dim > shape)
void AddInitializedTensor(std::string tensor_name, ETensorType type, std::vector< std::size_t > shape, std::shared_ptr< void > data)
RModel & operator=(RModel &&other)
void AddInputTensorName(std::string name)
void PrintDynamicTensors()
std::vector< std::string > fOutputTensorNames
void GenerateDynamicTensorInfo()
bool IsInitializedTensor(const std::string &name) const
void PrintInitializedTensors()
void AddOperator(std::unique_ptr< ROperator > op, int order_execution=-1)
RModel()=default
Default constructor.
void HeadInitializedTensors(std::string name, int n_print=50)
void Initialize(int batchSize=-1, bool verbose=false)
const std::vector< size_t > & GetTensorShape(std::string name)
bool IsInputTensor(const std::string &name) const
long WriteInitializedTensorsToFile(std::string filename="")
void Generate(std::underlying_type_t< Options > options, int batchSize=-1, long pos=0, bool verbose=false)
std::unordered_map< std::string, InputTensorInfo > fInputTensorInfos
std::shared_ptr< void > GetInitializedTensorData(std::string tensor_name)
void ReadInitializedTensorsFromFile(long)
std::unordered_map< std::string, std::string > fShapeParams
void SetNotWritableInitializedTensor(const std::string &tensor_name)
void GenerateInitializedTensorInfo()
std::vector< std::string > fInputTensorNames
std::unordered_map< std::string, InitializedTensor > fInitializedTensors
void UpdateInitializedTensor(std::string tensor_name, ETensorType type, std::vector< std::size_t > shape, std::shared_ptr< void > data)
void UpdateOutputTensorList(std::vector< std::string > curr_output_tensor, std::vector< std::string > modify_output_tensor)
void PrintRequiredInputTensors()
std::string Clean_name(std::string input_tensor_name)
std::vector< Dim > ConvertShapeToDim(std::vector< size_t > shape)
Convert shape from integer format to dynamic one (based on Dim)
std::string ConvertDynamicShapeToLength(std::vector< Dim > shape)
std::string ConvertShapeToString(std::vector< size_t > shape)
std::string ConvertTypeToString(ETensorType type)
std::string ConvertDynamicShapeToString(std::vector< Dim > shape)
std::underlying_type_t< Options > operator|(Options opA, Options opB)
std::vector< size_t > ConvertShapeToInt(std::vector< Dim > shape)
Convert shape based on Dim to integer format.
std::size_t ConvertShapeToLength(std::vector< size_t > shape)
create variable transformations