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

Base class for all operators with one input. More...

#include <unary_op.h>

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

Detailed Description

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

Base class for all operators with one input.

Unary operators can produce multiple output Tensors.

Template Parameters
BackendThe Backend specialization of this Operator.

Definition at line 20 of file unary_op.h.

Public Types

enum  { Inputs, kNumInputs }
 
enum  { Outputs, kNumOutputs }
 

Public Member Functions

 UnaryOp (const std::string &name, OpType opType, Workspace *workspace)
 
bool validate () override
 Returns true if the parameters/tensors of this operator are all valid.
 
void createAllTensors () override
 For tests: creates all input and output tensors for this operator. More...
 
void createOutputTensors ()
 
- 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 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
 

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::UnaryOp< 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 30 of file unary_op.h.


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