1#ifndef TMVA_SOFIE_ROPERATOR_SubGraph
2#define TMVA_SOFIE_ROPERATOR_SubGraph
23 std::vector<std::string>
fNYs;
31 ROperator_If(
const std::string & nameX,
const std::vector<std::string> & nameYs, std::unique_ptr<RModel> model_then, std::unique_ptr<RModel> model_else):
39 [](
const std::string& s) -> std::string_view { return s; });
53 if (model.CheckIfTensorAlreadyExist(
fNX) ==
false){
54 throw std::runtime_error(
"TMVA SOFIE If Op Input Tensor is not found in model");
65 for (
size_t i = 0; i <
fNYs.size(); i++) {
68 auto soutput_name =
fModel_then->GetOutputTensorNames()[i];
69 auto shape =
fModel_then->GetTensorShape(soutput_name);
75 throw std::runtime_error(
"TMVA SOFIE If Op supports only all outputs of the same type");
77 model.AddIntermediateTensor(
fNYs[i],
fType, shape );
83 std::string
Generate(std::string opName)
override {
84 opName =
"op_" + opName;
86 throw std::runtime_error(
"TMVA If operator called to Generate without being initialized first");
88 std::stringstream out;
91 out <<
"\n//------ If operator\n";
92 out <<
SP <<
"std::vector<std::vector<" << typeName <<
">> outputs_" << opName <<
";\n";
94 out <<
SP <<
"if (fTensor_" <<
fNX <<
"[0] ) { \n";
96 out <<
SP <<
SP <<
"outputs_" << opName <<
" = "
99 out <<
SP <<
"} else {\n";
100 out <<
SP <<
SP <<
"outputs_" << opName <<
" = "
104 out <<
SP <<
"if (outputs_" << opName <<
".size() != " <<
fNYs.size() <<
")\n";
105 out <<
SP <<
SP <<
"throw std::runtime_error(\" If operator: invalid output size!\");\n\n";
106 for (
size_t i = 0; i <
fNYs.size(); i++) {
107 out <<
SP <<
"std::copy(outputs_" << opName <<
"[" << i <<
"].begin(), outputs_" << opName <<
"[" << i <<
"].end(), fTensor_" <<
fNYs[i] <<
".begin());\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 Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
std::shared_ptr< RModel > fModel_then
std::string fInputSignature_modelThen
std::string fInputSignature_modelElse
std::vector< ETensorType > TypeInference(std::vector< ETensorType > input) override
std::string Generate(std::string opName) override
ROperator_If(const std::string &nameX, const std::vector< std::string > &nameYs, std::unique_ptr< RModel > model_then, std::unique_ptr< RModel > model_else)
std::vector< std::string > fNYs
std::vector< std::vector< size_t > > ShapeInference(std::vector< std::vector< size_t > > input) override
std::shared_ptr< RModel > fModel_else
void Initialize(RModel &model) override
std::vector< std::string_view > fInputTensorNames
const std::string SP
space used to correctly indent the generated C++ code
std::vector< std::string_view > fOutputTensorNames
std::string Clean_name(std::string input_tensor_name)
std::string ConvertTypeToString(ETensorType type)
create variable transformations