1#ifndef TMVA_SOFIE_ROPERATOR_SubGraph
2#define TMVA_SOFIE_ROPERATOR_SubGraph
11namespace Experimental{
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):
50 throw std::runtime_error(
"TMVA SOFIE If Op Input Tensor is not found in model");
61 for (
size_t i = 0; i <
fNYs.size(); i++) {
64 auto soutput_name =
fModel_then->GetOutputTensorNames()[i];
65 auto shape =
fModel_then->GetTensorShape(soutput_name);
71 throw std::runtime_error(
"TMVA SOFIE If Op supports only all outputs of the same type");
80 opName =
"op_" + opName;
82 throw std::runtime_error(
"TMVA If operator called to Generate without being initialized first");
84 std::stringstream out;
87 out <<
"\n//------ If operator\n";
88 out <<
SP <<
"std::vector<std::vector<" << typeName <<
">> outputs_" << opName <<
";\n";
90 out <<
SP <<
"if (fTensor_" <<
fNX <<
"[0] ) { \n";
92 out <<
SP <<
SP <<
"outputs_" << opName <<
" = "
95 out <<
SP <<
"} else {\n";
96 out <<
SP <<
SP <<
"outputs_" << opName <<
" = "
100 out <<
SP <<
"if (outputs_" << opName <<
".size() != " <<
fNYs.size() <<
")\n";
101 out <<
SP <<
SP <<
"throw std::runtime_error(\" If operator: invalid output size!\");\n\n";
102 for (
size_t i = 0; i <
fNYs.size(); i++) {
103 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
void AddIntermediateTensor(std::string tensor_name, ETensorType type, std::vector< Dim > dim_shape)
bool CheckIfTensorAlreadyExist(std::string tensor_name)
void InitializeSubGraph(std::shared_ptr< RModel > graph)
std::shared_ptr< RModel > fModel_then
std::string fInputSignature_modelThen
std::string fInputSignature_modelElse
std::vector< ETensorType > TypeInference(std::vector< ETensorType > input)
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::string Generate(std::string opName)
std::vector< std::vector< size_t > > ShapeInference(std::vector< std::vector< size_t > > input)
void Initialize(RModel &model)
std::vector< std::string > fNYs
std::shared_ptr< RModel > fModel_else
const std::string SP
space used to correctly indent the generated C++ code
std::string Clean_name(std::string input_tensor_name)
std::string ConvertTypeToString(ETensorType type)
create variable transformations