Caffe2 - C++ API
A deep learning, cross platform ML framework
redis_store_handler_op.h
1 #pragma once
2 
3 #include "redis_store_handler.h"
4 
5 #include <caffe2/core/operator.h>
6 
7 #include <string>
8 
9 namespace caffe2 {
10 
11 template <class Context>
12 class RedisStoreHandlerCreateOp final : public Operator<Context> {
13  public:
15  const OperatorDef& operator_def,
16  Workspace* ws)
17  : Operator<Context>(operator_def, ws),
18  host_(
19  OperatorBase::template GetSingleArgument<std::string>("host", "")),
20  port_(OperatorBase::template GetSingleArgument<int>("port", 0)),
21  prefix_(OperatorBase::template GetSingleArgument<std::string>(
22  "prefix",
23  "")) {
24  CAFFE_ENFORCE_NE(host_, "", "host is a required argument");
25  CAFFE_ENFORCE_NE(port_, 0, "port is a required argument");
26  }
27 
28  bool RunOnDevice() override {
29  auto ptr = std::unique_ptr<StoreHandler>(
30  new RedisStoreHandler(host_, port_, prefix_));
31  *OperatorBase::Output<std::unique_ptr<StoreHandler>>(HANDLER) =
32  std::move(ptr);
33  return true;
34  }
35 
36  private:
37  std::string host_;
38  int port_;
39  std::string prefix_;
40 
41  OUTPUT_TAGS(HANDLER);
42 };
43 
44 } // namespace caffe2
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