Skip to content

Commit

Permalink
onnx now optional, cmd line is ONNX_PATH=/Users/ngu/project/onnx/onnx…
Browse files Browse the repository at this point in the history
…runtime-osx-arm64-1.16.3 -j 4
  • Loading branch information
unelg committed Jan 24, 2024
1 parent 7327574 commit 68ef19e
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 8 deletions.
21 changes: 19 additions & 2 deletions CLA/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,26 @@ ROOTLIBS = $(shell root-config --libs)
ROOTGLIBS = $(shell root-config --glibs)
TODAYDATE = $(shell date)

# Define a variable for the library path
ONNX_PATH ?=

ifeq ($(strip $(ONNX_PATH)),)
# Library not found
@echo no onnx path is given. if can specify as make ONNX_PATH=/Users/ngu/project/onnx/onnxruntime-osx-arm64-1.16.3
ONNX_LIB :=
ONNX_INC :=
else
# Library found
ONNX_LIB := -L$(ONNX_PATH)/lib -lonnxruntime
ONNX_INC := -I$(ONNX_PATH)/include
endif

# we try to identify where the various subdirs (like CorrectionMethods) are
SUBDIRLOC = $(shell test -d ../CLA && echo ../ || echo ./)

# now we have the include directories defined, possibly using the SUBDIRLOC variable as the root
INCLUDES = -I$(ROOTSYS)/include -I. -I$(SUBDIRLOC)analysis_core/ -I$(SUBDIRLOC)BP/ -I$(SUBDIRLOC)Dump/ -I/Users/ngu/project/onnx/onnxruntime-osx-arm64-1.16.3/include
INCLUDES = -I$(ROOTSYS)/include -I. -I$(SUBDIRLOC)analysis_core/ -I$(SUBDIRLOC)BP/ -I$(SUBDIRLOC)Dump/ $(ONNX_INC)
###/Users/ngu/project/onnx/onnxruntime-osx-arm64-1.16.3/include

# allow Make to use the same include directories as locations of the sources of various files
VPATH = $(subst -I,:,$(INCLUDES))
Expand All @@ -31,7 +46,7 @@ LD = $(shell root-config --ld) -stdlib=libstdc++
SOFLAGS = -shared

CXXFLAGS += $(ROOTCFLAGS)
LIBS = $(ROOTLIBS) -lMinuit -L. -lDBXNtuple_cpp -ldbx_electron_h -ldbx_tau_h -ldbx_muon_h -ldbx_photon_h -ldbx_jet_h -ldbxParticle_cpp -ldbx_truth_h -l dbx_track_h -ldelphesParticles_h -lz -L/Users/ngu/project/onnx/onnxruntime-osx-arm64-1.16.3/lib -lonnxruntime -rpath /usr/local/lib
LIBS = $(ROOTLIBS) -lMinuit -L. -lDBXNtuple_cpp -ldbx_electron_h -ldbx_tau_h -ldbx_muon_h -ldbx_photon_h -ldbx_jet_h -ldbxParticle_cpp -ldbx_truth_h -l dbx_track_h -ldelphesParticles_h -lz $(ONNX_LIB) -rpath /usr/local/lib
GLIBS = $(ROOTGLIBS)

#LIBS += -lzstd -lCling -lpng -ltbb -lssl -lcrypto
Expand Down Expand Up @@ -95,6 +110,8 @@ endif


b.o : parse.y
@echo You can run as make ONNX_PATH=/Users/ngu/project/onnx/onnxruntime-osx-arm64-1.16.3
@echo "==================================================================================="
$(BISEXE) -d -v -o b.cpp parse.y; $(CXX) $(CXXFLAGS) $(INCLUDES) -c b.cpp

l.o : parse.l
Expand Down
11 changes: 8 additions & 3 deletions CLA/parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
//#define ERRBUG(a) std::cout<<a
#define ERRBUG(a) std::cerr<<a

#ifdef ONNX_PRESENT
#define OMECMD new OMENode(pippo, oidx, itv->second, ita->second, its->second)
#else
#define OMECMD new SFuncNode(all,1, "all")
#endif

extern int yylex();
extern int yylineno;
extern map<string, TTreeReader*> ttr_map;
Expand Down Expand Up @@ -281,9 +287,8 @@ definition : DEF ID '=' particules { DEBUG($2<<" will be defined as a new part
VariableList.clear();
}
}

| DEF ID '=' OME '(' description ',' ID ',' ID ',' ID ',' index ')' {
// 1 2 3 4 6 8 10 12 14
// cout << "Found an ONNX model execution:"<< $6 << "output will be from"<< $14 <<"\n";
string vname = $8;
string aname = $10;
string sname = $12;
Expand Down Expand Up @@ -321,7 +326,7 @@ definition : DEF ID '=' particules { DEBUG($2<<" will be defined as a new part
}
string pippo=$6;
int oidx=$14;
NodeVars->insert(make_pair(name,new OMENode(pippo, oidx, itv->second, ita->second, its->second) ));
NodeVars->insert(make_pair(name, OMECMD ));

}
| DEF ID '=' OME '(' description ',' variablelist ',' index ')' {
Expand Down
19 changes: 17 additions & 2 deletions analysis_core/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
objects := $(patsubst %.cpp,%.o,$(wildcard *.cpp))


# Define a variable for the library path
ONNX_PATH ?=

ifeq ($(strip $(ONNX_PATH)),)
# Library not found
ONNX_INC :=
objects := $(filter-out OMENode.o,$(patsubst %.cpp,%.o,$(wildcard *.cpp)))
else
# Library found
ONNX_INC := -I$(ONNX_PATH)/include
objects := $(patsubst %.cpp,%.o,$(wildcard *.cpp))
CXXFLAGS+= -DONNX_PRESENT
endif

ROOTCFLAGS = $(shell root-config --cflags)
CXXFLAGS += $(ROOTCFLAGS) -O3 -I../analysis_core -I/Users/ngu/project/onnx/onnxruntime-osx-arm64-1.16.3/include
CXXFLAGS += $(ROOTCFLAGS) -O3 -I../analysis_core $(ONNX_INC)
CXX = $(shell root-config --cxx) -g



%.o : %.cxx
$(CXX) $(CXXFLAGS) -c $< -o $@

Expand Down
2 changes: 2 additions & 0 deletions analysis_core/NodeTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
#include "ObjectNode.hpp"
#include "TextNode.hpp"
#include "SaveNode.h"
#ifdef ONNX_PRESENT
#include "OMENode.h"
#endif
//Delete Nodes
//Print Nodes As Defined by User
#endif /* NodeTree_h */
2 changes: 1 addition & 1 deletion analysis_core/TStringAddFloat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
TString operator+(const TString &s, Float_t f)
{
char si[32];
sprintf(si, "%g", f);
snprintf(si, sizeof(si), "%g", f);
return s+si;
}

Expand Down

0 comments on commit 68ef19e

Please sign in to comment.