SMAUG
Simulating Machine Learning Applications on gem5-Aladdin
Public Member Functions | Protected Types | List of all members
smaug::EltwiseOp< Backend > Class Template Reference

The base class of all elementwise operators. More...

#include <eltwise_op.h>

Inheritance diagram for smaug::EltwiseOp< Backend >:
smaug::Operator

Detailed Description

template<typename Backend>
class smaug::EltwiseOp< Backend >

The base class of all elementwise operators.

Template Parameters
BackendThe Backend specialization of this Operator.

Definition at line 17 of file eltwise_op.h.

Public Member Functions

 EltwiseOp (const std::string &name, OpType opType, Workspace *workspace)
 
void createAllTensors () override
 For tests: creates all input and output tensors for this operator. More...
 
- Public Member Functions inherited from smaug::Operator
 Operator (const std::string &_name, OpType _opType, Workspace *_workspace)
 
virtual void tile ()
 
virtual void run ()=0
 Executes the Operator. More...
 
virtual bool validate ()
 Returns true if the parameters/tensors of this operator are all valid.
 
virtual bool isDead ()
 Returns true if the Operator is dead. More...
 
virtual std::vector< TensorBase * > getParameterizableInputs ()
 Return a list of Tensors whose values that are parameterizable. More...
 
virtual int getNumParameters () const
 This returns the number of parameterizable weights in the operator.
 
virtual bool isSamplingSupported () const
 
virtual void setSamplingInfo (const SamplingInfo &sampling)
 
void printSummary (std::ostream &out) const
 
void setInput (TensorBase *op, int index)
 
void setOutput (TensorBase *op, int index)
 
void setNumPendingInputs (int num)
 Set the number of input tensors that this operator is waiting on. More...
 
int getNumPendingInputs () const
 
void decrNumPendingInputs ()
 
const std::string & getName () const
 
Vertex getVertex () const
 
void setVertex (Vertex v)
 
OpType getOpType () const
 
WorkspacegetWorkspace ()
 
TensorgetInput (int index) const
 
const std::vector< TensorBase * > & getInputs () const
 
TensorgetOutput (int index) const
 
const std::vector< TensorBase * > & getOutputs () const
 
void setInputsMemType (MemoryType type)
 
void setWeightsMemType (MemoryType type)
 
void setOutputsMemType (MemoryType type)
 
MemoryType getInputsMemType () const
 
MemoryType getWeightsMemType () const
 
MemoryType getOutputsMemType () const
 

Protected Types

enum  { Input0, Input1, kNumInputs }
 
enum  { Outputs, kNumOutputs }
 

Additional Inherited Members

- Protected Attributes inherited from smaug::Operator
std::vector< TensorBase * > inputs
 An ordered list of input tensors consumed by this operator. More...
 
std::vector< TensorBase * > outputs
 An ordered list of output tensors produced by this operator. More...
 
std::string name
 
OpType opType
 
Vertex vertex
 The BGL Vertex corresponding to this Operator.
 
Workspaceworkspace
 
int numPendingInputs
 The number of tensors that this operator is waiting on before it can be scheduled.
 
MemoryType inputsMemType
 The memory interface over which input activations are expected to arrive.
 
MemoryType weightsMemType
 The memory interface over which weights are expected to arrive.
 
MemoryType outputsMemType
 The memory interface over which outputs are expected to be delivered.
 

Member Function Documentation

◆ createAllTensors()

template<typename Backend >
void smaug::EltwiseOp< Backend >::createAllTensors ( )
inlineoverridevirtual

For tests: creates all input and output tensors for this operator.

When running a network, all tensor shapes are specified in the network topology proto, and the network builder will automatically create them for you. In unit tests, this is a convenience method to avoid needing to create TensorShape protos.

This should only be called once the Operator is fully initialized with all required parameters. It is responsible for creating only the tensors it "owns". All operators "own" their output tensors, but not necessarily all of their input tensors. For example, a convolution operator "owns" its weight tensors, but not the input activations (which are the output of a previous Operator).

Note that "ownership" of a Tensor does not mean the Operator holds a std::unique_ptr to the Tensor; it simply means it is solely responsible for constructing and allocating memory for it.

Reimplemented from smaug::Operator.

Definition at line 25 of file eltwise_op.h.


The documentation for this class was generated from the following file: