SMAUG
Simulating Machine Learning Applications on gem5-Aladdin
|
1 #ifndef _CORE_BACKEND_H_
2 #define _CORE_BACKEND_H_
6 #include "smaug/core/datatypes.h"
7 #include "smaug/utility/utils.h"
31 #ifndef DOXYGEN_SHOULD_SKIP_THIS
34 template <
typename Backend>
class DataOp;
42 template <
typename Backend>
class SplitOp;
49 template <
typename Backend>
class LessOp;
54 template <
typename Backend>
class MergeOp;
55 template <
typename Backend>
class ReluOp;
57 template <
typename Backend>
class EluOp;
58 template <
typename Backend>
class SeluOp;
59 template <
typename Backend>
class TanhOp;
69 extern const unsigned kConvolutionHw;
70 extern const unsigned kInnerProductHw;
71 extern const unsigned kEltwiseOpHw;
72 extern const unsigned kBatchNormHw;
73 extern const unsigned kPoolingHw;
85 #define DECL_CREATE_OP(OpType) \
86 static smaug::OpType<ReferenceBackend>* create##OpType( \
87 const std::string& name, Workspace* workspace)
90 static const int Alignment = 0;
91 static const bool PrecomputeBNVariance =
true;
92 static const bool TransposeFCWeights =
false;
93 static const std::string Name;
94 static const DataLayout DefaultInputDataLayout = DataLayout::NCHW;
96 static int SpadSize() {
return 0; }
97 static void initGlobals() {}
98 static void freeGlobals() {}
124 DECL_CREATE_OP(
EluOp);
130 #undef DECL_CREATE_OP
137 extern int kSpadSize;
138 extern const unsigned kConvolutionHw;
139 extern const unsigned kInnerProductHw;
140 extern const unsigned kEltwiseOpHw;
141 extern const unsigned kBatchNormHw;
142 extern const unsigned kPoolingHw;
143 extern const unsigned kSystolicArrayHw;
151 #ifndef DOXYGEN_SHOULD_SKIP_THIS
152 class SmvConvolutionOp;
153 class SmvInnerProductOp;
154 class SmvMaxPoolingOp;
155 class SmvAvgPoolingOp;
156 class SmvBatchNormOp;
164 class SmvEltwiseAddOp;
165 class SmvEltwiseMulOp;
167 class SmvLessEqualOp;
169 class SmvGreaterEqualOp;
183 #define DECL_CREATE_OP(OpType) \
184 static smaug::OpType<SmvBackend>* create##OpType( \
185 const std::string& name, Workspace* workspace)
186 #define DECL_CREATE_SMV_OP(OpType) \
187 static smaug::Smv##OpType* create##OpType( \
188 const std::string& name, Workspace* workspace)
191 static const int Alignment = 8;
192 static const bool PrecomputeBNVariance =
true;
193 static const bool TransposeFCWeights =
true;
194 static const std::string Name;
195 static const DataLayout DefaultInputDataLayout = DataLayout::NHWC;
197 static int SpadSize() {
return smv::kSpadSize; }
198 static void initGlobals() {
200 smv::kSpadSize = 32 * 1024;
209 static void freeGlobals() {
220 DECL_CREATE_SMV_OP(
ReluOp);
221 DECL_CREATE_SMV_OP(
EluOp);
222 DECL_CREATE_SMV_OP(
SeluOp);
223 DECL_CREATE_SMV_OP(
TanhOp);
229 DECL_CREATE_SMV_OP(
LessOp);
246 #undef DECL_CREATE_OP
Replicates a Tensor's data among all dimensions.
Concatenates N Tensors along a specified axis.
BackendName
The list of all hardware backends in the system.
Adds two Tensors elementwise.
SmvBackend implements a set of models of optimized DL kernels that were taped out on a machine learni...
Implements an elementwise less-than-or-equal-to operator.
Implements the sigmoid operator, defined as 1/(1 + exp(-input)).
Implements the softmax operator.
void * malloc_aligned(size_t size, bool zeroOut)
Return heap-allocated cacheline-aligned memory.
Implements the scaled exponential linear unit function.
Implements the hard tanh operator, which bounds the min and max value of the tanh operator.
Implements the inner product operator.
Implements the tanh operator.
Implements the split operator, which divides a Tensor into N output Tensors along a specified dimensi...
Conditionally forwards an input to one of two outputs.
Implements an elementwise less-than operator.
@ Reference
Reference backend.
Implements the depthwise convolution operator.
ReferenceBackend provides reference implementations of all operators supported by SMAUG.
Implements the batch normalization layer.
Implements an elementwise greater than operator.
Implements the max-pooling operator.
Implements the exponential linear unit function.
Implements the rectified linear unit operator: max(slope * x, 0).
The smaug namespace is the parent namespace of all C++ code in SMAUG.
Implements the arithmetic-average-pooling operator.
Forwards the first live input to its output.
Exposes a Tensor as its only output.
Multiplies two Tensors elementwise.
Pad a given tensor in any number of dimensions with arbitrary size.
The base class for all 4D spatial convolution operators.
Implements an elementwise greater than or equal to operator.
Flattens each batch of a Tensor.
Implements a Tensor reordering operation to convert between different DataLayouts.
@ UnknownBackend
Invalid backend.
Changes the Tensor's shape while retaining the number of elements.