Caffe2 - C++ API
A deep learning, cross platform ML framework
redis_store_handler_op.h
1 
17 #pragma once
18 
19 #include "redis_store_handler.h"
20 
21 #include <caffe2/core/operator.h>
22 
23 #include <string>
24 
25 namespace caffe2 {
26 
27 template <class Context>
28 class RedisStoreHandlerCreateOp final : public Operator<Context> {
29  public:
31  const OperatorDef& operator_def,
32  Workspace* ws)
33  : Operator<Context>(operator_def, ws),
34  host_(
35  OperatorBase::template GetSingleArgument<std::string>("host", "")),
36  port_(OperatorBase::template GetSingleArgument<int>("port", 0)),
37  prefix_(OperatorBase::template GetSingleArgument<std::string>(
38  "prefix",
39  "")) {
40  CAFFE_ENFORCE_NE(host_, "", "host is a required argument");
41  CAFFE_ENFORCE_NE(port_, 0, "port is a required argument");
42  }
43 
44  bool RunOnDevice() override {
45  auto ptr = std::unique_ptr<StoreHandler>(
46  new RedisStoreHandler(host_, port_, prefix_));
47  *OperatorBase::Output<std::unique_ptr<StoreHandler>>(HANDLER) =
48  std::move(ptr);
49  return true;
50  }
51 
52  private:
53  std::string host_;
54  int port_;
55  std::string prefix_;
56 
57  OUTPUT_TAGS(HANDLER);
58 };
59 
60 } // namespace caffe2
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.