17#include "output_transform.hxx"
35 printf(
" Rmem = %8.3f MB, Vmem = %8.f3 MB \n",
36 p.fMemResident /1024.,
39 return p.fMemResident / 1024.;
45 std::cout <<
" shape : " <<
ConvertShapeToString(t.GetShape()) <<
" size : " << t.GetSize() <<
"\n";
46 auto & shape = t.GetShape();
48 size_t nrows = (shape.size() > 1) ? shape[0] : 1;
49 size_t ncols = (shape.size() > 1) ? t.GetStrides()[0] : shape[0];
50 for (
size_t i = 0; i <
nrows; i++) {
53 if (
j>10) std::cout <<
"... ";
54 std::cout << *
p << std::endl;
57 std::cout << *
p <<
", ";
61 std::cout << std::endl;
64 if (!
txt.empty()) std::cout << std::endl <<
txt << std::endl;
74 TMVA_SOFIE_core::Session
core;
87 for (
int i = 0; i <
nsteps; i++) {
115 std::vector<GNN_Data> dataSet;
116 dataSet.reserve(
nevts);
117 for (
int i = 0; i <
nevts; i++) {
129 auto genValue = [&]() {
return r.Rndm()*10 -5; };
130 auto genLink = [&] () {
return r.Integer(num_nodes);};
135 dataSet.emplace_back(
gd);
141 bool verbose =
false;
149 std::vector<GNN_Data> dataSet;
150 dataSet.reserve(
nevts);
151 for (
int i = 0; i <
nevts; i++) {
153 auto &
n = (*(
ndata.GetPtr()))[i];
155 auto &
e = (*(
edata.GetPtr()))[i];
157 auto &
g = (*(
gdata.GetPtr()))[i];
162 auto &
r = (*(
rdata.GetPtr()))[i];
163 auto & s = (*(
sdata.GetPtr()))[i];
165 std::copy(
r.begin(),
r.end(),
gd.edge_index.GetData());
166 std::copy(s.begin(), s.end(),
gd.edge_index.GetData()+num_edges);
168 dataSet.emplace_back(
Copy(
gd));
169 if (i < 1 && verbose)
Print(dataSet[i],
"Input for Event" + std::to_string(i));
182 const int seed = 111;
191 std::cout <<
"reading data\n";
198 auto h1 =
new TH1D(
"h1",
"SOFIE Node data",40,1,0);
199 auto h2 =
new TH1D(
"h2",
"SOFIE Edge data",40,1,0);
200 auto h3 =
new TH1D(
"h3",
"SOFIE Global data",40,1,0);
201 std::cout <<
"doing inference...\n";
206 for (
int i = 0; i <
nevts; i++) {
210 if (i < 1 && verbose)
Print(
lr,
"Output for Event" + std::to_string(i));
218 auto c1 =
new TCanvas(
"c1",
"SOFIE Results");
221 c1->cd(2); h2->Draw();
222 c1->cd(3); h3->Draw();
226 auto c2 =
new TCanvas(
"c2",
"Reference Results");
228 auto o1 = file->Get(
"h1");
229 auto o2 = file->Get(
"h2");
230 auto o3 = file->Get(
"h3");
232 c2->cd(1);
o1->Draw();
233 c2->cd(2);
o2->Draw();
234 c2->cd(3);
o3->Draw();
#define R__ADD_INCLUDE_PATH(PATH)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
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 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 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 ,...
const_iterator begin() const
const_iterator end() const
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.
Random number generator class based on M.
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)