SMAUG
Simulating Machine Learning Applications on gem5-Aladdin
eltwise_op.h
1 #ifndef _OPERATORS_ELTWISEOP_OPS_H_
2 #define _OPERATORS_ELTWISEOP_OPS_H_
3 
4 #include "smaug/core/backend.h"
5 #include "smaug/core/operator.h"
6 #include "smaug/core/workspace.h"
7 
8 namespace smaug {
9 
16 template <typename Backend>
17 class EltwiseOp : public Operator {
18  public:
19  EltwiseOp(const std::string& name, OpType opType, Workspace* workspace)
20  : Operator(name, opType, workspace) {
21  inputs.resize(kNumInputs, nullptr);
22  outputs.resize(kNumOutputs, nullptr);
23  }
24 
25  void createAllTensors() override {
26  Tensor* output = new Tensor(name, getInput(Input0)->getShape());
27  outputs.at(Outputs) = output;
28  workspace->addTensor(output);
29  }
30 
31  protected:
32  enum { Input0, Input1, kNumInputs };
33  enum { Outputs, kNumOutputs };
34 };
35 
36 } // namespace smaug
37 
38 #endif
smaug::Tensor
Tensor represents a single multi-dimensional array of data.
Definition: tensor.h:344
smaug::Workspace
Workspace is the container and owner of all Tensors and Operators in the Network.
Definition: workspace.h:17
smaug::Operator::outputs
std::vector< TensorBase * > outputs
An ordered list of output tensors produced by this operator.
Definition: operator.h:141
smaug::Operator
Operator is the base class for all graph operators supported by SMAUG.
Definition: operator.h:28
smaug
The smaug namespace is the parent namespace of all C++ code in SMAUG.
Definition: backend.cpp:38
smaug::Operator::inputs
std::vector< TensorBase * > inputs
An ordered list of input tensors consumed by this operator.
Definition: operator.h:134
smaug::EltwiseOp::createAllTensors
void createAllTensors() override
For tests: creates all input and output tensors for this operator.
Definition: eltwise_op.h:25
smaug::EltwiseOp
The base class of all elementwise operators.
Definition: eltwise_op.h:17