Dragon - C++ API
A Computation Graph Virtual Machine Based Deep Learning Framework
clip_op.h
Go to the documentation of this file.
1 
13 #ifndef DRAGON_OPERATORS_ARITHMETIC_CLIP_OP_H_
14 #define DRAGON_OPERATORS_ARITHMETIC_CLIP_OP_H_
15 
16 #include "core/operator.h"
17 
18 namespace dragon {
19 
20 template <class Context>
21 class ClipOp final : public Operator<Context> {
22  public:
23  ClipOp(const OperatorDef& def, Workspace* ws)
24  : Operator<Context>(def, ws),
25  low_(OpArg<float>("low", -FLT_MAX)),
26  high_(OpArg<float>("high", FLT_MAX)) {}
28 
29  void RunOnDevice() override;
30  template <typename T> void RunImpl();
31 
32  protected:
33  float low_, high_, lowT_, highT_;
34 };
35 
36 template <class Context>
37 class ClipGradientOp final : public Operator<Context> {
38  public:
39  ClipGradientOp(const OperatorDef& def, Workspace* ws)
40  : Operator<Context>(def, ws),
41  low_(OpArg<float>("low", -FLT_MAX)),
42  high_(OpArg<float>("high", FLT_MAX)) {}
44 
45  void RunOnDevice() override;
46  template <typename T> void RunImpl();
47 
48  protected:
49  float low_, high_, lowT_, highT_;
50 };
51 
52 } // namespace dragon
53 
54 #endif // DRAGON_OPERATORS_ARITHMETIC_CLIP_OP_H_
float highT_
Definition: clip_op.h:33
void RunOnDevice() override
Implement the detailed execution.
Definition: clip_op.cc:74
Definition: workspace.h:20
float lowT_
Definition: clip_op.h:49
float highT_
Definition: clip_op.h:49
const OperatorDef & def() const
Return the stored def.
Definition: operator.h:114
Workspace * ws() const
Return the parent workspace.
Definition: operator.h:87
Definition: operator.h:149
#define OpArg
Definition: operator.h:235
float high_
Definition: clip_op.h:49
Definition: clip_op.h:21
USE_OPERATOR_FUNCTIONS
Definition: clip_op.h:43
USE_OPERATOR_FUNCTIONS
Definition: clip_op.h:27
float high_
Definition: clip_op.h:33
ClipGradientOp(const OperatorDef &def, Workspace *ws)
Definition: clip_op.h:39
float low_
Definition: clip_op.h:33
void RunImpl()
Definition: clip_op.cc:42
ClipOp(const OperatorDef &def, Workspace *ws)
Definition: clip_op.h:23
Definition: clip_op.h:37
void RunImpl()
Definition: clip_op.cc:60
float lowT_
Definition: clip_op.h:33
Definition: common.h:41
float low_
Definition: clip_op.h:49
void RunOnDevice() override
Implement the detailed execution.
Definition: clip_op.cc:54