SMAUG
Simulating Machine Learning Applications on gem5-Aladdin
elu_op.h
1 #ifndef _OPERATORS_ELU_OP_H_
2 #define _OPERATORS_ELU_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 
19 template <typename Backend>
20 class EluOp : public UnaryOp<Backend> {
21  public:
22  EluOp(const std::string& name, Workspace* workspace, float _alpha = 0.1)
23  : UnaryOp<Backend>(name, OpType::ELU, workspace), alpha(_alpha) {}
24 
25  void run() override {}
26 
27  void setAlpha(float _alpha) { alpha = _alpha; }
28  float getAlpha() const { return alpha; }
29 
30  protected:
31  float alpha;
32 };
33 
42 template <typename Backend>
43 class SeluOp : public EluOp<Backend> {
44  public:
45  SeluOp(const std::string& name, Workspace* workspace)
46  : EluOp<Backend>(name, workspace, 1.6733), lambda(1.0507) {
47  this->opType = OpType::SELU;
48  }
49 
50  void run() override {}
51 
52  void setLambda(float _lambda) { lambda = _lambda; }
53  float getLambda() const { return lambda; }
54 
55  protected:
56  float lambda;
57 };
58 
59 REGISTER_SPECIAL_OP(EluOp, ReferenceBackend);
60 REGISTER_SPECIAL_OP(SeluOp, ReferenceBackend);
61 
62 } // namespace smaug
63 
64 #endif
smaug
The smaug namespace is the parent namespace of all C++ code in SMAUG.
Definition: backend.cpp:38