Caffe2 - C++ API
A deep learning, cross platform ML framework
create_db_op.h
1 #ifndef CAFFE2_DB_CREATE_DB_OP_H_
2 #define CAFFE2_DB_CREATE_DB_OP_H_
3 
4 #include "caffe2/core/context.h"
5 #include "caffe2/core/db.h"
6 #include "caffe2/core/operator.h"
7 
8 namespace caffe2 {
9 
10 template <class Context>
11 class CreateDBOp final : public Operator<Context> {
12  public:
13  CreateDBOp(const OperatorDef& operator_def, Workspace* ws)
14  : Operator<Context>(operator_def, ws),
15  db_type_(OperatorBase::template GetSingleArgument<string>(
16  "db_type",
17  "leveldb")),
18  db_name_(OperatorBase::template GetSingleArgument<string>("db", "")),
19  num_shards_(
20  OperatorBase::template GetSingleArgument<int>("num_shards", 1)),
21  shard_id_(
22  OperatorBase::template GetSingleArgument<int>("shard_id", 0)) {
23  CAFFE_ENFORCE_GT(db_name_.size(), 0, "Must specify a db name.");
24  }
25 
26  bool RunOnDevice() final {
27  OperatorBase::Output<db::DBReader>(0)->Open(
28  db_type_, db_name_, num_shards_, shard_id_);
29  return true;
30  }
31 
32  private:
33  string db_type_;
34  string db_name_;
35  uint32_t num_shards_;
36  uint32_t shard_id_;
37  C10_DISABLE_COPY_AND_ASSIGN(CreateDBOp);
38 };
39 
40 } // namespace caffe2
41 
42 #endif // CAFFE2_DB_CREATE_DB_OP_H_
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
Definition: workspace.h:47
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13