SMAUG
Simulating Machine Learning Applications on gem5-Aladdin
|
Operator is the base class for all graph operators supported by SMAUG. More...
#include <operator.h>
Operator is the base class for all graph operators supported by SMAUG.
Definition at line 28 of file operator.h.
Public Member Functions | |
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 void | createAllTensors () |
For tests: creates all input and output tensors for this 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 |
Workspace * | getWorkspace () |
Tensor * | getInput (int index) const |
const std::vector< TensorBase * > & | getInputs () const |
Tensor * | getOutput (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 Attributes | |
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. | |
Workspace * | workspace |
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. | |
|
inlinevirtual |
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 in smaug::PoolingOp< Backend >, smaug::PoolingOp< SmvBackend >, smaug::UnaryOp< Backend >, and smaug::EltwiseOp< Backend >.
Definition at line 70 of file operator.h.
|
inlinevirtual |
Return a list of Tensors whose values that are parameterizable.
Parameterizable Tensors often include "weights", but typically do not include outputs of other Tensors.
Definition at line 86 of file operator.h.
|
virtual |
Returns true if the Operator is dead.
By default, an Operator is dead if any input is dead, but operators can override this behavior if they are expected to operate on dead Tensors.
Definition at line 5 of file operator.cpp.
|
pure virtual |
Executes the Operator.
All Operator subclasses must override this method.
Implemented in smaug::SmvAvgPoolingOp, smaug::SmvMaxPoolingOp, and smaug::SmvPoolingOp.
|
inline |
Set the number of input tensors that this operator is waiting on.
When this value drops to zero, this operator is ready to be scheduled.
Definition at line 101 of file operator.h.
|
protected |
An ordered list of input tensors consumed by this operator.
Operators may assign semantic meaning to specific input tensors at specific positions in this array, e.g. index 0 is the input data Tensor and index 1 is the weight Tensor.
Definition at line 134 of file operator.h.
|
protected |
An ordered list of output tensors produced by this operator.
Like input tensors, operators can assign semantic meaning to tensors at specific positions here.
Definition at line 141 of file operator.h.