Caffe2 - C++ API
A deep learning, cross platform ML framework
create_db_op.h
1 
17 #ifndef CAFFE2_DB_CREATE_DB_OP_H_
18 #define CAFFE2_DB_CREATE_DB_OP_H_
19 
20 #include "caffe2/core/context.h"
21 #include "caffe2/core/db.h"
22 #include "caffe2/core/operator.h"
23 
24 namespace caffe2 {
25 
26 template <class Context>
27 class CreateDBOp final : public Operator<Context> {
28  public:
29  CreateDBOp(const OperatorDef& operator_def, Workspace* ws)
30  : Operator<Context>(operator_def, ws),
31  db_type_(OperatorBase::template GetSingleArgument<string>(
32  "db_type",
33  "leveldb")),
34  db_name_(OperatorBase::template GetSingleArgument<string>("db", "")),
35  num_shards_(
36  OperatorBase::template GetSingleArgument<int>("num_shards", 1)),
37  shard_id_(
38  OperatorBase::template GetSingleArgument<int>("shard_id", 0)) {
39  CAFFE_ENFORCE_GT(db_name_.size(), 0, "Must specify a db name.");
40  }
41 
42  bool RunOnDevice() final {
43  OperatorBase::Output<db::DBReader>(0)->Open(
44  db_type_, db_name_, num_shards_, shard_id_);
45  return true;
46  }
47 
48  private:
49  string db_type_;
50  string db_name_;
51  uint32_t num_shards_;
52  uint32_t shard_id_;
53  DISABLE_COPY_AND_ASSIGN(CreateDBOp);
54 };
55 
56 } // namespace caffe2
57 
58 #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:63
Copyright (c) 2016-present, Facebook, Inc.