15#include "neml2/csrc/aoti/log.h"
16#include <torch/script.h>
26 const std::string & filename)
30 torch::jit::Module mod(
"neml2_failed_inputs");
31 for (
const auto & [name, tensor] : inputs)
33 if (!tensor.defined())
35 std::string key = name;
37 if (!std::isalnum(
static_cast<unsigned char>(c)) && c !=
'_')
39 mod.register_buffer(key, tensor.detach().to(at::kCPU).contiguous());
51 neml2::aoti::log::set_sink([console](neml2::aoti::log::Level,
const std::string & line)
52 { console << line << std::endl; });
76static const std::string
missing_neml2 =
"The `NEML2` library is required but not enabled. Refer "
77 "to the documentation for guidance on how to enable it.";
83 return missing_neml2 +
" (Original description: " + desc +
")";
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
A helper class for re-directing output streams to Console output objects form MooseObjects.
void dumpInputsToTorchScript(const std::map< std::string, at::Tensor > &inputs, const std::string &filename)
Serialize a set of named NEML2 input tensors to a TorchScript archive at filename (a torch::jit::Modu...
std::string docstring(const std::string &desc)
Augment docstring if NEML2 is not enabled.
static const std::string missing_neml2
void redirectLogsToConsole(const ConsoleStream &console)
Route NEML2's log output into MOOSE's console.
void assertNEML2Enabled()
Assert that NEML2 is enabled.
std::string stringify(MOOSEIOType type)