@@ -19,9 +19,9 @@ if(ROOT_tmva_FOUND AND ROOT_tmva-sofie_FOUND)
1919 # Looking for ONNXRuntime
2020 ## to find OONX run time configure cmake with
2121 ## -DONNXRuntime_INCLUDE_DIRS=..onxruntime_location.../include -DONNXRuntime_LIBRARIES=.../lib
22- find_package (ONNXRuntime QUIET )
22+ find_package (ONNXRuntime)
2323 if (ONNXRuntime_FOUND)
24- message (STATUS "Found ONNXRuntime (build type: ${ONNXRuntime_BUILD_TYPE } , version: ${ONNXRuntime_VERSION_STRING } )" )
24+ message (STATUS "Found ONNXRuntime (library is ${ONNXRuntime_LIBRARY } , libraries ${ONNXRuntime_LIBRARIES } )" )
2525
2626 # Configuring ONNXRuntimeInference_Template.cxx.in
2727 set (FUNC_NAME "BM_ONNXRuntime_Inference" )
@@ -42,13 +42,13 @@ if(ROOT_tmva_FOUND AND ROOT_tmva-sofie_FOUND)
4242 RB_ADD_GBENCHMARK(ONNXRuntimeInference
4343 ONNXRuntimeInference.cxx
4444 LABEL short
45- LIBRARIES TMVA onnxruntime
45+ LIBRARIES TMVA ${ONNXRuntime_LIBRARIES}
4646 )
4747 target_link_directories (ONNXRuntimeInference PRIVATE ${ONNXRuntime_LIBRARIES} )
4848 target_include_directories (ONNXRuntimeInference PRIVATE ${ONNXRuntime_INCLUDE_DIR} )
4949
5050 else ()
51- message (WARNING "ONNXRuntime not found" )
51+ message (STATUS "ONNXRuntime not found" )
5252 endif ()
5353
5454 if (Use_SOFIE_TEMPLATE)
@@ -95,71 +95,115 @@ if(ROOT_tmva_FOUND AND ROOT_tmva-sofie_FOUND)
9595
9696 endif ()
9797
98- configure_file (input_models/compiled/Linear_event.hxx Linear_event.hxx COPYONLY )
99- configure_file (input_models/compiled/Linear_event.dat Linear_event.dat COPYONLY )
10098
101- configure_file (input_models/compiled/Linear_16.hxx Linear_16.hxx COPYONLY )
102- configure_file (input_models/compiled/Linear_16.dat Linear_16.dat COPYONLY )
99+ # configure_file(input_models/compiled/Linear_event.hxx Linear_event.hxx COPYONLY)
100+ # configure_file(input_models/compiled/Linear_event.dat Linear_event.dat COPYONLY)
101+
102+ # configure_file(input_models/compiled/Linear_16.hxx Linear_16.hxx COPYONLY)
103+ # configure_file(input_models/compiled/Linear_16.dat Linear_16.dat COPYONLY)
103104
104- configure_file (input_models/compiled/Linear_32.hxx Linear_32.hxx COPYONLY )
105- configure_file (input_models/compiled/Linear_32.dat Linear_32.dat COPYONLY )
105+ # configure_file(input_models/compiled/Linear_32.hxx Linear_32.hxx COPYONLY)
106+ # configure_file(input_models/compiled/Linear_32.dat Linear_32.dat COPYONLY)
106107
107- configure_file (input_models/compiled/Linear_64.hxx Linear_64.hxx COPYONLY )
108- configure_file (input_models/compiled/Linear_64.dat Linear_64.dat COPYONLY )
108+ # configure_file(input_models/compiled/Linear_64.hxx Linear_64.hxx COPYONLY)
109+ # configure_file(input_models/compiled/Linear_64.dat Linear_64.dat COPYONLY)
109110
110111
111- configure_file (input_models/compiled/Conv_d100_L1_B1.hxx Conv_d100_L1_B1.hxx COPYONLY )
112- configure_file (input_models/compiled/Conv_d100_L1_B1.dat Conv_d100_L1_B1.dat COPYONLY )
112+ # configure_file(input_models/compiled/Conv_d100_L1_B1.hxx Conv_d100_L1_B1.hxx COPYONLY)
113+ # configure_file(input_models/compiled/Conv_d100_L1_B1.dat Conv_d100_L1_B1.dat COPYONLY)
113114
114- configure_file (input_models/compiled/Conv_d100_L14_B1.hxx Conv_d100_L14_B1.hxx COPYONLY )
115- configure_file (input_models/compiled/Conv_d100_L14_B1.dat Conv_d100_L14_B1.dat COPYONLY )
116- configure_file (input_models/compiled/Conv_d100_L14_B32.hxx Conv_d100_L14_B32.hxx COPYONLY )
117- #use file B1 as B32 for weights : it is the same
118- configure_file (input_models/compiled/Conv_d100_L14_B32.dat Conv_d100_L14_B32.dat COPYONLY )
115+ # configure_file(input_models/compiled/Conv_d100_L14_B1.hxx Conv_d100_L14_B1.hxx COPYONLY)
116+ # configure_file(input_models/compiled/Conv_d100_L14_B1.dat Conv_d100_L14_B1.dat COPYONLY)
117+ # configure_file(input_models/compiled/Conv_d100_L14_B32.hxx Conv_d100_L14_B32.hxx COPYONLY)
118+ # #use file B1 as B32 for weights : it is the same
119+ # configure_file(input_models/compiled/Conv_d100_L14_B32.dat Conv_d100_L14_B32.dat COPYONLY)
120+
121+ # configure_file(input_models/compiled/resnet18v1.hxx resnet18v1.hxx COPYONLY)
122+ # configure_file(input_models/compiled/resnet18v1.dat resnet18v1.dat COPYONLY)
123+
124+
125+ add_executable (emitFromONNX
126+ EmitFromONNX.cxx
127+ )
128+ #target_include_directories(emitFromONNX PRIVATE )
129+ target_link_libraries (emitFromONNX ${Protobuf_LIBRARIES} Core ROOTTMVASofie ROOTTMVASofieParser)
130+ set_target_properties (emitFromONNX PROPERTIES POSITION_INDEPENDENT_CODE TRUE )
131+
132+ if (NOT ONNX_MODELS_DIR)
133+ set (ONNX_MODELS_DIR input_models)
134+ endif ()
119135
120- configure_file (input_models/compiled/resnet18v1.hxx resnet18v1.hxx COPYONLY )
121- configure_file (input_models/compiled/resnet18v1.dat resnet18v1.dat COPYONLY )
136+ add_custom_target (SofieCompileModels )
137+ add_dependencies (SofieCompileModels emitFromONNX )
122138
123- # Benchmark for models emitted by SOFIE
124- RB_ADD_GBENCHMARK(SOFIEInference
139+
140+ file (GLOB ONNX_FILES "${ONNX_MODELS_DIR} /*.onnx" )
141+ foreach (onnx_file ${ONNX_FILES} )
142+ #get_filename_component(fname ${onnx_file} NAME_WE)
143+ #get_filename_component(fdir ${onnx_file} DIRECTORY)
144+ add_custom_command (TARGET SofieCompileModels POST_BUILD
145+ COMMAND ./emitFromONNX ${onnx_file}
146+ USES_TERMINAL
147+ )
148+ endforeach ()
149+
150+ find_package (BLAS)
151+ if (BLAS_FOUND)
152+ message (STATUS "Found BLAS ( libraries ${BLAS_LIBRARIES} )" )
153+
154+ #set(SOFIE_BLAS_LIBS /home/moneta/intel/mkl/lib/intel64/libmkl_intel_lp64.so /home/moneta/intel/mkl/lib/intel64/libmkl_sequential.so /home/moneta/intel/mkl/lib/intel64/libmkl_core.so -lpthread)
155+ #set(SOFIE_BLAS_LIBS /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Accelerate.framework)
156+
157+ # Benchmark for models emitted by SOFIE
158+ RB_ADD_GBENCHMARK(SOFIEInference
125159 SOFIEInference.cxx
126160 LABEL short
127- #LIBRARIES TMVA ROOTTMVASofie openblas
128- #LIBRARIES TMVA ROOTTMVASofie /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Accelerate.framework
129- LIBRARIES TMVA ROOTTMVASofie /home/moneta/intel/mkl/lib/intel64/libmkl_intel_lp64.so /home/moneta/intel/mkl/lib/intel64/libmkl_sequential.so /home/moneta/intel/mkl/lib/intel64/libmkl_core.so -lpthread
130- )
161+ LIBRARIES TMVA ROOTTMVASofie ${BLAS_LIBRARIES}
162+ )
163+
131164 # target_include_directories(SOFIEInference PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
132165
133- set (SOFIE_BLAS_LIBS /home/moneta/intel/mkl/lib/intel64/libmkl_intel_lp64.so /home/moneta/intel/mkl/lib/intel64/libmkl_sequential.so /home/moneta/intel/mkl/lib/intel64/libmkl_core.so -lpthread)
166+ #add_dependencies(SOFIEInference SofieCompileModels)
167+
134168
135- configure_file (input_models/compiled/higgs_model_dense.hxx higgs_model_dense.hxx COPYONLY )
136- configure_file (input_models/compiled/higgs_model_dense.dat higgs_model_dense.dat COPYONLY )
169+ # configure_file(input_models/compiled/higgs_model_dense.hxx higgs_model_dense.hxx COPYONLY)
170+ # configure_file(input_models/compiled/higgs_model_dense.dat higgs_model_dense.dat COPYONLY)
137171RB_ADD_GBENCHMARK(RDF_SOFIE_Inference
138172 RDF_SOFIE_Inference.cxx
139173 LABEL short
140174 #LIBRARIES TMVA ROOTTMVASofie openblas
141- #LIBRARIES TMVA ROOTTMVASofie /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Accelerate.framework
142- LIBRARIES Core Hist Imt RIO Tree TreePlayer ROOTDataFrame ROOTVecOps TMVA ROOTTMVASofie ${SOFIE_BLAS_LIBS }
175+ #LIBRARIES TMVA ROOTTMVASofie
176+ LIBRARIES Core Hist Imt RIO Tree TreePlayer ROOTDataFrame ROOTVecOps TMVA ROOTTMVASofie ${BLAS_LIBRARIES }
143177)
144178
145- endif ( )
179+ add_dependencies (RDF_SOFIE_Inference SofieCompileModels )
146180
147- configure_file (input_models/higgs_model_dense.json higgs_model_dense.json COPYONLY )
148- set (LWTNN_INCLUDE_DIR /home/moneta/cernbox/root/tests/tmva/sofie/lwtnn-build /include )
149- set (LWTNN_LIBS /home/moneta/cernbox/root/tests/tmva/sofie/lwtnn-build /lib/liblwtnn.so)
150- RB_ADD_GBENCHMARK(RDF_lwtnn_Inference
151- RDF_lwtnn_Inference.cxx
152- LABEL short
153- LIBRARIES Core Hist Imt RIO Tree TreePlayer ROOTDataFrame ROOTVecOps TMVA ROOTTMVASofie ${LWTNN_LIBS}
154- )
155- target_include_directories (RDF_lwtnn_Inference PRIVATE ${LWTNN_INCLUDE_DIR} )
181+ endif ()
182+ endif ()
156183
184+ find_package (LWTNN QUIET )
185+ if (LWTNN_FOUND)
186+
187+ message (STATUS "Found LWTNN (library is ${LWTNN_LIBRARY} , libraries ${LWTNN_LIBRARIES} )" )
188+ configure_file (input_models/higgs_model_dense.json higgs_model_dense.json COPYONLY )
189+ # set(LWTNN_INCLUDE_DIR /home/moneta/cernbox/root/tests/tmva/sofie/lwtnn-build/include)
190+ # set(LWTNN_LIBS /home/moneta/cernbox/root/tests/tmva/sofie/lwtnn-build/lib/liblwtnn.so)
191+ RB_ADD_GBENCHMARK(RDF_lwtnn_Inference
192+ RDF_lwtnn_Inference.cxx
193+ LABEL short
194+ LIBRARIES Core Hist Imt RIO Tree TreePlayer ROOTDataFrame ROOTVecOps TMVA ROOTTMVASofie ${LWTNN_LIBRARY} )
195+ target_include_directories (RDF_lwtnn_Inference PRIVATE ${LWTNN_INCLUDE_DIR} )
196+ else ()
197+ message (STATUS "LWTNN not found" )
198+ endif ()
157199
158- configure_file (input_models/higgs_model_dense.onnx higgs_model_dense.onnx COPYONLY )
159- RB_ADD_GBENCHMARK(RDF_ONNXRuntime_Inference
160- RDF_ONNXRuntime_Inference.cxx
161- LABEL short
162- LIBRARIES Core Hist Imt RIO Tree TreePlayer ROOTDataFrame ROOTVecOps TMVA ROOTTMVASofie onnxruntime
163- )
164- target_link_directories (RDF_ONNXRuntime_Inference PRIVATE ${ONNXRuntime_LIBRARIES} )
165- target_include_directories (RDF_ONNXRuntime_Inference PRIVATE ${ONNXRuntime_INCLUDE_DIR} )
200+ if (ONNXRuntime_FOUND)
201+ configure_file (input_models/higgs_model_dense.onnx higgs_model_dense.onnx COPYONLY )
202+ RB_ADD_GBENCHMARK(RDF_ONNXRuntime_Inference
203+ RDF_ONNXRuntime_Inference.cxx
204+ LABEL short
205+ LIBRARIES Core Hist Imt RIO Tree TreePlayer ROOTDataFrame ROOTVecOps TMVA ROOTTMVASofie ${ONNXRuntime_LIBRARIES}
206+ )
207+ target_link_directories (RDF_ONNXRuntime_Inference PRIVATE ${ONNXRuntime_LIBRARIES} )
208+ target_include_directories (RDF_ONNXRuntime_Inference PRIVATE ${ONNXRuntime_INCLUDE_DIR} )
209+ endif ()
0 commit comments