File indexing completed on 2024-04-06 12:15:47
0001 #ifndef HeterogeneousCore_SonicTriton_TritonEDProducer
0002 #define HeterogeneousCore_SonicTriton_TritonEDProducer
0003
0004
0005 #include "HeterogeneousCore/SonicTriton/interface/TritonDummyCache.h"
0006 #include "HeterogeneousCore/SonicCore/interface/SonicEDProducer.h"
0007 #include "HeterogeneousCore/SonicTriton/interface/TritonClient.h"
0008 #include "FWCore/ServiceRegistry/interface/Service.h"
0009 #include "HeterogeneousCore/SonicTriton/interface/TritonService.h"
0010
0011
0012 template <typename G, typename... Capabilities>
0013 class TritonEDProducerT : public SonicEDProducer<TritonClient, edm::GlobalCache<G>, Capabilities...> {
0014 public:
0015 TritonEDProducerT(edm::ParameterSet const& cfg)
0016 : SonicEDProducer<TritonClient, edm::GlobalCache<G>, Capabilities...>(cfg) {}
0017
0018
0019 static std::unique_ptr<G> initializeGlobalCache(edm::ParameterSet const& pset) {
0020 edm::Service<TritonService> ts;
0021 const auto& clientPset = pset.getParameterSet("Client");
0022 ts->addModel(clientPset.getParameter<std::string>("modelName"),
0023 clientPset.getParameter<edm::FileInPath>("modelConfigPath").fullPath());
0024 return nullptr;
0025 }
0026
0027 static void globalEndJob(G*) {}
0028
0029
0030 virtual void tritonEndStream() {}
0031 void endStream() final {
0032 tritonEndStream();
0033 this->client_.reset();
0034 }
0035 };
0036
0037 template <typename... Capabilities>
0038 using TritonEDProducer = TritonEDProducerT<TritonDummyCache, Capabilities...>;
0039
0040 #endif