Dragon - C++ API
A Computation Graph Virtual Machine Based Deep Learning Framework
bilinear_resize_op.h
Go to the documentation of this file.
1 
13 #ifndef DRAGON_OPERATORS_VISION_BILINEAR_RESIZE_OP_H_
14 #define DRAGON_OPERATORS_VISION_BILINEAR_RESIZE_OP_H_
15 
16 #include "core/operator.h"
17 
18 namespace dragon {
19 
20 template <class Context>
21 class BilinearResizeOp final : public Operator<Context> {
22  public:
23  BilinearResizeOp(const OperatorDef& def, Workspace* ws)
24  : Operator<Context>(def, ws),
25  fy_(OpArg<float>("fy", -1.f)),
26  fx_(OpArg<float>("fx", -1.f)),
27  shape_desc_(OpArg<string>("shape_like", "")) {
28  if (data_format() == "NCHW") axis_ = 2;
29  else if (data_format() == "NHWC") axis_ = 1;
30  else LOG(FATAL) << "Unknown DataFormat: " << data_format();
31  GET_ARGS_WITH_DESC(int64_t, dsize);
32  }
34 
35  void RunOnDevice() override;
36  template <typename T> void RunImpl();
37 
38  protected:
39  float fy_, fx_;
40  string shape_desc_;
41  int64_t n_, c_, h_, w_;
42  int64_t out_h_, out_w_, axis_;
43  DECLARE_ARGS_WITH_DESC(int64_t, dsize);
44 };
45 
46 template <class Context>
48  final : public Operator<Context> {
49  public:
52 
53  void RunOnDevice() override;
54  template <typename T> void RunImpl();
55 
56  protected:
57  int64_t n_, c_, h_, w_;
58  int64_t out_h_, out_w_;
59 };
60 
62 
63 } // namespace dragon
64 
65 #endif // DRAGON_OPERATORS_VISION_BILINEAR_RESIZE_OP_H_
Definition: logging.h:21
void RunOnDevice() override
Implement the detailed execution.
Definition: bilinear_resize_op.cc:86
Definition: workspace.h:20
Definition: bilinear_resize_op.h:47
const string & data_format() const
Return the data format.
Definition: operator.h:79
void RunImpl()
Definition: bilinear_resize_op.cc:9
int64_t out_h_
Definition: bilinear_resize_op.h:58
const OperatorDef & def() const
Return the stored def.
Definition: operator.h:114
void RunImpl()
Definition: bilinear_resize_op.cc:57
Workspace * ws() const
Return the parent workspace.
Definition: operator.h:87
USE_OPERATOR_FUNCTIONS
Definition: bilinear_resize_op.h:51
float fy_
Definition: bilinear_resize_op.h:39
void RunOnDevice() override
Implement the detailed execution.
Definition: bilinear_resize_op.cc:31
int64_t w_
Definition: bilinear_resize_op.h:57
int64_t h_
Definition: bilinear_resize_op.h:57
int64_t c_
Definition: bilinear_resize_op.h:41
int64_t c_
Definition: bilinear_resize_op.h:57
int64_t out_h_
Definition: bilinear_resize_op.h:42
Definition: operator.h:149
#define OpArg
Definition: operator.h:235
int64_t out_w_
Definition: bilinear_resize_op.h:58
int64_t out_w_
Definition: bilinear_resize_op.h:42
string shape_desc_
Definition: bilinear_resize_op.h:40
int64_t w_
Definition: bilinear_resize_op.h:41
BilinearResizeOp(const OperatorDef &def, Workspace *ws)
Definition: bilinear_resize_op.h:23
int64_t n_
Definition: bilinear_resize_op.h:57
int64_t n_
Definition: bilinear_resize_op.h:41
int64_t h_
Definition: bilinear_resize_op.h:41
DEFINE_ARGS_WITH_DESC(int64_t, CropOp, starts)
#define LOG(severity)
Definition: logging.h:54
float fx_
Definition: bilinear_resize_op.h:39
#define GET_ARGS_WITH_DESC(type, arg)
Definition: operator.h:412
int64_t axis_
Definition: bilinear_resize_op.h:42
SIMPLE_CTOR_DTOR(BilinearResizeGradientOp)
USE_OPERATOR_FUNCTIONS
Definition: bilinear_resize_op.h:33
Definition: common.h:41
Definition: bilinear_resize_op.h:21
DECLARE_ARGS_WITH_DESC(int64_t, dsize)