https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
EagerModelHandle Class Reference

Handle wrapping the cpp-eager runtime (embeds CPython; loads from a source .i). More...

#include <NEML2ModelHandle.h>

Inheritance diagram for EagerModelHandle:
[legend]

Public Member Functions

 EagerModelHandle (const std::string &input_file, const std::string &model_name, const at::Device &device, const std::vector< std::string > &load)
 
const std::vector< std::string > & input_names () const override
 
const std::vector< std::string > & output_names () const override
 
const std::vector< std::vector< int64_t > > & input_base_shapes () const override
 
const std::vector< std::vector< int64_t > > & output_base_shapes () const override
 
const std::map< std::string, std::vector< int64_t > > & parameter_base_shapes () const override
 
std::pair< std::map< std::string, at::Tensor >, neml2::aoti::VariablePairJacobian > jacobian (const std::map< std::string, at::Tensor > &inputs) const override
 Evaluate the model and its full input Jacobian.
 
std::pair< std::map< std::string, at::Tensor >, neml2::aoti::VariablePairJacobian > param_jacobian (const std::map< std::string, at::Tensor > &inputs) const override
 Evaluate the model and its parameter Jacobian (d output / d parameter).
 
void set_parameter (const std::string &name, const at::Tensor &value) override
 Replace a (runtime-flexible) model parameter's value.
 
std::map< std::string, at::Tensor > value (const std::map< std::string, at::Tensor > &inputs) const override
 
at::Device device () const override
 The compute device this rank's workload runs on (for cpp-aoti, the scheduler-assigned device).
 

Private Attributes

neml2::eager::Model _m
 

Detailed Description

Handle wrapping the cpp-eager runtime (embeds CPython; loads from a source .i).

Single-device: the model is pinned to one device (cpp-eager has no scheduler / multi-device dispatch).

Definition at line 83 of file NEML2ModelHandle.h.

Constructor & Destructor Documentation

◆ EagerModelHandle()

EagerModelHandle::EagerModelHandle ( const std::string &  input_file,
const std::string &  model_name,
const at::Device &  device,
const std::vector< std::string > &  load 
)
inline

Definition at line 86 of file NEML2ModelHandle.h.

90 : _m(input_file, model_name, device, load)
91 {
92 }
at::Device device() const override
The compute device this rank's workload runs on (for cpp-aoti, the scheduler-assigned device).
neml2::eager::Model _m

Member Function Documentation

◆ device()

at::Device EagerModelHandle::device ( ) const
inlineoverridevirtual

The compute device this rank's workload runs on (for cpp-aoti, the scheduler-assigned device).

Implements NEML2ModelHandle.

Definition at line 128 of file NEML2ModelHandle.h.

128{ return _m.device(); }

◆ input_base_shapes()

const std::vector< std::vector< int64_t > > & EagerModelHandle::input_base_shapes ( ) const
inlineoverridevirtual

Implements NEML2ModelHandle.

Definition at line 96 of file NEML2ModelHandle.h.

97 {
98 return _m.input_base_shapes();
99 }

◆ input_names()

const std::vector< std::string > & EagerModelHandle::input_names ( ) const
inlineoverridevirtual

Implements NEML2ModelHandle.

Definition at line 94 of file NEML2ModelHandle.h.

94{ return _m.input_names(); }

◆ jacobian()

std::pair< std::map< std::string, at::Tensor >, neml2::aoti::VariablePairJacobian > EagerModelHandle::jacobian ( const std::map< std::string, at::Tensor > &  inputs) const
inlineoverridevirtual

Evaluate the model and its full input Jacobian.

Implements NEML2ModelHandle.

Definition at line 110 of file NEML2ModelHandle.h.

111 {
112 return _m.jacobian(inputs);
113 }

◆ output_base_shapes()

const std::vector< std::vector< int64_t > > & EagerModelHandle::output_base_shapes ( ) const
inlineoverridevirtual

Implements NEML2ModelHandle.

Definition at line 100 of file NEML2ModelHandle.h.

101 {
102 return _m.output_base_shapes();
103 }

◆ output_names()

const std::vector< std::string > & EagerModelHandle::output_names ( ) const
inlineoverridevirtual

Implements NEML2ModelHandle.

Definition at line 95 of file NEML2ModelHandle.h.

95{ return _m.output_names(); }

◆ param_jacobian()

std::pair< std::map< std::string, at::Tensor >, neml2::aoti::VariablePairJacobian > EagerModelHandle::param_jacobian ( const std::map< std::string, at::Tensor > &  inputs) const
inlineoverridevirtual

Evaluate the model and its parameter Jacobian (d output / d parameter).

Implements NEML2ModelHandle.

Definition at line 115 of file NEML2ModelHandle.h.

116 {
117 return _m.param_jacobian(inputs);
118 }

◆ parameter_base_shapes()

const std::map< std::string, std::vector< int64_t > > & EagerModelHandle::parameter_base_shapes ( ) const
inlineoverridevirtual

Implements NEML2ModelHandle.

Definition at line 104 of file NEML2ModelHandle.h.

105 {
106 return _m.parameter_base_shapes();
107 }

◆ set_parameter()

void EagerModelHandle::set_parameter ( const std::string &  name,
const at::Tensor &  value 
)
inlineoverridevirtual

Replace a (runtime-flexible) model parameter's value.

Implements NEML2ModelHandle.

Definition at line 119 of file NEML2ModelHandle.h.

120 {
121 _m.set_parameter(name, value);
122 }

◆ value()

std::map< std::string, at::Tensor > EagerModelHandle::value ( const std::map< std::string, at::Tensor > &  inputs) const
inlineoverridevirtual

Implements NEML2ModelHandle.

Definition at line 124 of file NEML2ModelHandle.h.

125 {
126 return _m.forward(inputs);
127 }

Member Data Documentation

◆ _m

neml2::eager::Model EagerModelHandle::_m
private

The documentation for this class was generated from the following file: