@@ -26,7 +26,6 @@ if(ROOT_tmva_FOUND AND ROOT_tmva-sofie_FOUND)
2626 set (CAPTURE_STR "BENCHMARK_CAPTURE(${FUNC_NAME} , @1,\t @2)@3" )
2727 set (HEAD_COMMENT "Automatically configured by CMake" )
2828 set (ALL_CAPTURES "" )
29- set (ONNX_MODEL_NAMES "" )
3029 foreach (model ${ONNX_MODELS} )
3130 get_filename_component (fname ${model} NAME )
3231 get_filename_component (fname_we ${model} NAME_WE )
@@ -46,27 +45,55 @@ if(ROOT_tmva_FOUND AND ROOT_tmva-sofie_FOUND)
4645 target_link_directories (ONNXRuntimeInference PRIVATE ${ONNXRuntime_LIBRARIES} )
4746 target_include_directories (ONNXRuntimeInference PRIVATE ${ONNXRuntime_INCLUDE_DIR} )
4847
48+ else ()
49+ message (WARNING "ONNXRuntime not found" )
4950 endif ()
5051
51- # Checking the SOFIE compiler
52- if (NOT EXISTS ${ROOTSYS} /tmva/sofie/test /emitFromONNX)
53- message (FATAL_ERROR "SOFIE compiler not found" )
54- endif ()
52+ # Configuring SOFIEInference_Template.cxx.in
53+ set (FUNC_NAME "BM_SOFIE_Inference" )
54+ set (CAPTURE_STR "BENCHMARK_CAPTURE(${FUNC_NAME} , @1,\t @2)@3" )
55+ set (INCLUDES_STR "#include @1" )
56+ set (FUNCS_STR "\t\t { @1,\t {@2,\t @3} }" )
57+ set (HEAD_COMMENT "Automatically configured by CMake" )
58+ set (ALL_CAPTURES "" )
59+ set (ALL_INCLUDES "" )
60+ set (ALL_FUNCS "" )
61+ set (COMPILED_MODELS_DIR ${ONNX_MODELS_DIR} /compiled)
62+ file (GLOB COMPILED_MODELS "${COMPILED_MODELS_DIR} /*.hxx" )
63+ set (inc "" )
64+ set (cap "" )
65+ set (funcs "" )
66+ foreach (model ${COMPILED_MODELS} )
67+ get_filename_component (fname ${model} NAME )
68+ get_filename_component (fname_we ${model} NAME_WE )
69+ # Fixing the string for the include headers
70+ string (REPLACE "@1" "\" ${COMPILED_MODELS_DIR} /${fname} \" " inc ${INCLUDES_STR} )
71+ list (APPEND ALL_INCLUDES ${inc} )
72+ # Fixing the string for the GBenchmark captures
73+ string (REPLACE "@1" ${fname_we} cap ${CAPTURE_STR} )
74+ string (REPLACE "@2" "\" ${fname_we} \" " cap ${cap} )
75+ list (APPEND ALL_CAPTURES ${cap} )
76+ # Fixing the string for the actual infer function that each capture will call
77+ string (REPLACE "@1" "\" ${fname_we} \" " funcs ${FUNCS_STR} )
78+ string (REPLACE "@2" "TMVA_SOFIE_${fname_we} ::infer" funcs ${funcs} )
79+ string (REPLACE "@3" "0" funcs ${funcs} )
80+ list (APPEND ALL_FUNCS ${funcs} )
81+ endforeach ()
5582
83+ # Transforming list of strings into a single multi-line string
84+ string (REPLACE ";" "\n " BENCHMARK_CAPTURES "${ALL_CAPTURES} " ) # String[] -> String
85+ string (REPLACE "@3" ";" BENCHMARK_CAPTURES "${BENCHMARK_CAPTURES} " ) # Adding semicolon
86+ string (REPLACE ";" "\n " INCLUDE_HEADERS "${ALL_INCLUDES} " ) # String[] -> String
87+ string (REPLACE ";" ",\n " FUNC_TUPLES "${ALL_FUNCS} " ) # String[] -> String
88+ configure_file (SOFIEInference_Template.cxx.in SOFIEInference.cxx @ONLY)
89+
5690 # Benchmark for models emitted by SOFIE
5791 RB_ADD_GBENCHMARK(SOFIEInference
5892 SOFIEInference.cxx
5993 LABEL short
60- LIBRARIES TMVA blas
94+ LIBRARIES TMVA openblas
6195 )
96+ target_include_directories (SOFIEInference PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} )
6297
63- # Benchmark for models emitted by SOFIE (with RModelProfiler)
64- # This should be useful in measuring profiler's overhead
65- RB_ADD_GBENCHMARK(SOFIEInferenceProfiler
66- SOFIEInferenceProfiler.cxx
67- LABEL short
68- LIBRARIES TMVA blas
69- )
70-
7198endif ()
7299
0 commit comments