Caffe2 - C++ API
A deep learning, cross platform ML framework
conv_relu_op.h
1 #pragma once
2 
3 #include "caffe2/operators/conv_op.h"
4 #include "caffe2/operators/conv_pool_op_base.h"
5 
6 namespace caffe2 {
7 
8 template <typename T, class Context>
9 class ConvReluOp final : public ConvPoolOpBase<Context> {
10  public:
11  ConvReluOp(const OperatorDef& operator_def, Workspace* ws)
12  : ConvPoolOpBase<Context>(operator_def, ws) {
13  for (auto name : operator_def.input()) {
14  local_input_blobs_.push_back(local_ws_.CreateBlob(name));
15  CHECK_NOTNULL(local_input_blobs_.back());
16  }
17  local_op_.reset(new ConvOp<T, Context>(operator_def, &local_ws_));
18  for (auto name : operator_def.output()) {
19  local_output_blobs_.push_back(local_ws_.GetBlob(name));
20  CHECK_NOTNULL(local_output_blobs_.back());
21  }
22  }
23  ~ConvReluOp() {}
24 
25  bool RunOnDeviceWithOrderNCHW() override;
26  bool RunOnDeviceWithOrderNHWC() override;
27 
28  private:
29  Workspace local_ws_;
30  std::vector<Blob*> local_input_blobs_;
31  std::vector<Blob*> local_output_blobs_;
32  std::unique_ptr<ConvOp<T, Context>> local_op_;
33 }; // class ConvReluOp
34 
35 } // namespace caffe2
Blob * CreateBlob(const string &name)
Creates a blob of the given name.
Definition: workspace.cc:100
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
Definition: workspace.h:47
const Blob * GetBlob(const string &name) const
Gets the blob with the given name as a const pointer.
Definition: workspace.cc:160
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13