1 #include "caffe2/serialize/istream_adapter.h" 2 #include <c10/util/Exception.h> 7 IStreamAdapter::IStreamAdapter(std::istream* istream) : istream_(istream) {}
9 size_t IStreamAdapter::size()
const {
10 auto prev_pos = istream_->tellg();
11 validate(
"getting the current position");
12 istream_->seekg(0, istream_->end);
13 validate(
"seeking to end");
14 auto result = istream_->tellg();
15 validate(
"getting size");
16 istream_->seekg(prev_pos);
17 validate(
"seeking to the original position");
21 size_t IStreamAdapter::read(uint64_t pos,
void* buf,
size_t n,
const char* what)
25 istream_->read(static_cast<char*>(buf), n);
30 void IStreamAdapter::validate(
const char* what)
const {
32 AT_ERROR(
"istream reader failed: ", what,
".");
36 IStreamAdapter::~IStreamAdapter() {}
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...