Caffe2 - C++ API
A deep learning, cross platform ML framework
upsample_nearest_op.h
1 
17 #ifndef UPSAMPLE_NEAREST_OP_H_
18 #define UPSAMPLE_NEAREST_OP_H_
19 
20 #include "caffe2/core/context.h"
21 #include "caffe2/core/logging.h"
22 #include "caffe2/core/operator.h"
23 #include "caffe2/utils/math.h"
24 
25 namespace caffe2 {
26 
27 template <typename T, class Context>
28 class UpsampleNearestOp final : public Operator<Context> {
29  public:
30  UpsampleNearestOp(const OperatorDef& operator_def, Workspace* ws)
31  : Operator<Context>(operator_def, ws),
32  scale_(OperatorBase::GetSingleArgument<int>("scale", 2)) {
33  DCHECK_GE(scale_, 1);
34  }
35  USE_OPERATOR_CONTEXT_FUNCTIONS;
36 
37  bool RunOnDevice() override {
38  // No CPU implementation for now
39  CAFFE_NOT_IMPLEMENTED;
40  }
41 
42  protected:
43  int scale_;
44 };
45 
46 template <typename T, class Context>
47 class UpsampleNearestGradientOp final : public Operator<Context> {
48  public:
49  UpsampleNearestGradientOp(const OperatorDef& def, Workspace* ws)
50  : Operator<Context>(def, ws),
51  scale_(OperatorBase::GetSingleArgument<int>("scale", 2)) {
52  DCHECK_GE(scale_, 1);
53  }
54  USE_OPERATOR_CONTEXT_FUNCTIONS;
55 
56  bool RunOnDevice() override {
57  // No CPU implementation for now
58  CAFFE_NOT_IMPLEMENTED;
59  }
60 
61  protected:
62  int scale_;
63 };
64 
65 } // namespace caffe2
66 
67 #endif // UPSAMPLE_NEAREST_OP_H_
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 ...