Caffe2 - C++ API
A deep learning, cross platform ML framework
file_adapter.cc
1 #include "caffe2/serialize/file_adapter.h"
2 #include <c10/util/Exception.h>
3 #include "caffe2/core/common.h"
4 
5 namespace caffe2 {
6 namespace serialize {
7 
8 FileAdapter::FileAdapter(const std::string& file_name) {
9  file_stream_.open(file_name, std::ifstream::in | std::ifstream::binary);
10  if (!file_stream_) {
11  AT_ERROR("open file failed, file path: ", file_name);
12  }
13  istream_adapter_ = caffe2::make_unique<IStreamAdapter>(&file_stream_);
14 }
15 
16 size_t FileAdapter::size() const {
17  return istream_adapter_->size();
18 }
19 
20 size_t FileAdapter::read(uint64_t pos, void* buf, size_t n, const char* what)
21  const {
22  return istream_adapter_->read(pos, buf, n, what);
23 }
24 
25 FileAdapter::~FileAdapter() {}
26 
27 } // namespace serialize
28 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13