47 fGC +=
"\n\nnamespace Edge_Update{\nstruct Session {\n";
64 fGC+=
"\n\nnamespace Node_Update{\nstruct Session {\n";
84 fGC+=
"\n\nnamespace Global_Update{\nstruct Session {\n";
107 fGC +=
"struct Session {\n";
108 fGC +=
"\n// Instantiating session objects for graph components\n";
111 fGC +=
"Edge_Update::Session edge_update;\n";
117 fGC +=
"Node_Update::Session node_update;\n";
122 fGC +=
"Global_Update::Session global_update;\n\n";
126 fGC +=
"\nvoid infer(TMVA::Experimental::SOFIE::GNN_Data& input_graph){\n";
131 fGC +=
"\n// --- Edge Update ---\n";
134 fGC +=
"size_t n_edges = input_graph.edge_data.GetShape()[0];\n";
135 fGC +=
"for (size_t k = 0; k < n_edges; k++) { \n";
136 fGC +=
" std::copy(input_graph.edge_data.GetData() + k * " +
e_size_input +
137 ", input_graph.edge_data.GetData() + (k + 1) * " +
e_size_input +
", fEdgeInputs.begin() + k * " +
141 fGC +=
"auto edgeUpdates = " +
edges_update_block->Generate({
"n_edges",
"fEdgeInputs.data()"}) +
"\n";
144 fGC +=
"\n// resize edge graph data since output feature size is not equal to input size\n";
145 fGC +=
"input_graph.edge_data = input_graph.edge_data.Resize({ n_edges, " +
149 fGC +=
"\nfor (size_t k = 0; k < n_edges; k++) { \n";
152 ",input_graph.edge_data.GetData() + k * " + std::to_string(
num_edge_features) +
");\n";
160 fGC +=
"\n// --- Node Update ---\n";
161 fGC +=
"size_t n_nodes = input_graph.node_data.GetShape()[0];\n";
162 fGC +=
"for (size_t k = 0; k < n_nodes; k++) { \n";
163 fGC +=
" std::copy(input_graph.node_data.GetData() + k * " +
n_size_input +
164 ", input_graph.node_data.GetData() + (k + 1) * " +
n_size_input +
", fNodeInputs.begin() + k * " +
168 fGC +=
"auto nodeUpdates = ";
173 fGC +=
"\n// resize node graph data since output feature size is not equal to input size\n";
174 fGC +=
"input_graph.node_data = input_graph.node_data.Resize({ n_nodes, " +
178 fGC +=
"\nfor (size_t k = 0; k < n_nodes; k++) { \n";
181 ",input_graph.node_data.GetData() + k * " + std::to_string(
num_node_features) +
");\n";
188 fGC +=
"\n// --- Global Update ---\n";
189 fGC +=
"std::vector<float> Global_Data = ";
194 fGC +=
"\n// resize global graph data since output feature size is not equal to input size\n";
195 fGC +=
"input_graph.global_data = input_graph.global_data.Resize({" + std::to_string(
num_global_features) +
199 fGC +=
"\nstd::copy(Global_Data.begin(), Global_Data.end(), input_graph.global_data.GetData());";
203 fGC += (
"}\n};\n} //TMVA_SOFIE_" +
fName +
"\n");
204 fGC +=
"\n#endif // TMVA_SOFIE_" +
hgname +
"\n";