ATLAS Offline Software
Loading...
Searching...
No Matches
InferenceUtils.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef MUONINFERENCE_INFERENCEUTILS_H
5#define MUONINFERENCE_INFERENCEUTILS_H
6
8
9#include <cmath>
10
12
14 bool isCuda{false};
16};
17
18template <class SessionToolHandle>
19SessionBackend sessionBackend(const SessionToolHandle& sessionTool) {
20 if (const auto* cudaTool = dynamic_cast<const AthOnnx::OnnxRuntimeSessionToolCUDA*>(sessionTool.get())) {
21 return SessionBackend{true, cudaTool->deviceId()};
22 }
23 return SessionBackend{};
24}
25
26inline float sigmoid(float x) {
27 if (x >= 0.f) {
28 const float z = std::exp(-x);
29 return 1.f / (1.f + z);
30 }
31 const float z = std::exp(x);
32 return z / (1.f + z);
33}
34
35} // namespace MuonML::InferenceUtils
36
37#endif // MUONINFERENCE_INFERENCEUTILS_H
#define x
#define z
SessionBackend sessionBackend(const SessionToolHandle &sessionTool)