Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
LArDLHelper.cc
Go to the documentation of this file.
1
10
11namespace lar_dl_content
12{
13
14using namespace pandora;
15
16StatusCode 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
34void 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
Header file for the lar deep learning helper helper class.
torch::jit::script::Module TorchModel
Definition LArDLHelper.h:25
static void InitialiseInput(const at::IntArrayRef dimensions, TorchInput &tensor)
Create a torch input tensor.
std::vector< torch::jit::IValue > TorchInputVector
Definition LArDLHelper.h:27
static pandora::StatusCode LoadModel(const std::string &filename, TorchModel &model)
Loads a deep learning model.
static void Forward(TorchModel &model, const TorchInputVector &input, TorchOutput &output)
Run a deep learning model.
StatusCode
The StatusCode enum.