NEML2 1.4.0
|
Interface for object which can store buffers. More...
Interface for object which can store buffers.
#include <BufferStore.h>
Public Member Functions | |
BufferStore (const OptionSet &options, NEML2Object *object) | |
const Storage< std::string, TensorValueBase > & | named_buffers () const |
Storage< std::string, TensorValueBase > & | named_buffers () |
template<typename T , typename = typename std::enable_if_t<std::is_base_of_v<TensorBase<T>, T>>> | |
TensorValue< T > & | get_buffer (const std::string &name) |
}@ | |
virtual void | send_buffers_to (const torch::TensorOptions &options) |
Send all buffers to options . | |
template<typename T , typename = typename std::enable_if_t<std::is_base_of_v<TensorBase<T>, T>>> | |
const T & | declare_buffer (const std::string &name, const T &rawval) |
Declare a buffer. | |
template<typename T , typename = typename std::enable_if_t<std::is_base_of_v<TensorBase<T>, T>>> | |
const T & | declare_buffer (const std::string &name, const std::string &input_option_name) |
Declare a buffer. | |
BufferStore | ( | const OptionSet & | options, |
NEML2Object * | object ) |
|
protected |
Declare a buffer.
Note that all buffers are stored in the host (the object exposed to users). An object may be used multiple times in the host, and the same buffer may be declared multiple times. That is allowed, but only the first call to declare_buffer constructs the buffer value, and subsequent calls only returns a reference to the existing buffer.
T | Buffer type. See Statically shaped tensors for supported types. |
name | Buffer name |
input_option_name | Name of the input option that defines the value of the model buffer. |
Declare a buffer.
Note that all buffers are stored in the host (the object exposed to users). An object may be used multiple times in the host, and the same buffer may be declared multiple times. That is allowed, but only the first call to declare_buffer constructs the buffer value, and subsequent calls only returns a reference to the existing buffer.
T | Buffer type. See Statically shaped tensors for supported types. |
name | Buffer name |
rawval | Buffer value |
TensorValue< T > & get_buffer | ( | const std::string & | name | ) |
}@
Get a writable reference of a buffer
Storage< std::string, TensorValueBase > & named_buffers | ( | ) |
|
inline |