SMAUG
Simulating Machine Learning Applications on gem5-Aladdin
smv_tiling_common.cpp
1 #include "smaug/operators/smv/smv_tiling_common.h"
3 
4 namespace smaug {
5 namespace smv {
6 
7 std::ostream& operator<<(std::ostream& os, const TilingDims& dims) {
8  switch (dims) {
9  case None:
10  os << "None";
11  break;
12  case DimN:
13  os << "DimN";
14  break;
15  case DimNC:
16  os << "DimNC";
17  break;
18  case DimNH:
19  os << "DimNH";
20  break;
21  case DimNW:
22  os << "DimNW";
23  break;
24  case DimNHW:
25  os << "DimNHW";
26  break;
27  case DimNCH:
28  os << "DimNCH";
29  break;
30  case DimNCW:
31  os << "DimNCW";
32  break;
33  case Invalid:
34  os << "Invalid";
35  break;
36  }
37  return os;
38 }
39 
40 std::ostream& operator<<(std::ostream& os, const TilingConfig& config) {
41  os << "inputs: " << config.inputs;
42  if (config.weights.ndims() != 0)
43  os << ", weights: " << config.weights;
44  os << ", outputs: " << config.outputs;
45  return os;
46 }
47 
48 // N means batch for inputs/outputs, whereas this can mean ofmap for convolution
49 // weights, or neuron for inner product weights.
50 bool needsNwiseTiling(TilingDims dim) {
51  assert(dim != Invalid);
52  return (dim != None);
53 }
54 
55 // C means channel for convolution and activations for inner product.
56 bool needsCwiseTiling(TilingDims dim) {
57  return (dim == DimNC) || (dim == DimNCH) || (dim == DimNCW);
58 }
59 
60 // H means row for convolution.
61 bool needsHwiseTiling(TilingDims dim) {
62  return (dim == DimNH) || (dim == DimNHW) || (dim == DimNCH);
63 }
64 
65 // W means column for convolution.
66 bool needsWwiseTiling(TilingDims dim) {
67  return (dim == DimNW) || (dim == DimNHW) || (dim == DimNCW);
68 }
69 
70 } // namespace smv
71 } // namespace smaug
smaug::smv::TilingDims
TilingDims
The set of supported tiling strategies.
Definition: smv_tiling_common.h:13
tensor_utils.h
Utility functions for copying/printing/tiling tensors.
smaug
The smaug namespace is the parent namespace of all C++ code in SMAUG.
Definition: backend.cpp:38