All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LArDLHelper.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoradlcontent/LArHelpers/LArDLHelper.cc
3  *
4  * @brief Implementation of the lar deep learning helper helper class.
5  *
6  * $Log: $
7  */
8 
10 
11 namespace lar_dl_content
12 {
13 
14 using namespace pandora;
15 
16 StatusCode LArDLHelper::LoadModel(const std::string &filename, LArDLHelper::TorchModel &model)
17 {
18  try
19  {
20  model = torch::jit::load(filename);
21  std::cout << "Loaded the TorchScript model \'" << filename << "\'" << std::endl;
22  }
23  catch (const std::exception &e)
24  {
25  std::cout << "Error loading the TorchScript model \'" << filename << "\':\n" << e.what() << std::endl;
26  return STATUS_CODE_FAILURE;
27  }
28 
29  return STATUS_CODE_SUCCESS;
30 }
31 
32 //------------------------------------------------------------------------------------------------------------------------------------------
33 
34 void LArDLHelper::InitialiseInput(const at::IntArrayRef dimensions, TorchInput &tensor)
35 {
36  tensor = torch::zeros(dimensions);
37 }
38 
39 //------------------------------------------------------------------------------------------------------------------------------------------
40 
42 {
43  output = model.forward(input).toTensor();
44 }
45 
46 } // namespace lar_dl_content
BEGIN_PROLOG could also be dds filename
torch::jit::script::Module TorchModel
Definition: LArDLHelper.h:25
Header file for the lar deep learning helper helper class.
static void Forward(TorchModel &model, const TorchInputVector &input, TorchOutput &output)
Run a deep learning model.
Definition: LArDLHelper.cc:41
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
Definition: reco_sbnd.fcl:182
static pandora::StatusCode LoadModel(const std::string &filename, TorchModel &model)
Loads a deep learning model.
Definition: LArDLHelper.cc:16
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
do i e
static void InitialiseInput(const at::IntArrayRef dimensions, TorchInput &tensor)
Create a torch input tensor.
Definition: LArDLHelper.cc:34
BEGIN_PROLOG could also be cout
std::vector< torch::jit::IValue > TorchInputVector
Definition: LArDLHelper.h:27