From 1079f1c356029db11be329d14644923da5181be2 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Mon, 1 Apr 2024 19:57:14 -0500 Subject: [PATCH 01/17] feat: example of how to use ONNX Runtime (Ort) in algorithms --- CMakeLists.txt | 6 +++ cmake/jana_plugin.cmake | 14 +++++++ src/algorithms/CMakeLists.txt | 4 ++ src/algorithms/onnx/CMakeLists.txt | 21 ++++++++++ src/algorithms/onnx/InclusiveKinematicsML.cc | 31 +++++++++++++++ src/algorithms/onnx/InclusiveKinematicsML.h | 42 ++++++++++++++++++++ 6 files changed, 118 insertions(+) create mode 100644 src/algorithms/onnx/CMakeLists.txt create mode 100644 src/algorithms/onnx/InclusiveKinematicsML.cc create mode 100644 src/algorithms/onnx/InclusiveKinematicsML.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 724b798850..7e86b94455 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -219,6 +219,12 @@ if(NOT "cxx_std_${CMAKE_CXX_STANDARD}" IN_LIST ROOT_COMPILE_FEATURES) ) endif() +# ONNX Runtime +option(USE_ONNX "Compile with ONNX support" ON) +if (${USE_ONNX}) + find_package(onnxruntime) +endif() + # Add CMake additional functionality: include(cmake/jana_plugin.cmake) # Add common settings for plugins list(APPEND CMAKE_MODULE_PATH ${EICRECON_SOURCE_DIR}/cmake diff --git a/cmake/jana_plugin.cmake b/cmake/jana_plugin.cmake index 8450bcc055..755fcf9b38 100644 --- a/cmake/jana_plugin.cmake +++ b/cmake/jana_plugin.cmake @@ -376,3 +376,17 @@ macro(plugin_add_fastjet _name) plugin_link_libraries(${PLUGIN_NAME} ${FASTJET_LIBRARIES}) endmacro() + +# Adds ONNX Runtime for a plugin +macro(plugin_add_onnxruntime _name) + + if(NOT onnxruntime_FOUND) + find_package(onnxruntime_FOUND) + endif() + + # Add libraries + plugin_link_libraries(${PLUGIN_NAME} + onnxruntime::onnxruntime + ) + +endmacro() diff --git a/src/algorithms/CMakeLists.txt b/src/algorithms/CMakeLists.txt index dddced5bff..87bbf34d67 100644 --- a/src/algorithms/CMakeLists.txt +++ b/src/algorithms/CMakeLists.txt @@ -7,3 +7,7 @@ add_subdirectory(pid) add_subdirectory(digi) add_subdirectory(reco) add_subdirectory(fardetectors) + +if(USE_ONNX) + add_subdirectory(onnx) +endif() diff --git a/src/algorithms/onnx/CMakeLists.txt b/src/algorithms/onnx/CMakeLists.txt new file mode 100644 index 0000000000..20d16ad481 --- /dev/null +++ b/src/algorithms/onnx/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.16) + +set(PLUGIN_NAME "algorithms_onnx") + +# Function creates ${PLUGIN_NAME}_plugin and ${PLUGIN_NAME}_library targets +# Setting default includes, libraries and installation paths +plugin_add(${PLUGIN_NAME} WITH_SHARED_LIBRARY WITHOUT_PLUGIN) + +# The macro grabs sources as *.cc *.cpp *.c and headers as *.h *.hh *.hpp +# Then correctly sets sources for ${_name}_plugin and ${_name}_library targets +# Adds headers to the correct installation directory +plugin_glob_all(${PLUGIN_NAME}) + +# Find dependencies +plugin_add_event_model(${PLUGIN_NAME}) +plugin_add_onnxruntime(${PLUGIN_NAME}) + +# The macro grabs sources as *.cc *.cpp *.c and headers as *.h *.hh *.hpp +# Then correctly sets sources for ${_name}_plugin and ${_name}_library targets +# Adds headers to the correct installation directory +plugin_glob_all(${PLUGIN_NAME}) diff --git a/src/algorithms/onnx/InclusiveKinematicsML.cc b/src/algorithms/onnx/InclusiveKinematicsML.cc new file mode 100644 index 0000000000..cef34555dc --- /dev/null +++ b/src/algorithms/onnx/InclusiveKinematicsML.cc @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2022, 2023 Wouter Deconinck, Tooba Ali + +#include +#include +#include +#include +#include +#include +#include + +#include "InclusiveKinematicsML.h" + +namespace eicrecon { + + void InclusiveKinematicsML::init(std::shared_ptr& logger) { + } + + void InclusiveKinematicsML::process( + const InclusiveKinematicsML::Input& input, + const InclusiveKinematicsML::Output& output) const { + + const auto [electron, da] = input; + auto [ml] = output; + + const auto& api = Ort::GetApi(); + + Ort::Session session(nullptr); + } + +} // namespace eicrecon diff --git a/src/algorithms/onnx/InclusiveKinematicsML.h b/src/algorithms/onnx/InclusiveKinematicsML.h new file mode 100644 index 0000000000..a313a4b2fc --- /dev/null +++ b/src/algorithms/onnx/InclusiveKinematicsML.h @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2022, 2023 Sylvester Joosten, Dmitry Romanov, Wouter Deconinck + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace eicrecon { + + using InclusiveKinematicsMLAlgorithm = algorithms::Algorithm< + algorithms::Input< + edm4eic::InclusiveKinematicsCollection, + edm4eic::InclusiveKinematicsCollection + >, + algorithms::Output< + edm4eic::InclusiveKinematicsCollection + > + >; + + class InclusiveKinematicsML + : public InclusiveKinematicsMLAlgorithm { + + public: + InclusiveKinematicsML(std::string_view name) + : InclusiveKinematicsMLAlgorithm{name, + {"inclusiveKinematicsElectron", "inclusiveKinematicsDA"}, + {"inclusiveKinematicsML"}, + "Determine inclusive kinematics using combined ML method."} {} + + void init(std::shared_ptr& logger); + void process(const Input&, const Output&) const final; + + private: + std::shared_ptr m_log; + }; + +} // namespace eicrecon From 1ea612b91d61ee05fb700284180da9140296782e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 01:00:07 +0000 Subject: [PATCH 02/17] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/onnx/InclusiveKinematicsML.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/onnx/InclusiveKinematicsML.h b/src/algorithms/onnx/InclusiveKinematicsML.h index a313a4b2fc..a2aee12b23 100644 --- a/src/algorithms/onnx/InclusiveKinematicsML.h +++ b/src/algorithms/onnx/InclusiveKinematicsML.h @@ -32,7 +32,7 @@ namespace eicrecon { {"inclusiveKinematicsML"}, "Determine inclusive kinematics using combined ML method."} {} - void init(std::shared_ptr& logger); + void init(std::shared_ptr& logger); void process(const Input&, const Output&) const final; private: From d422b77201c66f0b752b25f05654c68bbb3fec34 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Mon, 1 Apr 2024 22:24:15 -0500 Subject: [PATCH 03/17] fix: correct find_package --- cmake/jana_plugin.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/jana_plugin.cmake b/cmake/jana_plugin.cmake index 755fcf9b38..e5b98b9824 100644 --- a/cmake/jana_plugin.cmake +++ b/cmake/jana_plugin.cmake @@ -381,7 +381,7 @@ endmacro() macro(plugin_add_onnxruntime _name) if(NOT onnxruntime_FOUND) - find_package(onnxruntime_FOUND) + find_package(onnxruntime) endif() # Add libraries From 0e2db853b369aa3001e341fcc6593b94f3a547b7 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Mon, 1 Apr 2024 22:25:20 -0500 Subject: [PATCH 04/17] fix: iwyu --- src/algorithms/onnx/InclusiveKinematicsML.cc | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/algorithms/onnx/InclusiveKinematicsML.cc b/src/algorithms/onnx/InclusiveKinematicsML.cc index cef34555dc..2fbc8589c2 100644 --- a/src/algorithms/onnx/InclusiveKinematicsML.cc +++ b/src/algorithms/onnx/InclusiveKinematicsML.cc @@ -1,13 +1,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // Copyright (C) 2022, 2023 Wouter Deconinck, Tooba Ali -#include -#include -#include -#include -#include #include -#include #include "InclusiveKinematicsML.h" From 57c3a961aa5a87cc7afb9dd37964fc3dbd60126c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 17:24:03 +0000 Subject: [PATCH 05/17] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- CMakeLists.txt | 4 ++-- cmake/jana_plugin.cmake | 12 +++++------- src/algorithms/CMakeLists.txt | 2 +- src/algorithms/onnx/CMakeLists.txt | 12 ++++++------ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e86b94455..aec87fb4d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,8 +221,8 @@ endif() # ONNX Runtime option(USE_ONNX "Compile with ONNX support" ON) -if (${USE_ONNX}) - find_package(onnxruntime) +if(${USE_ONNX}) + find_package(onnxruntime) endif() # Add CMake additional functionality: diff --git a/cmake/jana_plugin.cmake b/cmake/jana_plugin.cmake index e5b98b9824..da4454cbb0 100644 --- a/cmake/jana_plugin.cmake +++ b/cmake/jana_plugin.cmake @@ -380,13 +380,11 @@ endmacro() # Adds ONNX Runtime for a plugin macro(plugin_add_onnxruntime _name) - if(NOT onnxruntime_FOUND) - find_package(onnxruntime) - endif() + if(NOT onnxruntime_FOUND) + find_package(onnxruntime) + endif() - # Add libraries - plugin_link_libraries(${PLUGIN_NAME} - onnxruntime::onnxruntime - ) + # Add libraries + plugin_link_libraries(${PLUGIN_NAME} onnxruntime::onnxruntime) endmacro() diff --git a/src/algorithms/CMakeLists.txt b/src/algorithms/CMakeLists.txt index 87bbf34d67..013ea11931 100644 --- a/src/algorithms/CMakeLists.txt +++ b/src/algorithms/CMakeLists.txt @@ -9,5 +9,5 @@ add_subdirectory(reco) add_subdirectory(fardetectors) if(USE_ONNX) - add_subdirectory(onnx) + add_subdirectory(onnx) endif() diff --git a/src/algorithms/onnx/CMakeLists.txt b/src/algorithms/onnx/CMakeLists.txt index 20d16ad481..c0fd746a91 100644 --- a/src/algorithms/onnx/CMakeLists.txt +++ b/src/algorithms/onnx/CMakeLists.txt @@ -6,16 +6,16 @@ set(PLUGIN_NAME "algorithms_onnx") # Setting default includes, libraries and installation paths plugin_add(${PLUGIN_NAME} WITH_SHARED_LIBRARY WITHOUT_PLUGIN) -# The macro grabs sources as *.cc *.cpp *.c and headers as *.h *.hh *.hpp -# Then correctly sets sources for ${_name}_plugin and ${_name}_library targets -# Adds headers to the correct installation directory +# The macro grabs sources as *.cc *.cpp *.c and headers as *.h *.hh *.hpp Then +# correctly sets sources for ${_name}_plugin and ${_name}_library targets Adds +# headers to the correct installation directory plugin_glob_all(${PLUGIN_NAME}) # Find dependencies plugin_add_event_model(${PLUGIN_NAME}) plugin_add_onnxruntime(${PLUGIN_NAME}) -# The macro grabs sources as *.cc *.cpp *.c and headers as *.h *.hh *.hpp -# Then correctly sets sources for ${_name}_plugin and ${_name}_library targets -# Adds headers to the correct installation directory +# The macro grabs sources as *.cc *.cpp *.c and headers as *.h *.hh *.hpp Then +# correctly sets sources for ${_name}_plugin and ${_name}_library targets Adds +# headers to the correct installation directory plugin_glob_all(${PLUGIN_NAME}) From d8de246f196a8a9d00c8d71fa55f0b659419a077 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Thu, 11 Apr 2024 18:24:16 -0500 Subject: [PATCH 06/17] feat: add InclusiveKinematicsMLConfig --- src/algorithms/onnx/InclusiveKinematicsML.h | 7 ++- .../onnx/InclusiveKinematicsMLConfig.h | 16 +++++++ .../reco/InclusiveKinematicsML_factory.h | 47 +++++++++++++++++++ src/global/reco/CMakeLists.txt | 2 +- src/global/reco/reco.cc | 14 ++++++ src/services/io/podio/JEventProcessorPODIO.cc | 1 + 6 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 src/algorithms/onnx/InclusiveKinematicsMLConfig.h create mode 100644 src/factories/reco/InclusiveKinematicsML_factory.h diff --git a/src/algorithms/onnx/InclusiveKinematicsML.h b/src/algorithms/onnx/InclusiveKinematicsML.h index a2aee12b23..686d174e34 100644 --- a/src/algorithms/onnx/InclusiveKinematicsML.h +++ b/src/algorithms/onnx/InclusiveKinematicsML.h @@ -7,9 +7,13 @@ #include #include #include +#include #include #include +#include "algorithms/interfaces/WithPodConfig.h" +#include "algorithms/onnx/InclusiveKinematicsMLConfig.h" + namespace eicrecon { using InclusiveKinematicsMLAlgorithm = algorithms::Algorithm< @@ -23,7 +27,8 @@ namespace eicrecon { >; class InclusiveKinematicsML - : public InclusiveKinematicsMLAlgorithm { + : public InclusiveKinematicsMLAlgorithm, + public WithPodConfig { public: InclusiveKinematicsML(std::string_view name) diff --git a/src/algorithms/onnx/InclusiveKinematicsMLConfig.h b/src/algorithms/onnx/InclusiveKinematicsMLConfig.h new file mode 100644 index 0000000000..86402d26e5 --- /dev/null +++ b/src/algorithms/onnx/InclusiveKinematicsMLConfig.h @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2024 Wouter Deconinck + +#pragma once + +#include + +namespace eicrecon { + + struct InclusiveKinematicsMLConfig { + + std::string modelPath{""}; + + }; + +} // eicrecon diff --git a/src/factories/reco/InclusiveKinematicsML_factory.h b/src/factories/reco/InclusiveKinematicsML_factory.h new file mode 100644 index 0000000000..ad9861289d --- /dev/null +++ b/src/factories/reco/InclusiveKinematicsML_factory.h @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2022 Wouter Deconinck + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "algorithms/onnx/InclusiveKinematicsML.h" +#include "extensions/jana/JOmniFactory.h" + +namespace eicrecon { + +class InclusiveKinematicsML_factory : + public JOmniFactory { + +public: + using AlgoT = eicrecon::InclusiveKinematicsML; +private: + std::unique_ptr m_algo; + + PodioInput m_inclusive_kinematics_electron_input {this}; + PodioInput m_inclusive_kinematics_da_input {this}; + PodioOutput m_inclusive_kinematics_output {this}; + + ParameterRef m_modelPath {this, "modelPath", config().modelPath}; + +public: + void Configure() { + m_algo = std::make_unique(GetPrefix()); + m_algo->applyConfig(config()); + m_algo->init(logger()); + } + + void ChangeRun(int64_t run_number) { + } + + void Process(int64_t run_number, uint64_t event_number) { + m_algo->process({m_inclusive_kinematics_electron_input(), m_inclusive_kinematics_da_input()}, {m_inclusive_kinematics_output().get()}); + } +}; + +} // eicrecon diff --git a/src/global/reco/CMakeLists.txt b/src/global/reco/CMakeLists.txt index 5049d1ac7a..cecc15e4ec 100644 --- a/src/global/reco/CMakeLists.txt +++ b/src/global/reco/CMakeLists.txt @@ -27,4 +27,4 @@ plugin_glob_all(${PLUGIN_NAME}) # Add libraries (same as target_include_directories but for both plugin and # library) plugin_link_libraries(${PLUGIN_NAME} algorithms_digi_library - algorithms_tracking_library algorithms_reco_library) + algorithms_tracking_library algorithms_onnx_library algorithms_reco_library) diff --git a/src/global/reco/reco.cc b/src/global/reco/reco.cc index 5a3c27b59c..ed06c97c49 100644 --- a/src/global/reco/reco.cc +++ b/src/global/reco/reco.cc @@ -11,6 +11,7 @@ #include #include +#include "algorithms/onnx/InclusiveKinematicsML.h" #include "algorithms/reco/InclusiveKinematicsDA.h" #include "algorithms/reco/InclusiveKinematicsElectron.h" #include "algorithms/reco/InclusiveKinematicsJB.h" @@ -18,6 +19,7 @@ #include "algorithms/reco/InclusiveKinematicseSigma.h" #include "extensions/jana/JOmniFactoryGeneratorT.h" #include "factories/meta/CollectionCollector_factory.h" +#include "factories/reco/InclusiveKinematicsML_factory.h" #include "factories/reco/InclusiveKinematicsReconstructed_factory.h" #include "factories/reco/InclusiveKinematicsTruth_factory.h" #include "factories/reco/JetReconstruction_factory.h" @@ -155,6 +157,18 @@ void InitPlugin(JApplication *app) { app )); + app->Add(new JOmniFactoryGeneratorT( + "InclusiveKinematicsML", + { + "InclusiveKinematicsElectron", + "InclusiveKinematicsDA" + }, + { + "InclusiveKinematicsML" + }, + app + )); + app->Add(new JOmniFactoryGeneratorT( "ReconstructedElectrons", {"ReconstructedParticles"}, diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index 80b43c428e..299e211768 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -136,6 +136,7 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "CentralCKFSeededTrackParameters", "InclusiveKinematicsDA", "InclusiveKinematicsJB", + "InclusiveKinematicsML", "InclusiveKinematicsSigma", "InclusiveKinematicseSigma", "InclusiveKinematicsElectron", From 7293cfb27eb7a63e0dad9e637443076f729f3ba4 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Thu, 11 Apr 2024 18:24:59 -0500 Subject: [PATCH 07/17] feat: add session as algorithm state; run inference --- src/algorithms/onnx/InclusiveKinematicsML.cc | 83 +++++++++++++++++++- src/algorithms/onnx/InclusiveKinematicsML.h | 11 +++ 2 files changed, 92 insertions(+), 2 deletions(-) diff --git a/src/algorithms/onnx/InclusiveKinematicsML.cc b/src/algorithms/onnx/InclusiveKinematicsML.cc index 2fbc8589c2..741c688043 100644 --- a/src/algorithms/onnx/InclusiveKinematicsML.cc +++ b/src/algorithms/onnx/InclusiveKinematicsML.cc @@ -7,7 +7,58 @@ namespace eicrecon { + static std::string print_shape(const std::vector& v) { + std::stringstream ss(""); + for (std::size_t i = 0; i < v.size() - 1; i++) ss << v[i] << "x"; + ss << v[v.size() - 1]; + return ss.str(); + } + + template + Ort::Value vec_to_tensor(std::vector& data, const std::vector& shape) { + Ort::MemoryInfo mem_info = + Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator, OrtMemType::OrtMemTypeDefault); + auto tensor = Ort::Value::CreateTensor(mem_info, data.data(), data.size(), shape.data(), shape.size()); + return tensor; + } + void InclusiveKinematicsML::init(std::shared_ptr& logger) { + m_log = logger; + + // onnxruntime setup + Ort::Env env(ORT_LOGGING_LEVEL_VERBOSE, "inclusive-kinematics-ml"); + Ort::SessionOptions session_options; + try { + m_session = Ort::Session(env, m_cfg.modelPath.c_str(), session_options); + + // print name/shape of inputs + Ort::AllocatorWithDefaultOptions allocator; + m_log->debug("Input Node Name/Shape:"); + for (std::size_t i = 0; i < m_session.GetInputCount(); i++) { + m_input_names.emplace_back(m_session.GetInputNameAllocated(i, allocator).get()); + m_input_shapes.emplace_back(m_session.GetInputTypeInfo(i).GetTensorTypeAndShapeInfo().GetShape()); + m_log->debug("\t{} : {}", m_input_names.at(i), print_shape(m_input_shapes.at(i))); + } + + // print name/shape of outputs + m_log->debug("Output Node Name/Shape:"); + for (std::size_t i = 0; i < m_session.GetOutputCount(); i++) { + m_output_names.emplace_back(m_session.GetOutputNameAllocated(i, allocator).get()); + m_output_shapes.emplace_back(m_session.GetOutputTypeInfo(i).GetTensorTypeAndShapeInfo().GetShape()); + m_log->debug("\t{} : {}", m_output_names.at(i), print_shape(m_output_shapes.at(i))); + } + + // convert names to char* + m_input_names_char.resize(m_input_names.size(), nullptr); + std::transform(std::begin(m_input_names), std::end(m_input_names), std::begin(m_input_names_char), + [&](const std::string& str) { return str.c_str(); }); + m_output_names_char.resize(m_output_names.size(), nullptr); + std::transform(std::begin(m_output_names), std::end(m_output_names), std::begin(m_output_names_char), + [&](const std::string& str) { return str.c_str(); }); + + } catch(std::exception& e) { + m_log->error(e.what()); + } } void InclusiveKinematicsML::process( @@ -17,9 +68,37 @@ namespace eicrecon { const auto [electron, da] = input; auto [ml] = output; - const auto& api = Ort::GetApi(); + // Assume model has 1 input nodes and 1 output node. + assert(m_input_names.size() == 1 && m_output_names.size() == 1); + + // Prepare input tensor + std::vector input_tensor_values; + std::vector input_tensors; + for (std::size_t i = 0; i < electron->size(); i++) { + input_tensor_values.push_back(electron->at(i).getX()); + } + input_tensors.emplace_back(vec_to_tensor(input_tensor_values, m_input_shapes.front())); + + // Double-check the dimensions of the input tensor + assert(input_tensors[0].IsTensor() && input_tensors[0].GetTensorTypeAndShapeInfo().GetShape() == m_input_shapes.front()); + + // Attempt inference + try { + auto output_tensors = m_session.Run(Ort::RunOptions{nullptr}, m_input_names_char.data(), input_tensors.data(), + m_input_names_char.size(), m_output_names_char.data(), m_output_names_char.size()); + + // Double-check the dimensions of the output tensors + assert(output_tensors.size() == m_output_names.size() && output_tensors[0].IsTensor()); + + // Convert output tensor + float* output_tensor_data = output_tensors[0].GetTensorMutableData(); + auto x = output_tensor_data[0]; + auto kin = ml->create(); + kin.setX(x); - Ort::Session session(nullptr); + } catch (const Ort::Exception& exception) { + m_log->error("error running model inference: {}", exception.what()); + } } } // namespace eicrecon diff --git a/src/algorithms/onnx/InclusiveKinematicsML.h b/src/algorithms/onnx/InclusiveKinematicsML.h index 686d174e34..7aed103e3c 100644 --- a/src/algorithms/onnx/InclusiveKinematicsML.h +++ b/src/algorithms/onnx/InclusiveKinematicsML.h @@ -42,6 +42,17 @@ namespace eicrecon { private: std::shared_ptr m_log; + + mutable Ort::Session m_session{nullptr}; + + std::vector m_input_names; + std::vector m_input_names_char; + std::vector> m_input_shapes; + + std::vector m_output_names; + std::vector m_output_names_char; + std::vector> m_output_shapes; + }; } // namespace eicrecon From b70caf3e235c134d87a9bf28bd9d5295c99a71bd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 23:25:52 +0000 Subject: [PATCH 08/17] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/global/reco/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/global/reco/CMakeLists.txt b/src/global/reco/CMakeLists.txt index cecc15e4ec..90886e8147 100644 --- a/src/global/reco/CMakeLists.txt +++ b/src/global/reco/CMakeLists.txt @@ -26,5 +26,6 @@ plugin_glob_all(${PLUGIN_NAME}) # Add libraries (same as target_include_directories but for both plugin and # library) -plugin_link_libraries(${PLUGIN_NAME} algorithms_digi_library - algorithms_tracking_library algorithms_onnx_library algorithms_reco_library) +plugin_link_libraries( + ${PLUGIN_NAME} algorithms_digi_library algorithms_tracking_library + algorithms_onnx_library algorithms_reco_library) From 01e8a8a816e7ec12599adabba1a2a4c979d19fc5 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Thu, 11 Apr 2024 19:19:17 -0500 Subject: [PATCH 09/17] fix: don't run if no inputs --- src/algorithms/onnx/InclusiveKinematicsML.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/algorithms/onnx/InclusiveKinematicsML.cc b/src/algorithms/onnx/InclusiveKinematicsML.cc index 741c688043..5e2bee8df7 100644 --- a/src/algorithms/onnx/InclusiveKinematicsML.cc +++ b/src/algorithms/onnx/InclusiveKinematicsML.cc @@ -68,6 +68,9 @@ namespace eicrecon { const auto [electron, da] = input; auto [ml] = output; + // Require valid inputs + if (electron->size() == 0 || da->size() == 0) return; + // Assume model has 1 input nodes and 1 output node. assert(m_input_names.size() == 1 && m_output_names.size() == 1); From b5ff6e07142c8146e001d733872370c9c6367300 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Thu, 11 Apr 2024 19:44:17 -0500 Subject: [PATCH 10/17] fix: iwyu --- src/algorithms/onnx/InclusiveKinematicsML.cc | 9 +++++++++ src/algorithms/onnx/InclusiveKinematicsML.h | 4 +++- src/global/reco/reco.cc | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/algorithms/onnx/InclusiveKinematicsML.cc b/src/algorithms/onnx/InclusiveKinematicsML.cc index 5e2bee8df7..3e17919865 100644 --- a/src/algorithms/onnx/InclusiveKinematicsML.cc +++ b/src/algorithms/onnx/InclusiveKinematicsML.cc @@ -1,7 +1,16 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // Copyright (C) 2022, 2023 Wouter Deconinck, Tooba Ali +#include +#include +#include #include +#include +#include +#include +#include +#include +#include #include "InclusiveKinematicsML.h" diff --git a/src/algorithms/onnx/InclusiveKinematicsML.h b/src/algorithms/onnx/InclusiveKinematicsML.h index 7aed103e3c..e2d559dbf0 100644 --- a/src/algorithms/onnx/InclusiveKinematicsML.h +++ b/src/algorithms/onnx/InclusiveKinematicsML.h @@ -5,11 +5,13 @@ #include #include +#include #include +#include #include -#include #include #include +#include #include "algorithms/interfaces/WithPodConfig.h" #include "algorithms/onnx/InclusiveKinematicsMLConfig.h" diff --git a/src/global/reco/reco.cc b/src/global/reco/reco.cc index ed06c97c49..fd13ec7b38 100644 --- a/src/global/reco/reco.cc +++ b/src/global/reco/reco.cc @@ -11,7 +11,7 @@ #include #include -#include "algorithms/onnx/InclusiveKinematicsML.h" +#include "algorithms/interfaces/WithPodConfig.h" #include "algorithms/reco/InclusiveKinematicsDA.h" #include "algorithms/reco/InclusiveKinematicsElectron.h" #include "algorithms/reco/InclusiveKinematicsJB.h" From 29bb2bd307d6fad2ec479dbb209dc39ab8ee9551 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Thu, 11 Apr 2024 19:44:41 -0500 Subject: [PATCH 11/17] fix: ORT_LOGGING_LEVEL_WARNING --- src/algorithms/onnx/InclusiveKinematicsML.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/onnx/InclusiveKinematicsML.cc b/src/algorithms/onnx/InclusiveKinematicsML.cc index 3e17919865..1909bd551e 100644 --- a/src/algorithms/onnx/InclusiveKinematicsML.cc +++ b/src/algorithms/onnx/InclusiveKinematicsML.cc @@ -35,7 +35,7 @@ namespace eicrecon { m_log = logger; // onnxruntime setup - Ort::Env env(ORT_LOGGING_LEVEL_VERBOSE, "inclusive-kinematics-ml"); + Ort::Env env(ORT_LOGGING_LEVEL_WARNING, "inclusive-kinematics-ml"); Ort::SessionOptions session_options; try { m_session = Ort::Session(env, m_cfg.modelPath.c_str(), session_options); From 1813a105b19cb02aa6079e2b845440ddc426b53b Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Thu, 11 Apr 2024 19:45:10 -0500 Subject: [PATCH 12/17] fix: no assert, return instead --- src/algorithms/onnx/InclusiveKinematicsML.cc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/algorithms/onnx/InclusiveKinematicsML.cc b/src/algorithms/onnx/InclusiveKinematicsML.cc index 1909bd551e..15093d2fcf 100644 --- a/src/algorithms/onnx/InclusiveKinematicsML.cc +++ b/src/algorithms/onnx/InclusiveKinematicsML.cc @@ -78,10 +78,16 @@ namespace eicrecon { auto [ml] = output; // Require valid inputs - if (electron->size() == 0 || da->size() == 0) return; + if (electron->size() == 0 || da->size() == 0) { + m_log->debug("skipping because input collections have no entries"); + return; + } // Assume model has 1 input nodes and 1 output node. - assert(m_input_names.size() == 1 && m_output_names.size() == 1); + if (m_input_names.size() != 1 || m_output_names.size() != 1) { + m_log->debug("skipping because model has incorrect input and output size"); + return; + } // Prepare input tensor std::vector input_tensor_values; @@ -92,7 +98,10 @@ namespace eicrecon { input_tensors.emplace_back(vec_to_tensor(input_tensor_values, m_input_shapes.front())); // Double-check the dimensions of the input tensor - assert(input_tensors[0].IsTensor() && input_tensors[0].GetTensorTypeAndShapeInfo().GetShape() == m_input_shapes.front()); + if (! input_tensors[0].IsTensor() || input_tensors[0].GetTensorTypeAndShapeInfo().GetShape() != m_input_shapes.front()) { + m_log->debug("skipping because input tensor shape incorrect"); + return; + } // Attempt inference try { @@ -100,7 +109,10 @@ namespace eicrecon { m_input_names_char.size(), m_output_names_char.data(), m_output_names_char.size()); // Double-check the dimensions of the output tensors - assert(output_tensors.size() == m_output_names.size() && output_tensors[0].IsTensor()); + if (!output_tensors[0].IsTensor() || output_tensors.size() != m_output_names.size()) { + m_log->debug("skipping because output tensor shape incorrect"); + return; + } // Convert output tensor float* output_tensor_data = output_tensors[0].GetTensorMutableData(); From c9ac7b83febd61f4896071c65ebe811795d39a51 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Thu, 11 Apr 2024 19:45:51 -0500 Subject: [PATCH 13/17] fix: default modelPath calibrations/identity_gemm_w1x1_b1.onnx --- src/algorithms/onnx/InclusiveKinematicsMLConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/onnx/InclusiveKinematicsMLConfig.h b/src/algorithms/onnx/InclusiveKinematicsMLConfig.h index 86402d26e5..3894e898e4 100644 --- a/src/algorithms/onnx/InclusiveKinematicsMLConfig.h +++ b/src/algorithms/onnx/InclusiveKinematicsMLConfig.h @@ -9,7 +9,7 @@ namespace eicrecon { struct InclusiveKinematicsMLConfig { - std::string modelPath{""}; + std::string modelPath{"calibrations/identity_gemm_w1x1_b1.onnx"}; }; From e33f2a1e230e7b11dd986160f801b2a67b2ef7ff Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Thu, 11 Apr 2024 19:50:12 -0500 Subject: [PATCH 14/17] dbg: force download onnx artifact in CI [REVERT ME] --- .github/workflows/linux-eic-shell.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/linux-eic-shell.yml b/.github/workflows/linux-eic-shell.yml index a06a307bd9..04ccb3900b 100644 --- a/.github/workflows/linux-eic-shell.yml +++ b/.github/workflows/linux-eic-shell.yml @@ -414,6 +414,7 @@ jobs: export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH export JANA_PLUGIN_PATH=$PWD/install/lib/EICrecon/plugins${JANA_PLUGIN_PATH:+:${JANA_PLUGIN_PATH}} + wget --directory-prefix=calibrations https://github.com/eic/epic-data/raw/812daafabbe7ed7e269f1b20f090de0517b06b9c/onnx/identity_gemm_w1x1_b1.onnx $PWD/install/bin/eicrecon -Ppodio:output_include_collections=EventHeader,MCParticles,EcalBarrelScFiRawHits,EcalBarrelImagingRawHits -Ppodio:output_file=two_stage_raw_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4eic.root sim_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4hep.root -Pplugins=dump_flags,janadot -Pdump_flags:json=${{ matrix.particle }}_${{ matrix.detector_config }}_flags.json -Pjana:warmup_timeout=0 -Pjana:timeout=0 - name: Upload digitization output uses: actions/upload-artifact@v4 @@ -430,6 +431,7 @@ jobs: export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH export JANA_PLUGIN_PATH=$PWD/install/lib/EICrecon/plugins${JANA_PLUGIN_PATH:+:${JANA_PLUGIN_PATH}} + wget --directory-prefix=calibrations https://github.com/eic/epic-data/raw/812daafabbe7ed7e269f1b20f090de0517b06b9c/onnx/identity_gemm_w1x1_b1.onnx $PWD/install/bin/eicrecon -Ppodio:output_include_collections=EcalBarrelClusters,EcalBarrelClusterAssociations -Ppodio:output_file=two_stage_rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4eic.root two_stage_raw_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4eic.root -Pplugins=dump_flags,janadot -Pdump_flags:json=${{ matrix.particle }}_${{ matrix.detector_config }}_flags.json -Pjana:warmup_timeout=0 -Pjana:timeout=0 - name: Upload reconstruction output uses: actions/upload-artifact@v4 @@ -476,6 +478,7 @@ jobs: export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH export JANA_PLUGIN_PATH=$PWD/install/lib/EICrecon/plugins${JANA_PLUGIN_PATH:+:${JANA_PLUGIN_PATH}} + wget --directory-prefix=calibrations https://github.com/eic/epic-data/raw/812daafabbe7ed7e269f1b20f090de0517b06b9c/onnx/identity_gemm_w1x1_b1.onnx $PWD/install/bin/eicmkplugin.py MyCustomPlugin cmake -S MyCustomPlugin -B MyCustomPlugin/build -DEICrecon_ROOT=$PWD/install -DUSER_PLUGIN_OUTPUT_DIRECTORY=$PWD/install/lib/EICrecon/plugins cmake --build MyCustomPlugin/build -j $(getconf _NPROCESSORS_ONLN) --target install @@ -527,6 +530,7 @@ jobs: export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH export JANA_PLUGIN_PATH=$PWD/install/lib/EICrecon/plugins${JANA_PLUGIN_PATH:+:${JANA_PLUGIN_PATH}} + wget --directory-prefix=calibrations https://github.com/eic/epic-data/raw/812daafabbe7ed7e269f1b20f090de0517b06b9c/onnx/identity_gemm_w1x1_b1.onnx $PWD/install/bin/eicrecon -Pplugins=${{ matrix.benchmark_plugins }} -Phistsfile=rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}_${{ matrix.benchmark_plugins }}.hists.root -Ppodio:output_file=rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4eic.root sim_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4hep.root -Pplugins=dump_flags,janadot -Pdump_flags:json=${{ matrix.particle }}_${{ matrix.detector_config }}_flags.json -Pjana:warmup_timeout=0 -Pjana:timeout=0 - uses: actions/upload-artifact@v4 with: @@ -580,6 +584,7 @@ jobs: export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH export JANA_PLUGIN_PATH=$PWD/install/lib/EICrecon/plugins:/usr/local/plugins + wget --directory-prefix=calibrations https://github.com/eic/epic-data/raw/812daafabbe7ed7e269f1b20f090de0517b06b9c/onnx/identity_gemm_w1x1_b1.onnx $PWD/install/bin/eicrecon -Ppodio:output_file=rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4eic.root sim_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4hep.root -Pplugins=dump_flags,janadot,janatop -Pdump_flags:json=${{ matrix.particle }}_${{ matrix.detector_config }}_flags.json -Pjana:warmup_timeout=0 -Pjana:timeout=0 dot -Tsvg jana.dot > jana.svg mv jana.dot rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.dot @@ -686,6 +691,7 @@ jobs: export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH export JANA_PLUGIN_PATH=$PWD/install/lib/EICrecon/plugins:/usr/local/plugins + wget --directory-prefix=calibrations https://github.com/eic/epic-data/raw/812daafabbe7ed7e269f1b20f090de0517b06b9c/onnx/identity_gemm_w1x1_b1.onnx $PWD/install/bin/eicrecon -Ppodio:output_file=rec_${{ matrix.particle }}_EcalLumiSpec_${{ matrix.detector_config }}.edm4eic.root sim_${{ matrix.particle }}_EcalLumiSpec_${{ matrix.detector_config }}.edm4hep.root -Ppodio:output_include_collections=EcalLumiSpecRawHits,EcalLumiSpecRecHits,EcalLumiSpecClusters,EcalLumiSpecClusterAssociations -PLUMISPECCAL:EcalLumiSpecIslandProtoClusters:splitCluster=1 -Pplugins=dump_flags,janadot,janatop -Pdump_flags:json=${{ matrix.particle }}_${{ matrix.detector_config }}_flags.json -Pjana:warmup_timeout=0 -Pjana:timeout=0 - uses: actions/upload-artifact@v4 with: @@ -745,6 +751,7 @@ jobs: export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH export JANA_PLUGIN_PATH=$PWD/install/lib/EICrecon/plugins:/usr/local/plugins + wget --directory-prefix=calibrations https://github.com/eic/epic-data/raw/812daafabbe7ed7e269f1b20f090de0517b06b9c/onnx/identity_gemm_w1x1_b1.onnx $PWD/install/bin/eicrecon -Ppodio:output_file=rec_dis_${{matrix.beam}}_minQ2=${{matrix.minq2}}_${{ matrix.detector_config }}.edm4eic.root sim_dis_${{matrix.beam}}_minQ2=${{matrix.minq2}}_${{ matrix.detector_config }}.edm4hep.root -Pacts:WriteObj=true -Pacts:WritePly=true -Pplugins=janadot,janatop -Pjana:warmup_timeout=0 -Pjana:timeout=0 dot -Tsvg jana.dot > jana.svg mv jana.dot rec_dis_${{matrix.beam}}_minQ2=${{matrix.minq2}}_${{ matrix.detector_config }}.dot From 9e5ff06c796f5333caecf1daa2dc367d74e23880 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Thu, 11 Apr 2024 20:02:27 -0500 Subject: [PATCH 15/17] fix: iwyu --- src/algorithms/onnx/InclusiveKinematicsML.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/algorithms/onnx/InclusiveKinematicsML.cc b/src/algorithms/onnx/InclusiveKinematicsML.cc index 15093d2fcf..6ef2e72a40 100644 --- a/src/algorithms/onnx/InclusiveKinematicsML.cc +++ b/src/algorithms/onnx/InclusiveKinematicsML.cc @@ -1,7 +1,6 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // Copyright (C) 2022, 2023 Wouter Deconinck, Tooba Ali -#include #include #include #include From a243ced796b600caa269d55c548ae86ca51c1880 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Tue, 16 Apr 2024 16:41:57 -0500 Subject: [PATCH 16/17] Revert "dbg: force download onnx artifact in CI [REVERT ME]" This reverts commit e33f2a1e230e7b11dd986160f801b2a67b2ef7ff. --- .github/workflows/linux-eic-shell.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/linux-eic-shell.yml b/.github/workflows/linux-eic-shell.yml index 04ccb3900b..a06a307bd9 100644 --- a/.github/workflows/linux-eic-shell.yml +++ b/.github/workflows/linux-eic-shell.yml @@ -414,7 +414,6 @@ jobs: export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH export JANA_PLUGIN_PATH=$PWD/install/lib/EICrecon/plugins${JANA_PLUGIN_PATH:+:${JANA_PLUGIN_PATH}} - wget --directory-prefix=calibrations https://github.com/eic/epic-data/raw/812daafabbe7ed7e269f1b20f090de0517b06b9c/onnx/identity_gemm_w1x1_b1.onnx $PWD/install/bin/eicrecon -Ppodio:output_include_collections=EventHeader,MCParticles,EcalBarrelScFiRawHits,EcalBarrelImagingRawHits -Ppodio:output_file=two_stage_raw_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4eic.root sim_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4hep.root -Pplugins=dump_flags,janadot -Pdump_flags:json=${{ matrix.particle }}_${{ matrix.detector_config }}_flags.json -Pjana:warmup_timeout=0 -Pjana:timeout=0 - name: Upload digitization output uses: actions/upload-artifact@v4 @@ -431,7 +430,6 @@ jobs: export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH export JANA_PLUGIN_PATH=$PWD/install/lib/EICrecon/plugins${JANA_PLUGIN_PATH:+:${JANA_PLUGIN_PATH}} - wget --directory-prefix=calibrations https://github.com/eic/epic-data/raw/812daafabbe7ed7e269f1b20f090de0517b06b9c/onnx/identity_gemm_w1x1_b1.onnx $PWD/install/bin/eicrecon -Ppodio:output_include_collections=EcalBarrelClusters,EcalBarrelClusterAssociations -Ppodio:output_file=two_stage_rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4eic.root two_stage_raw_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4eic.root -Pplugins=dump_flags,janadot -Pdump_flags:json=${{ matrix.particle }}_${{ matrix.detector_config }}_flags.json -Pjana:warmup_timeout=0 -Pjana:timeout=0 - name: Upload reconstruction output uses: actions/upload-artifact@v4 @@ -478,7 +476,6 @@ jobs: export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH export JANA_PLUGIN_PATH=$PWD/install/lib/EICrecon/plugins${JANA_PLUGIN_PATH:+:${JANA_PLUGIN_PATH}} - wget --directory-prefix=calibrations https://github.com/eic/epic-data/raw/812daafabbe7ed7e269f1b20f090de0517b06b9c/onnx/identity_gemm_w1x1_b1.onnx $PWD/install/bin/eicmkplugin.py MyCustomPlugin cmake -S MyCustomPlugin -B MyCustomPlugin/build -DEICrecon_ROOT=$PWD/install -DUSER_PLUGIN_OUTPUT_DIRECTORY=$PWD/install/lib/EICrecon/plugins cmake --build MyCustomPlugin/build -j $(getconf _NPROCESSORS_ONLN) --target install @@ -530,7 +527,6 @@ jobs: export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH export JANA_PLUGIN_PATH=$PWD/install/lib/EICrecon/plugins${JANA_PLUGIN_PATH:+:${JANA_PLUGIN_PATH}} - wget --directory-prefix=calibrations https://github.com/eic/epic-data/raw/812daafabbe7ed7e269f1b20f090de0517b06b9c/onnx/identity_gemm_w1x1_b1.onnx $PWD/install/bin/eicrecon -Pplugins=${{ matrix.benchmark_plugins }} -Phistsfile=rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}_${{ matrix.benchmark_plugins }}.hists.root -Ppodio:output_file=rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4eic.root sim_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4hep.root -Pplugins=dump_flags,janadot -Pdump_flags:json=${{ matrix.particle }}_${{ matrix.detector_config }}_flags.json -Pjana:warmup_timeout=0 -Pjana:timeout=0 - uses: actions/upload-artifact@v4 with: @@ -584,7 +580,6 @@ jobs: export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH export JANA_PLUGIN_PATH=$PWD/install/lib/EICrecon/plugins:/usr/local/plugins - wget --directory-prefix=calibrations https://github.com/eic/epic-data/raw/812daafabbe7ed7e269f1b20f090de0517b06b9c/onnx/identity_gemm_w1x1_b1.onnx $PWD/install/bin/eicrecon -Ppodio:output_file=rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4eic.root sim_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4hep.root -Pplugins=dump_flags,janadot,janatop -Pdump_flags:json=${{ matrix.particle }}_${{ matrix.detector_config }}_flags.json -Pjana:warmup_timeout=0 -Pjana:timeout=0 dot -Tsvg jana.dot > jana.svg mv jana.dot rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.dot @@ -691,7 +686,6 @@ jobs: export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH export JANA_PLUGIN_PATH=$PWD/install/lib/EICrecon/plugins:/usr/local/plugins - wget --directory-prefix=calibrations https://github.com/eic/epic-data/raw/812daafabbe7ed7e269f1b20f090de0517b06b9c/onnx/identity_gemm_w1x1_b1.onnx $PWD/install/bin/eicrecon -Ppodio:output_file=rec_${{ matrix.particle }}_EcalLumiSpec_${{ matrix.detector_config }}.edm4eic.root sim_${{ matrix.particle }}_EcalLumiSpec_${{ matrix.detector_config }}.edm4hep.root -Ppodio:output_include_collections=EcalLumiSpecRawHits,EcalLumiSpecRecHits,EcalLumiSpecClusters,EcalLumiSpecClusterAssociations -PLUMISPECCAL:EcalLumiSpecIslandProtoClusters:splitCluster=1 -Pplugins=dump_flags,janadot,janatop -Pdump_flags:json=${{ matrix.particle }}_${{ matrix.detector_config }}_flags.json -Pjana:warmup_timeout=0 -Pjana:timeout=0 - uses: actions/upload-artifact@v4 with: @@ -751,7 +745,6 @@ jobs: export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH export JANA_PLUGIN_PATH=$PWD/install/lib/EICrecon/plugins:/usr/local/plugins - wget --directory-prefix=calibrations https://github.com/eic/epic-data/raw/812daafabbe7ed7e269f1b20f090de0517b06b9c/onnx/identity_gemm_w1x1_b1.onnx $PWD/install/bin/eicrecon -Ppodio:output_file=rec_dis_${{matrix.beam}}_minQ2=${{matrix.minq2}}_${{ matrix.detector_config }}.edm4eic.root sim_dis_${{matrix.beam}}_minQ2=${{matrix.minq2}}_${{ matrix.detector_config }}.edm4hep.root -Pacts:WriteObj=true -Pacts:WritePly=true -Pplugins=janadot,janatop -Pjana:warmup_timeout=0 -Pjana:timeout=0 dot -Tsvg jana.dot > jana.svg mv jana.dot rec_dis_${{matrix.beam}}_minQ2=${{matrix.minq2}}_${{ matrix.detector_config }}.dot From 49ef2465aeca0e7f8547a6a62748644f82f594e9 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Tue, 16 Apr 2024 16:44:16 -0500 Subject: [PATCH 17/17] fix: use test model in calibrations/onnx --- src/algorithms/onnx/InclusiveKinematicsMLConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/onnx/InclusiveKinematicsMLConfig.h b/src/algorithms/onnx/InclusiveKinematicsMLConfig.h index 3894e898e4..dd7bd37d1a 100644 --- a/src/algorithms/onnx/InclusiveKinematicsMLConfig.h +++ b/src/algorithms/onnx/InclusiveKinematicsMLConfig.h @@ -9,7 +9,7 @@ namespace eicrecon { struct InclusiveKinematicsMLConfig { - std::string modelPath{"calibrations/identity_gemm_w1x1_b1.onnx"}; + std::string modelPath{"calibrations/onnx/identity_gemm_w1x1_b1.onnx"}; };