Dragon - C++ API
A Computation Graph Virtual Machine Based Deep Learning Framework
crop_op.h
Go to the documentation of this file.
1 
13 #ifndef DRAGON_OPERATORS_ARRAY_CROP_OP_H_
14 #define DRAGON_OPERATORS_ARRAY_CROP_OP_H_
15 
16 #include "core/operator.h"
17 
18 namespace dragon {
19 
20 template <class Context>
21 class CropOp final : public Operator<Context> {
22  public:
23  CropOp(const OperatorDef& def, Workspace* ws)
24  : Operator<Context>(def, ws),
25  ofs_(OpArgs<int64_t>("offsets")),
26  start_axis_(OpArg<int64_t>("start_axis", -1)),
27  shape_desc_(OpArg<string>("shape_like", "")) {
28  GET_ARGS_WITH_DESC(int64_t, starts);
29  GET_ARGS_WITH_DESC(int64_t, sizes);
30  }
32 
33  void Setup();
34  void RunOnDevice() override;
35  template <typename T> void RunImpl();
36 
37  protected:
38  string shape_desc_;
39  int64_t start_axis_;
42  DECLARE_ARGS_WITH_DESC(int64_t, starts);
43  DECLARE_ARGS_WITH_DESC(int64_t, sizes);
44 };
45 
46 template <class Context>
47 class CropGradientOp final : public Operator<Context> {
48  public:
51 
52  void RunOnDevice() override;
53  template <typename T> void RunImpl();
54 
55  protected:
58 };
59 
60 DEFINE_ARGS_WITH_DESC(int64_t, CropOp, starts);
61 DEFINE_ARGS_WITH_DESC(int64_t, CropOp, sizes);
62 
63 } // namespace dragon
64 
65 #endif // DRAGON_OPERATORS_ARRAY_CROP_OP_H_
string shape_desc_
Definition: crop_op.h:38
void RunOnDevice() override
Implement the detailed execution.
Definition: crop_op.cc:126
Definition: workspace.h:20
Tensor X_starts_
Definition: crop_op.h:57
Tensor Y_dims_
Definition: crop_op.h:57
Definition: crop_op.h:47
const OperatorDef & def() const
Return the stored def.
Definition: operator.h:114
Workspace * ws() const
Return the parent workspace.
Definition: operator.h:87
vec64_t ed_
Definition: crop_op.h:56
DECLARE_ARGS_WITH_DESC(int64_t, starts)
Tensor X_strides_
Definition: crop_op.h:57
Definition: tensor.h:21
Tensor X_strides_
Definition: crop_op.h:41
#define OpArgs
Definition: operator.h:236
Definition: operator.h:149
#define OpArg
Definition: operator.h:235
Tensor X_starts_
Definition: crop_op.h:41
std::vector< int64_t > vec64_t
Definition: types.h:25
vec64_t ofs_
Definition: crop_op.h:40
void Setup()
Definition: crop_op.cc:48
vec64_t ed_
Definition: crop_op.h:40
vec64_t keep_
Definition: crop_op.h:40
CropOp(const OperatorDef &def, Workspace *ws)
Definition: crop_op.h:23
USE_OPERATOR_FUNCTIONS
Definition: crop_op.h:50
vec64_t st_
Definition: crop_op.h:56
SIMPLE_CTOR_DTOR(CropGradientOp)
void RunImpl()
Definition: crop_op.cc:155
void RunOnDevice() override
Implement the detailed execution.
Definition: crop_op.cc:174
int64_t start_axis_
Definition: crop_op.h:39
vec64_t st_
Definition: crop_op.h:40
DEFINE_ARGS_WITH_DESC(int64_t, CropOp, starts)
USE_OPERATOR_FUNCTIONS
Definition: crop_op.h:31
Tensor Y_dims_
Definition: crop_op.h:41
#define GET_ARGS_WITH_DESC(type, arg)
Definition: operator.h:412
Definition: crop_op.h:21
Definition: common.h:41
void RunImpl()
Definition: crop_op.cc:32