LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
LArDLHelper.cc
Go to the documentation of this file.
1 
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 
41 void LArDLHelper::Forward(TorchModel &model, const TorchInputVector &input, TorchOutput &output)
42 {
43  output = model.forward(input).toTensor();
44 }
45 
46 } // namespace lar_dl_content
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
static pandora::StatusCode LoadModel(const std::string &filename, TorchModel &model)
Loads a deep learning model.
Definition: LArDLHelper.cc:16
Float_t e
Definition: plot.C:35
static void InitialiseInput(const at::IntArrayRef dimensions, TorchInput &tensor)
Create a torch input tensor.
Definition: LArDLHelper.cc:34
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::vector< torch::jit::IValue > TorchInputVector
Definition: LArDLHelper.h:27