Dragon - C++ API
A Computation Graph Virtual Machine Based Deep Learning Framework
pow_op.h
Go to the documentation of this file.
1 
13 #ifndef DRAGON_OPERATORS_ARITHMETIC_POW_OP_H_
14 #define DRAGON_OPERATORS_ARITHMETIC_POW_OP_H_
15 
16 #include "core/operator.h"
17 
18 namespace dragon {
19 
20 template <class Context>
21 class PowOp final : public Operator<Context> {
22  public:
23  PowOp(const OperatorDef& def, Workspace* ws)
24  : Operator<Context>(def, ws),
25  scale_(OpArg<float>("scale", 1.f)),
26  shift_(OpArg<float>("shift", 0.f)),
27  power_(OpArg<float>("power", 1.f)) {
29  }
31 
32  void RunOnDevice() override;
33  template <typename T> void RunImpl();
34 
35  protected:
36  float scale_, shift_;
38 };
39 
40 template <class Context>
41 class PowGradientOp final : public Operator<Context> {
42  public:
43  PowGradientOp(const OperatorDef& def, Workspace* ws)
44  : Operator<Context>(def, ws),
45  scale_(OpArg<float>("scale", 1.f)),
46  shift_(OpArg<float>("shift", 0.f)),
47  power_(OpArg<float>("power", 1.f)) {
49  }
51 
52  void RunOnDevice() override;
53  template <typename T> void RunImpl();
54 
55  protected:
56  float scale_, shift_;
58 };
59 
60 } // namespace dragon
61 
62 #endif // DRAGON_OPERATORS_ARITHMETIC_POW_OP_H_
Definition: workspace.h:20
PowOp(const OperatorDef &def, Workspace *ws)
Definition: pow_op.h:23
float power_scale_
Definition: pow_op.h:57
const OperatorDef & def() const
Return the stored def.
Definition: operator.h:114
Workspace * ws() const
Return the parent workspace.
Definition: operator.h:87
USE_OPERATOR_FUNCTIONS
Definition: pow_op.h:30
Definition: pow_op.h:41
Definition: operator.h:149
#define OpArg
Definition: operator.h:235
USE_OPERATOR_FUNCTIONS
Definition: pow_op.h:50
float power_
Definition: pow_op.h:37
float scale_
Definition: pow_op.h:36
PowGradientOp(const OperatorDef &def, Workspace *ws)
Definition: pow_op.h:43
float power_
Definition: pow_op.h:57
float scale_
Definition: pow_op.h:56
void RunImpl()
Definition: pow_op.cc:8
float power_scale_
Definition: pow_op.h:37
float shift_
Definition: pow_op.h:36
void RunOnDevice() override
Implement the detailed execution.
Definition: pow_op.cc:80
Definition: pow_op.h:21
void RunImpl()
Definition: pow_op.cc:41
Definition: common.h:41
void RunOnDevice() override
Implement the detailed execution.
Definition: pow_op.cc:32
float shift_
Definition: pow_op.h:56