I have trained a model from python and now I’m trying to load it from a c++ program. Unfortunately it crashes on the line // crash here
#include <torch/script.h>
#include <iostream>
#include <vector>
#include "nets/nets.h"
#include "util/runfiles.h"
int main(int argc, char** argv) {
std::cout << "Nets example" << std::endl;
// Custom code that loads the module
auto runfiles = MakeRunfiles(argv[0]);
torch::jit::script::Module segnet3 = LoadSegNet3(*runfiles);
std::cout << "Loaded SegNet3" << std::endl;
// Make a fake image.
torch::Tensor input = torch::randn({1, 3, 300, 300});
std::cout << "Made random input" << std::endl;
std::vector<torch::jit::IValue> inputs;
inputs.push_back(input);
// crash here
torch::Tensor output = segnet3.forward(inputs).toTensor();
std::cout << "Output done" << std::endl;
}
The output of the program is
Nets example
Loaded SegNet3
Made random input
and it exits without writing any error message.
What can I do to debug the situation? I am wondering if maybe my input tensor is of the wrong dimensionality. Is there a way to check the dimensions the network is expecting? And/or is there a way to print some debug information about the structure of the network?