Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linux-eic-shell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ jobs:
platform-release: "${{ env.platform }}:${{ matrix.release }}"
run: |
# install this repo
CXX="${{ matrix.CXX }}" CXXFLAGS="${{ matrix.CXXFLAGS }}" cmake --warn-uninitialized -B build -S . -DCMAKE_INSTALL_PREFIX=install -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=${{ matrix.CMAKE_BUILD_TYPE }} -DUSE_ASAN=${{matrix.USE_ASAN}} -DUSE_TSAN=${{matrix.USE_TSAN}} -DUSE_UBSAN=${{matrix.USE_UBSAN}}
CXX="${{ matrix.CXX }}" CXXFLAGS="${{ matrix.CXXFLAGS }}" cmake --warn-uninitialized -B build -S . -DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_BATCH_SIZE=24 -DCMAKE_UNITY_BUILD_UNIQUE_ID=UNITY_BUILD_UNIQUE_ID -DCMAKE_INSTALL_PREFIX=install -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=${{ matrix.CMAKE_BUILD_TYPE }} -DUSE_ASAN=${{matrix.USE_ASAN}} -DUSE_TSAN=${{matrix.USE_TSAN}} -DUSE_UBSAN=${{matrix.USE_UBSAN}}
cmake --build build -j $(getconf _NPROCESSORS_ONLN) --target install
ccache --show-stats --verbose
ccache --evict-older-than 7d
Expand Down
4 changes: 0 additions & 4 deletions src/algorithms/calorimetry/CalorimeterIslandCluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
using namespace edm4eic;

namespace eicrecon {
template <typename... L> struct multilambda : L... {
using L::operator()...;
constexpr multilambda(L... lambda) : L(std::move(lambda))... {}
};

static double Phi_mpi_pi(double phi) { return std::remainder(phi, 2 * M_PI); }

Expand Down
5 changes: 5 additions & 0 deletions src/algorithms/calorimetry/CalorimeterIslandCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ class CalorimeterIslandCluster : public CalorimeterIslandClusterAlgorithm,
dd4hep::IDDescriptor m_idSpec;

private:
template <typename... L> struct multilambda : L... {
using L::operator()...;
constexpr multilambda(L... lambda) : L(std::move(lambda))... {}
};

// grouping function with Breadth-First Search
void bfs_group(const edm4eic::CalorimeterHitCollection& hits, std::set<std::size_t>& group,
std::size_t idx, std::vector<bool>& visits) const;
Expand Down
4 changes: 0 additions & 4 deletions src/algorithms/calorimetry/ImagingTopoCluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
#include "algorithms/calorimetry/ImagingTopoClusterConfig.h"

namespace eicrecon {
template <typename... L> struct multilambda : L... {
using L::operator()...;
constexpr multilambda(L... lambda) : L(std::move(lambda))... {}
};

void ImagingTopoCluster::init() {

Expand Down
5 changes: 5 additions & 0 deletions src/algorithms/calorimetry/ImagingTopoCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ class ImagingTopoCluster : public ImagingTopoClusterAlgorithm,
void process(const Input& input, const Output& output) const final;

private:
template <typename... L> struct multilambda : L... {
using L::operator()...;
constexpr multilambda(L... lambda) : L(std::move(lambda))... {}
};

// helper function to group hits
bool is_neighbour(const edm4eic::CalorimeterHit& h1, const edm4eic::CalorimeterHit& h2) const;

Expand Down
46 changes: 30 additions & 16 deletions src/algorithms/onnx/InclusiveKinematicsML.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,37 @@

namespace eicrecon {

static std::string print_shape(const std::vector<std::int64_t>& 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();
}
#ifndef UNITY_BUILD_UNIQUE_ID
#define UNITY_BUILD_UNIQUE_ID
#endif

template <typename T>
Ort::Value vec_to_tensor(std::vector<T>& data, const std::vector<std::int64_t>& shape) {
Ort::MemoryInfo mem_info = Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator,
OrtMemType::OrtMemTypeDefault);
auto tensor =
Ort::Value::CreateTensor<T>(mem_info, data.data(), data.size(), shape.data(), shape.size());
return tensor;
}
namespace {
namespace UNITY_BUILD_UNIQUE_ID {

static std::string print_shape(const std::vector<std::int64_t>& 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 <typename T>
Ort::Value vec_to_tensor(std::vector<T>& data, const std::vector<std::int64_t>& shape) {
Ort::MemoryInfo mem_info = Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator,
OrtMemType::OrtMemTypeDefault);
auto tensor = Ort::Value::CreateTensor<T>(mem_info, data.data(), data.size(), shape.data(),
shape.size());
return tensor;
}

} // namespace UNITY_BUILD_UNIQUE_ID
} // namespace

void InclusiveKinematicsML::init() {
using namespace UNITY_BUILD_UNIQUE_ID;

// onnxruntime setup
m_env = Ort::Env(ORT_LOGGING_LEVEL_WARNING, "inclusive-kinematics-ml");
Ort::SessionOptions session_options;
Expand Down Expand Up @@ -89,6 +101,8 @@ void InclusiveKinematicsML::init() {
void InclusiveKinematicsML::process(const InclusiveKinematicsML::Input& input,
const InclusiveKinematicsML::Output& output) const {

using namespace UNITY_BUILD_UNIQUE_ID;

const auto [electron, da] = input;
auto [ml] = output;

Expand Down
76 changes: 45 additions & 31 deletions src/algorithms/onnx/ONNXInference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,54 @@

namespace eicrecon {

static std::string print_shape(const std::vector<std::int64_t>& 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();
}
#ifndef UNITY_BUILD_UNIQUE_ID
#define UNITY_BUILD_UNIQUE_ID
#endif

static bool check_shape_consistency(const std::vector<std::int64_t>& shape1,
const std::vector<std::int64_t>& shape2) {
if (shape2.size() != shape1.size()) {
return false;
}
for (std::size_t ix = 0; ix < shape1.size(); ix++) {
if ((shape1[ix] != -1) && (shape2[ix] != -1) && (shape1[ix] != shape2[ix])) {
return false;
namespace {
namespace UNITY_BUILD_UNIQUE_ID {

static std::string print_shape(const std::vector<std::int64_t>& 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();
}
}
return true;
}

template <typename T>
static Ort::Value iters_to_tensor(typename std::vector<T>::const_iterator data_begin,
typename std::vector<T>::const_iterator data_end,
std::vector<int64_t>::const_iterator shape_begin,
std::vector<int64_t>::const_iterator shape_end) {
Ort::MemoryInfo mem_info = Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator,
OrtMemType::OrtMemTypeDefault);
auto tensor =
Ort::Value::CreateTensor<T>(mem_info, const_cast<T*>(&*data_begin), data_end - data_begin,
&*shape_begin, shape_end - shape_begin);
return tensor;
}
static bool check_shape_consistency(const std::vector<std::int64_t>& shape1,
const std::vector<std::int64_t>& shape2) {
if (shape2.size() != shape1.size()) {
return false;
}
for (std::size_t ix = 0; ix < shape1.size(); ix++) {
if ((shape1[ix] != -1) && (shape2[ix] != -1) && (shape1[ix] != shape2[ix])) {
return false;
}
}
return true;
}

template <typename T>
static Ort::Value iters_to_tensor(typename std::vector<T>::const_iterator data_begin,
typename std::vector<T>::const_iterator data_end,
std::vector<int64_t>::const_iterator shape_begin,
std::vector<int64_t>::const_iterator shape_end) {
Ort::MemoryInfo mem_info = Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator,
OrtMemType::OrtMemTypeDefault);
auto tensor =
Ort::Value::CreateTensor<T>(mem_info, const_cast<T*>(&*data_begin), data_end - data_begin,
&*shape_begin, shape_end - shape_begin);
return tensor;
}

} // namespace UNITY_BUILD_UNIQUE_ID
} // namespace

void ONNXInference::init() {
using namespace UNITY_BUILD_UNIQUE_ID;

// onnxruntime setup
m_env = Ort::Env(ORT_LOGGING_LEVEL_WARNING, name().data());
Ort::SessionOptions session_options;
Expand Down Expand Up @@ -106,6 +118,8 @@ void ONNXInference::init() {
void ONNXInference::process(const ONNXInference::Input& input,
const ONNXInference::Output& output) const {

using namespace UNITY_BUILD_UNIQUE_ID;

const auto [in_tensors] = input;
auto [out_tensors] = output;

Expand Down
Loading