Interface class to provide common input parameters, members, and methods for MOOSEObjects that use NEML2 models. More...
#include <NEML2ModelInterface.h>
Public Member Functions | |
| template<typename... P> | |
| NEML2ModelInterface (const InputParameters ¶ms, P &&... args) | |
Static Public Member Functions | |
| static InputParameters | validParams () |
Protected Member Functions | |
| virtual void | validateModel () const |
| Validate the NEML2 material model. | |
| const NEML2ModelHandle & | model () const |
| Get the NEML2 model handle (cpp-aoti by default, cpp-eager when eager=true) | |
| NEML2ModelHandle & | model () |
| Non-const access to the NEML2 model handle, for runtime parameter writes (set_parameter) | |
| const at::Device & | device () const |
| Get the target compute device. | |
| const at::Device & | output_device () const |
| Get the target output device. | |
| unsigned int | neml2NumThreads () const |
| libtorch intra-op thread count to use while evaluating the NEML2 model. | |
Static Private Member Functions | |
| static std::vector< std::string > | loadExtensionPaths (const InputParameters ¶ms) |
| Resolve the 'load' DataFileName list (whose relative paths InputParameters has already resolved against the input file + data search path) to plain path strings for the eager runtime's external-extension loader. | |
| static std::unique_ptr< NEML2ModelHandle > | makeModelHandle (const InputParameters ¶ms, NEML2ModelInterface< T > &self) |
| Parse the runtime parameters and build the model handle. | |
Private Attributes | |
| std::unique_ptr< NEML2ModelHandle > | _model |
| The NEML2 material model handle. | |
| const at::Device | _device |
| The device on which to evaluate the NEML2 model (this rank's scheduler-assigned device) | |
| const at::Device | _output_device |
| The device on which to store the outputs. | |
| const unsigned int | _num_threads |
| libtorch intra-op thread count applied (scoped) during model evaluation; defaults to the MOOSE/libMesh thread count. | |
Interface class to provide common input parameters, members, and methods for MOOSEObjects that use NEML2 models.
Definition at line 28 of file NEML2ModelInterface.h.
| NEML2ModelInterface< T >::NEML2ModelInterface | ( | const InputParameters & | params, |
| P &&... | args | ||
| ) |
Definition at line 219 of file NEML2ModelInterface.h.
|
inlineprotected |
Get the target compute device.
Definition at line 52 of file NEML2ModelInterface.h.
|
inlinestaticprivate |
Resolve the 'load' DataFileName list (whose relative paths InputParameters has already resolved against the input file + data search path) to plain path strings for the eager runtime's external-extension loader.
Definition at line 66 of file NEML2ModelInterface.h.
Referenced by NEML2ModelInterface< T >::makeModelHandle().
|
inlinestaticprivate |
Parse the runtime parameters and build the model handle.
Static so it can run in the member initializer list (before _device, which is read back from the handle). self supplies the MooseObject services (paramError, comm, app) once the T base is constructed.
Definition at line 75 of file NEML2ModelInterface.h.
|
inlineprotected |
Non-const access to the NEML2 model handle, for runtime parameter writes (set_parameter)
Definition at line 49 of file NEML2ModelInterface.h.
|
inlineprotected |
Get the NEML2 model handle (cpp-aoti by default, cpp-eager when eager=true)
Definition at line 46 of file NEML2ModelInterface.h.
|
inlineprotected |
libtorch intra-op thread count to use while evaluating the NEML2 model.
Wrap the evaluation region in NEML2Utils::ScopedNumThreads guard(neml2NumThreads()); so the count is applied only during evaluation and the previous value is restored afterward.
Definition at line 60 of file NEML2ModelInterface.h.
|
inlineprotected |
Get the target output device.
Definition at line 55 of file NEML2ModelInterface.h.
|
protectedvirtual |
Validate the NEML2 material model.
Note that the developer is responsible for calling this method at the appropriate times, for example, at initialSetup().
Definition at line 250 of file NEML2ModelInterface.h.
|
static |
Definition at line 146 of file NEML2ModelInterface.h.
Referenced by NEML2ActionCommon::commonParams(), and NEML2ModelExecutor::validParams().
|
private |
The device on which to evaluate the NEML2 model (this rank's scheduler-assigned device)
Definition at line 134 of file NEML2ModelInterface.h.
Referenced by NEML2ModelInterface< T >::device().
|
private |
The NEML2 material model handle.
Defaults to the cpp-aoti runtime (loads an ahead-of-time- compiled artifact from the 'input' folder); the cpp-eager runtime (embeds a CPython interpreter and loads the model from the source 'input' file) is opt-in via the 'eager' parameter.
Definition at line 132 of file NEML2ModelInterface.h.
Referenced by NEML2ModelInterface< T >::model(), and NEML2ModelInterface< T >::model().
|
private |
libtorch intra-op thread count applied (scoped) during model evaluation; defaults to the MOOSE/libMesh thread count.
Definition at line 139 of file NEML2ModelInterface.h.
Referenced by NEML2ModelInterface< T >::neml2NumThreads().
|
private |
The device on which to store the outputs.
Definition at line 136 of file NEML2ModelInterface.h.
Referenced by NEML2ModelInterface< T >::output_device().