ATLAS Offline Software
NNSharingSvc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef NN_SHARING_SVC_H
6 #define NN_SHARING_SVC_H
7 
10 
12 #include "FlavorTagInference/GNN.h"
13 
14 namespace FlavorTagInference
15 {
16 
17  namespace detail {
18  struct NNKey {
19  std::string path;
21  bool operator==(const NNKey&) const;
22  std::size_t hash() const;
23  };
24  struct NNHasher {
25  std::size_t operator()(const NNKey& o) const {
26  return o.hash();
27  }
28  };
29  }
30 
31  class NNSharingSvc: public extends<asg::AsgService, INNSharingSvc>
32  {
33  public:
34  using extends::extends; // base class constructor
35 #ifndef XAOD_ANALYSIS
36  virtual StatusCode initialize() override;
37 #endif
38  virtual std::shared_ptr<const GNN> get(
39  const std::string& nn_name,
40  const GNNOptions& opts) override;
41  private:
42  using val_t = std::shared_ptr<const GNN>;
43  std::unordered_map<detail::NNKey, val_t, detail::NNHasher> m_gnns;
44  std::unordered_map<std::string, val_t> m_base_gnns;
45 #ifndef XAOD_ANALYSIS
46  Gaudi::Property<bool> m_useTriton {this, "UseTriton", false
47  , "Toggle running the inference through Triton"};
48  Gaudi::Property<float> m_tritonTimeout {this, "TritonTimeout", 0.f
49  , "Timeout value for Triton client"};
50  Gaudi::Property<int> m_tritonPort {this, "TritonPort", 443
51  , "Triton server port"};
52  Gaudi::Property<std::string> m_tritonUrl {this, "TritonUrl", ""
53  , "Triton server URL"};
54  Gaudi::Property<bool> m_tritonUseSsl {this, "TritonUseSSL", true
55  , "Connect to the Triton server over SSL"};
56 
57  // !!! ------ For testing purpose only! -------- !!!
58  // In the long run we need to find some other mechanism
59  // for mapping physical paths to model names
60  std::map<std::string, std::string> m_tritonPathToName;
61  void initTritonPathToName();
62  // !!! ----------------------------------------- !!!
63 #endif
64  };
65 
66 }
67 
68 #endif
GNN.h
AsgService.h
FlavorTagInference
This file contains "getter" functions used for accessing tagger inputs from the EDM.
Definition: PhysicsAnalysis/JetTagging/FlavorTagInference/FlavorTagInference/ConstituentsLoader.h:27
FlavorTagInference::detail::NNHasher
Definition: NNSharingSvc.h:24
detail
Definition: extract_histogram_tag.cxx:14
FlavorTagInference::NNSharingSvc::m_tritonUrl
Gaudi::Property< std::string > m_tritonUrl
Definition: NNSharingSvc.h:52
GNNOptions.h
FlavorTagInference::NNSharingSvc
Definition: NNSharingSvc.h:32
FlavorTagInference::NNSharingSvc::m_useTriton
Gaudi::Property< bool > m_useTriton
Definition: NNSharingSvc.h:46
FlavorTagInference::NNSharingSvc::m_tritonTimeout
Gaudi::Property< float > m_tritonTimeout
Definition: NNSharingSvc.h:48
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
FlavorTagInference::detail::NNHasher::operator()
std::size_t operator()(const NNKey &o) const
Definition: NNSharingSvc.h:25
FlavorTagInference::NNSharingSvc::m_gnns
std::unordered_map< detail::NNKey, val_t, detail::NNHasher > m_gnns
Definition: NNSharingSvc.h:43
FlavorTagInference::NNSharingSvc::initTritonPathToName
void initTritonPathToName()
Definition: NNSharingSvc.cxx:76
FlavorTagInference::NNSharingSvc::m_tritonUseSsl
Gaudi::Property< bool > m_tritonUseSsl
Definition: NNSharingSvc.h:54
FlavorTagInference::detail::NNKey::operator==
bool operator==(const NNKey &) const
Definition: NNSharingSvc.cxx:20
FlavorTagInference::NNSharingSvc::initialize
virtual StatusCode initialize() override
Definition: NNSharingSvc.cxx:68
FlavorTagInference::NNSharingSvc::m_tritonPathToName
std::map< std::string, std::string > m_tritonPathToName
Definition: NNSharingSvc.h:60
FlavorTagInference::GNNOptions
Definition: GNNOptions.h:15
FlavorTagInference::NNSharingSvc::get
virtual std::shared_ptr< const GNN > get(const std::string &nn_name, const GNNOptions &opts) override
Definition: NNSharingSvc.cxx:25
FlavorTagInference::detail::NNKey
Definition: NNSharingSvc.h:18
FlavorTagInference::detail::NNKey::hash
std::size_t hash() const
Definition: NNSharingSvc.cxx:15
INNSharingSvc.h
FlavorTagInference::detail::NNKey::opts
GNNOptions opts
Definition: NNSharingSvc.h:20
FlavorTagInference::NNSharingSvc::m_tritonPort
Gaudi::Property< int > m_tritonPort
Definition: NNSharingSvc.h:50
FlavorTagInference::detail::NNKey::path
std::string path
Definition: NNSharingSvc.h:19
FlavorTagInference::NNSharingSvc::m_base_gnns
std::unordered_map< std::string, val_t > m_base_gnns
Definition: NNSharingSvc.h:44
FlavorTagInference::NNSharingSvc::val_t
std::shared_ptr< const GNN > val_t
Definition: NNSharingSvc.h:42
athena.opts
opts
Definition: athena.py:88