SMAUG
Simulating Machine Learning Applications on gem5-Aladdin
tanh_op.h
1 #ifndef _OPERATORS_TANH_OP_H_
2 #define _OPERATORS_TANH_OP_H_
3 
4 #include <string>
5 
6 #include "smaug/core/backend.h"
7 #include "smaug/operators/unary_op.h"
8 
9 namespace smaug {
10 
17 template <typename Backend>
18 class TanhOp : public UnaryOp<Backend> {
19  public:
20  TanhOp(const std::string& name, Workspace* workspace)
21  : UnaryOp<Backend>(name, OpType::Tanh, workspace) {}
22 
23  void run() override {}
24 };
25 
33 template <typename Backend>
34 class HardTanhOp : public UnaryOp<Backend> {
35  public:
36  HardTanhOp(const std::string& name,
37  Workspace* workspace,
38  float _min = -1,
39  float _max = 1)
40  : UnaryOp<Backend>(name, OpType::HardTanh, workspace), min(_min),
41  max(_max) {}
42 
43  void run() override {}
44 
45  void setMin(float _min) { min = _min; }
46  void setMax(float _max) { max = _max; }
47  float getMin() const { return min; }
48  float getMax() const { return max; }
49 
50  protected:
51  float min;
52  float max;
53 };
54 
55 REGISTER_SPECIAL_OP(TanhOp, ReferenceBackend);
56 REGISTER_SPECIAL_OP(HardTanhOp, ReferenceBackend);
57 
58 } // namespace smaug
59 
60 #endif
smaug
The smaug namespace is the parent namespace of all C++ code in SMAUG.
Definition: backend.cpp:38