NEML2 2.0.0
|
Interface for object which can store buffers. More...
Interface for object which can store buffers.
#include <BufferStore.h>
Public Member Functions | |
BufferStore (OptionSet options, NEML2Object *object) | |
BufferStore (const BufferStore &)=delete | |
BufferStore (BufferStore &&)=delete | |
BufferStore & | operator= (const BufferStore &)=delete |
BufferStore & | operator= (BufferStore &&)=delete |
virtual | ~BufferStore ()=default |
const Storage< std::string, TensorValueBase > & | named_buffers () const |
Storage< std::string, TensorValueBase > & | named_buffers () |
TensorValueBase & | get_buffer (const std::string &name) |
}@ | |
const TensorValueBase & | get_buffer (const std::string &name) const |
Get a read-only reference of a buffer. | |
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 CrossRef< T > &crossref) |
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 | ( | OptionSet | options, |
NEML2Object * | object ) |
|
delete |
|
delete |
|
virtualdefault |
Declare a buffer.
Similar to the previous method, but additionally handles the resolution of cross-referenced parameters.
T | Buffer type. See Statically shaped tensors for supported types. |
name | Buffer name. |
crossref | The cross-ref'ed "string" that defines the value of the buffer. |
|
protected |
Declare a buffer.
Similar to the previous methods, but this method takes care of the high-level logic to directly construct a buffer from the input option.
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 |
TensorValueBase & get_buffer | ( | const std::string & | name | ) |
}@
Get a writable reference of a buffer
const TensorValueBase & get_buffer | ( | const std::string & | name | ) | const |
Get a read-only reference of a buffer.
Storage< std::string, TensorValueBase > & named_buffers | ( | ) |
|
inline |
|
delete |
|
delete |