13#include "output_transform.hxx"
29 printf(
"%s - ",s.c_str());
31 printf(
" Rmem = %8.3f MB, Vmem = %8.f3 MB \n",
32 p.fMemResident /1024.,
35 return p.fMemResident / 1024.;
44 size_t nrows = (shape.size() > 1) ? shape[0] : 1;
45 size_t ncols = (shape.size() > 1) ? t.
GetStrides()[0] : shape[0];
46 for (
size_t i = 0; i < nrows; i++) {
47 for (
size_t j = 0; j < ncols; j++) {
49 if (j>10) std::cout <<
"... ";
50 std::cout << *
p << std::endl;
53 std::cout << *
p <<
", ";
57 std::cout << std::endl;
60 if (!txt.empty()) std::cout << std::endl << txt << std::endl;
70 TMVA_SOFIE_core::Session
core;
80 auto latent0 =
Copy(input_data);
82 std::vector<GNN_Data> outputData;
83 for (
int i = 0; i < nsteps; i++) {
88 core.infer(core_input);
91 latent =
Copy(core_input);
94 outputData.push_back(
Copy(core_input));
111 std::vector<GNN_Data> dataSet;
112 dataSet.reserve(nevts);
113 for (
int i = 0; i < nevts; i++) {
125 auto genValue = [&]() {
return r.Rndm()*10 -5; };
126 auto genLink = [&] () {
return r.Integer(num_nodes);};
131 dataSet.emplace_back(gd);
137 bool verbose =
false;
144 int nevts = ndata.GetPtr()->
size();
145 std::vector<GNN_Data> dataSet;
146 dataSet.reserve(nevts);
147 for (
int i = 0; i < nevts; i++) {
149 auto &
n = (*(ndata.GetPtr()))[i];
151 auto &
e = (*(edata.GetPtr()))[i];
153 auto &
g = (*(gdata.GetPtr()))[i];
158 auto &
r = (*(rdata.GetPtr()))[i];
159 auto & s = (*(sdata.GetPtr()))[i];
164 dataSet.emplace_back(
Copy(gd));
165 if (i < 1 && verbose)
Print(dataSet[i],
"Input for Event" + std::to_string(i));
178 const int seed = 111;
179 const int nproc_steps = 5;
187 std::cout <<
"reading data\n";
188 auto inputData =
ReadData(
"gdata",
"graph_data.root");
189 nevts = inputData.size();
194 auto h1 =
new TH1D(
"h1",
"SOFIE Node data",40,1,0);
195 auto h2 =
new TH1D(
"h2",
"SOFIE Edge data",40,1,0);
196 auto h3 =
new TH1D(
"h3",
"SOFIE Global data",40,1,0);
197 std::cout <<
"doing inference...\n";
202 for (
int i = 0; i < nevts; i++) {
203 auto result = gnn.Infer(inputData[i], nproc_steps);
205 auto & lr =
result.back();
206 if (i < 1 && verbose)
Print(lr,
"Output for Event" + std::to_string(i));
208 h2->Fill(
TMath::Mean(lr.edge_data.begin(), lr.edge_data.end()));
209 h3->Fill(
TMath::Mean(lr.global_data.begin(), lr.global_data.end()));
214 auto c1 =
new TCanvas(
"c1",
"SOFIE Results");
217 c1->cd(2); h2->Draw();
218 c1->cd(3); h3->Draw();
222 auto c2 =
new TCanvas(
"c2",
"Reference Results");
224 auto o1 = file->Get(
"h1");
225 auto o2 = file->Get(
"h2");
226 auto o3 = file->Get(
"h3");
228 c2->cd(1); o1->Draw();
229 c2->cd(2); o2->Draw();
230 c2->cd(3); o3->Draw();
#define R__ADD_INCLUDE_PATH(PATH)
winID h TVirtualViewer3D TVirtualGLPainter p
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 result
void Print(GNN_Data &d, std::string txt="")
const int EDGE_FEATURE_SIZE
const int GLOBAL_FEATURE_SIZE
std::vector< GNN_Data > ReadData(std::string treename, std::string filename)
void PrintTensor(RTensor< T > &t)
void TMVA_SOFIE_GNN_Application(bool verbose=false)
const int NODE_FEATURE_SIZE
double check_mem(std::string s="")
std::vector< GNN_Data > GenerateData(int nevts, int seed)
R__EXTERN TSystem * gSystem
RResultPtr< COLL > Take(std::string_view column="")
Return a collection of values of a column (lazy action, returns a std::vector by default).
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
A "std::vector"-like collection of values implementing handy operation to analyse them.
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.
1-D histogram with a double per channel (see TH1 documentation)
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
void Draw(Option_t *option="") override
Draw this histogram with options.
RTensor is a container with contiguous memory and shape information.
const Shape_t & GetStrides() const
std::size_t GetSize() const
Iterator begin() noexcept
const Shape_t & GetShape() const
Random number generator class based on M.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
virtual int GetProcInfo(ProcInfo_t *info) const
Returns cpu and memory used by this process into the ProcInfo_t structure.
std::string ConvertShapeToString(std::vector< size_t > shape)
TMVA::Experimental::RTensor< T > Concatenate(TMVA::Experimental::RTensor< T > &t1, TMVA::Experimental::RTensor< T > &t2, int axis=0)
GNN_Data Copy(const GNN_Data &data)
Double_t Mean(Long64_t n, const T *a, const Double_t *w=nullptr)
Returns the weighted mean of an array a with length n.
TMVA_SOFIE_core::Session core
TMVA_SOFIE_output_transform::Session output_transform
TMVA_SOFIE_decoder::Session decoder
TMVA_SOFIE_encoder::Session encoder
std::vector< GNN_Data > Infer(const GNN_Data &data, int nsteps)
RTensor< float > global_data
RTensor< float > edge_data
RTensor< int > edge_index
RTensor< float > node_data