Caffe2 - C++ API
A deep learning, cross platform ML framework
free_op.h
1 #ifndef CAFFE2_OPERATORS_FREE_OP_H_
2 #define CAFFE2_OPERATORS_FREE_OP_H_
3 
4 #include "caffe2/core/context.h"
5 #include "caffe2/core/operator.h"
6 
7 namespace caffe2 {
8 
9 // FreeOp frees the content of the output blob. We allow it to take in input
10 // blobs purely for the reason that it can "wait" on the input blobs to be
11 // produced by some of the earlier operators before a free is called.
12 template <class Context>
13 class FreeOp : public Operator<Context> {
14  public:
15  template <class... Args>
16  explicit FreeOp(Args&&... args)
17  : Operator<Context>(std::forward<Args>(args)...) {}
18 
19  bool RunOnDevice() override {
20  for (Blob* output : OperatorBase::Outputs()) {
21  output->Reset();
22  }
23  return true;
24  }
25 };
26 
27 } // namespace caffe2
28 
29 #endif // CAFFE2_OPERATORS_FREE_OP_H_
Blob is a general container that hosts a typed pointer.
Definition: blob.h:24
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13