ATLAS Offline Software
Loading...
Searching...
No Matches
MuonSpectrometer
MuonPhaseII
MuonLearning
MuonInference
src
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
7
#include "
AthOnnxComps/OnnxRuntimeSessionToolCUDA.h
"
8
9
#include <cmath>
10
11
namespace
MuonML::InferenceUtils
{
12
13
struct
SessionBackend
{
14
bool
isCuda
{
false
};
15
int
cudaDeviceId
{0};
16
};
17
18
template
<
class
SessionToolHandle>
19
SessionBackend
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
26
inline
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
OnnxRuntimeSessionToolCUDA.h
x
#define x
z
#define z
AthOnnx::OnnxRuntimeSessionToolCUDA
Definition
OnnxRuntimeSessionToolCUDA.h:21
MuonML::InferenceUtils
Definition
InferenceUtils.h:11
MuonML::InferenceUtils::sessionBackend
SessionBackend sessionBackend(const SessionToolHandle &sessionTool)
Definition
InferenceUtils.h:19
MuonML::InferenceUtils::sigmoid
float sigmoid(float x)
Definition
InferenceUtils.h:26
MuonML::InferenceUtils::SessionBackend
Definition
InferenceUtils.h:13
MuonML::InferenceUtils::SessionBackend::cudaDeviceId
int cudaDeviceId
Definition
InferenceUtils.h:15
MuonML::InferenceUtils::SessionBackend::isCuda
bool isCuda
Definition
InferenceUtils.h:14
Generated on
for ATLAS Offline Software by
1.16.1