Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fix build on macos #424

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ endif()
if(WITH_ONNX)
# New onnxruntime (at least 1.17.1 and above) provide a onnxruntimeConfig.cmake
# and use the name onnxruntime
find_package(onnxruntime)
if (NOT onnxruntime_FOUND)
find_package(onnxruntime REQUIRED)
if (NOT TARGET onnxruntime::onnxruntime)
message(STATUS "Could not find onnxruntime (> 1.17.1). Looking for an older version")
find_package(ONNXRuntime)
else()
set(onnxruntime_FOUND TRUE)
endif()

if(onnxruntime_FOUND OR ONNXRuntime_FOUND)
Expand Down
1 change: 0 additions & 1 deletion addons/FastJet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ add_custom_command(TARGET FastJet POST_BUILD
install(FILES
${CMAKE_CURRENT_LIST_DIR}/ExternalRecombiner.h
${CMAKE_CURRENT_LIST_DIR}/ValenciaPlugin.h
${CMAKE_CURRENT_LIST_DIR}/JetClustering.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/FastJet
)

Expand Down
2 changes: 1 addition & 1 deletion addons/ONNXRuntime/ONNXRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ONNXRuntime {
const std::vector<std::string>& inputNames() const { return input_names_; }

template <typename T>
Tensor<T> run(Tensor<T>&, const Tensor<long>& = {}, unsigned long long = 1ull) const;
Tensor<T> run(Tensor<T>&, const Tensor<int64_t>& = {}, unsigned long long = 1ull) const;

private:
size_t variablePos(const std::string&) const;
Expand Down
2 changes: 1 addition & 1 deletion addons/ONNXRuntime/WeaverInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class WeaverInterface {

std::unique_ptr<ONNXRuntime> onnx_;
std::vector<std::string> variables_names_;
ONNXRuntime::Tensor<long> input_shapes_;
ONNXRuntime::Tensor<int64_t> input_shapes_;
std::vector<unsigned int> input_sizes_;
std::unordered_map<std::string, PreprocessParams> prep_info_map_;
ONNXRuntime::Tensor<float> data_;
Expand Down
11 changes: 6 additions & 5 deletions addons/ONNXRuntime/src/ONNXRuntime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <numeric>
#include <algorithm>
#include <vector>

ONNXRuntime::ONNXRuntime(const std::string& model_path, const std::vector<std::string>& input_names)
: env_(new Ort::Env(OrtLoggingLevel::ORT_LOGGING_LEVEL_WARNING, "onnx_runtime")),
Expand Down Expand Up @@ -58,16 +59,16 @@ ONNXRuntime::~ONNXRuntime() {}

template <typename T>
ONNXRuntime::Tensor<T> ONNXRuntime::run(Tensor<T>& input,
const Tensor<long>& input_shapes,
const Tensor<int64_t>& input_shapes,
unsigned long long batch_size) const {
std::vector<Ort::Value> tensors_in;
for (const auto& name : input_node_strings_) {
auto input_pos = variablePos(name);
auto value = input.begin() + input_pos;
std::vector<int64_t> input_dims;
std::vector< int64_t> input_dims;
if (input_shapes.empty()) {
input_dims = input_node_dims_.at(name);
input_dims[0] = batch_size;
input_dims = input_node_dims_.at(name);
input_dims[0] = (int64_t) batch_size;
} else {
input_dims = input_shapes[input_pos];
// rely on the given input_shapes to set the batch size
Expand Down Expand Up @@ -117,4 +118,4 @@ size_t ONNXRuntime::variablePos(const std::string& name) const {
return iter - input_names_.begin();
}

template ONNXRuntime::Tensor<float> ONNXRuntime::run(Tensor<float>&, const Tensor<long>&, unsigned long long) const;
template ONNXRuntime::Tensor<float> ONNXRuntime::run(Tensor<float>&, const Tensor<int64_t>&, unsigned long long) const;
2 changes: 1 addition & 1 deletion analyzers/dataframe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ target_include_directories(FCCAnalyses PUBLIC

message(STATUS " ====== DELPHES LIBRARY = " ${DELPHES_LIBRARY} )
message(STATUS " ====== DELPHES_EXTERNALS_TKCOV_INCLUDE_DIR = " ${DELPHES_EXTERNALS_TKCOV_INCLUDE_DIR} )
message(STATUS " ====== ADDONS_LIBRARIES " ${ADDONS_LIBRARIES})

target_link_libraries(FCCAnalyses PUBLIC
ROOT::Physics
Expand All @@ -73,7 +74,6 @@ target_link_libraries(FCCAnalyses PUBLIC
podio::podioDataSource
${ADDONS_LIBRARIES}
${DELPHES_LIBRARY}
gfortran # todo: why necessary?
)

if(WITH_DD4HEP)
Expand Down
2 changes: 1 addition & 1 deletion analyzers/dataframe/FCCAnalyses/Algorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "edm4hep/ReconstructedParticleData.h"

#include "FastJet/JetClustering.h"
#include "FCCAnalyses/JetClustering.h"

//#include "TFitter.h"
#include "Math/Minimizer.h"
Expand Down
2 changes: 1 addition & 1 deletion analyzers/dataframe/FCCAnalyses/JetClusteringUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "Math/Vector4D.h"
#include "ROOT/RVec.hxx"

#include "FastJet/JetClustering.h"
#include "FCCAnalyses/JetClustering.h"
#include "fastjet/JetDefinition.hh"

#include "TRandom3.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "FastJet/JetClustering.h"
#include "FCCAnalyses/JetClustering.h"
#include "FastJet/ExternalRecombiner.h"

#include "FCCAnalyses/JetClusteringUtils.h"
Expand Down
10 changes: 10 additions & 0 deletions analyzers/dataframe/src/VertexFitterSimple.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace FCCAnalyses {

namespace VertexFitterSimple {

#ifndef __APPLE__
int supress_stdout() {
fflush(stdout);

Expand All @@ -35,6 +36,15 @@ void resume_stdout(int fd) {
std::cout << std::flush;
}

#else
int supress_stdout() {
return 0;
}

void resume_stdout(int fd) {
}
#endif

// -----------------------------------------------------------------------------

VertexingUtils::FCCAnalysesVertex VertexFitter(
Expand Down
25 changes: 0 additions & 25 deletions cmake/FindONNXRuntime.cmake

This file was deleted.

Loading