Skip to content

Commit

Permalink
- add optimization vectorization options for SOFIE tests
Browse files Browse the repository at this point in the history
- set in ONNXRuntime also the interopnumthreads to 1
  • Loading branch information
lmoneta committed Jul 1, 2022
1 parent 5388577 commit bebe103
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
10 changes: 7 additions & 3 deletions root/tmva/sofie/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,13 @@ add_dependencies(RDF_SOFIE_Inference SofieCompileModels)
#if (ROOT_PLATFORM MATCHES "linux|macosx" AND CMAKE_SYSTEM_PROCESSOR MATCHES x86_64 AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
## assume we run only on linux/macos with gnu or gcc
set(gnu-flags $<$<CXX_COMPILER_ID:GNU>:-fno-signaling-nans>)
target_compile_options(SOFIEInference PRIVATE ${gnu-flags} -fno-trapping-math -O3)
target_compile_options(RDF_SOFIE_Inference PRIVATE ${gnu-flags} -fno-trapping-math -O3)
#endif()
if ($APPLE)
target_compile_options(SOFIEInference PRIVATE ${gnu-flags} -ffast-math -fno-trapping-math -O3)
target_compile_options(RDF_SOFIE_Inference PRIVATE ${gnu-flags} -ffast-math -fno-trapping-math -O3)
else()
target_compile_options(SOFIEInference PRIVATE ${gnu-flags} -march=native -ffast-math -fno-trapping-math -O3)
target_compile_options(RDF_SOFIE_Inference PRIVATE ${gnu-flags} -march=native -ffast-math -fno-trapping-math -O3)
endif()

endif() # endif blas
endif() # endif TMVA/SOFIE
Expand Down
13 changes: 7 additions & 6 deletions root/tmva/sofie/ONNXRuntimeInference_Template.cxx.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ static void @FUNC_NAME@(benchmark::State& state, string model_path)

Ort::SessionOptions session_options;
session_options.SetIntraOpNumThreads(1);
session_options.SetInterOpNumThreads(1);
session_options.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED);

//std::cout << "benchmarking model " << model_path << std::endl;
Expand All @@ -45,12 +46,12 @@ static void @FUNC_NAME@(benchmark::State& state, string model_path)
for (int i = 0; i < nout; i++)
output_node_dims[i] = session.GetOutputTypeInfo(i).GetTensorTypeAndShapeInfo().GetShape();

for (int i = 0; i < nin; i++) {
std::cout << "input " << input_node_names[i] << " shape : ";
for (int j = 0; j < input_node_dims[i].size(); j++)
std::cout << " " << input_node_dims[i][j];
std::cout << std::endl;
}
// for (int i = 0; i < nin; i++) {
// std::cout << "input " << input_node_names[i] << " shape : ";
// for (int j = 0; j < input_node_dims[i].size(); j++)
// std::cout << " " << input_node_dims[i][j];
// std::cout << std::endl;
// }
// fix negative shapes
for (int i = 0; i < nin; i++) {
for (int j = 0; j < input_node_dims[i].size(); j++) {
Expand Down

0 comments on commit bebe103

Please sign in to comment.