10 #ifdef LIBTORCH_ENABLED 12 #include <torch/torch.h> 28 torch::jit::script::Module * base =
this;
29 *base = torch::jit::load(filename);
31 catch (
const c10::Error & e)
33 mooseError(
"Error while loading torchscript file ", filename,
"!\n", e.msg());
40 std::vector<torch::jit::IValue> inputs(1, x);
41 return torch::jit::script::Module::forward(inputs).toTensor();
virtual torch::Tensor forward(const torch::Tensor &x) override
Overriding the forward substitution function for the neural network, unfortunately this cannot be con...
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
void loadNeuralNetwork(const std::string &filename)
Construct the neural network.
TorchScriptModule()
Construct using a filename which contains the source code in torchscript format.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...