A recursive representation of tensors that can be deserialized from a file or stream. More...
#include <input-archive.h>
Public Member Functions | |
| InputArchive () | |
Default-constructs the InputArchive. | |
| InputArchive (InputArchive &&)=default | |
| InputArchive & | operator= (InputArchive &&)=default |
| InputArchive (InputArchive &)=delete | |
| InputArchive & | operator= (InputArchive &)=delete |
| void | read (const std::string &key, Tensor &tensor, bool is_buffer=false) |
Reads a tensor associated with a given key. More... | |
| void | read (const std::string &key, InputArchive &archive) |
Reads an InputArchive associated with a given key. More... | |
| void | load_from (const std::string &filename, c10::optional< torch::Device > device=c10::nullopt) |
Loads the InputArchive from a serialized representation stored in the file at filename. More... | |
| void | load_from (std::istream &stream, c10::optional< torch::Device > device=c10::nullopt) |
Loads the InputArchive from a serialized representation stored in the given stream. More... | |
| template<typename... Ts> | |
| void | operator() (Ts &&...ts) |
Forwards all arguments to read(). More... | |
A recursive representation of tensors that can be deserialized from a file or stream.
In most cases, users should not have to interact with this class, and should instead use torch::load.
Definition at line 32 of file input-archive.h.
| void torch::serialize::InputArchive::load_from | ( | const std::string & | filename, |
| c10::optional< torch::Device > | device = c10::nullopt |
||
| ) |
Loads the InputArchive from a serialized representation stored in the file at filename.
Storage are remapped using device option. If device is not specified, the module is loaded to the original device.
Definition at line 62 of file input-archive.cpp.
| void torch::serialize::InputArchive::load_from | ( | std::istream & | stream, |
| c10::optional< torch::Device > | device = c10::nullopt |
||
| ) |
Loads the InputArchive from a serialized representation stored in the given stream.
Storage are remapped using device option. If device is not specified, the module is loaded to the original device.
Definition at line 67 of file input-archive.cpp.
|
inline |
Forwards all arguments to read().
Useful for generic code that can be re-used for both InputArchive and OutputArchive (where operator() forwards to write()).
Definition at line 73 of file input-archive.h.
| void torch::serialize::InputArchive::read | ( | const std::string & | key, |
| Tensor & | tensor, | ||
| bool | is_buffer = false |
||
| ) |
Reads a tensor associated with a given key.
If the tensor is expected to be a buffer (not differentiable), is_buffer must be true.
Definition at line 22 of file input-archive.cpp.
| void torch::serialize::InputArchive::read | ( | const std::string & | key, |
| InputArchive & | archive | ||
| ) |
Reads an InputArchive associated with a given key.
The archive can thereafter be used for further deserialization of the nested data.
Definition at line 53 of file input-archive.cpp.
1.8.11