Returns the number of spatial dims of a tensor of rank 'num_dims' and tensor format 'format'.
| 113 | // Returns the number of spatial dims of a tensor of rank 'num_dims' and tensor |
| 114 | // format 'format'. |
| 115 | inline int GetTensorSpatialDims(int num_dims, TensorFormat format) { |
| 116 | switch (format) { |
| 117 | case FORMAT_NHWC: |
| 118 | case FORMAT_NCHW: |
| 119 | case FORMAT_HWNC: |
| 120 | case FORMAT_HWCN: |
| 121 | return num_dims - 2; // Exclude N,C. |
| 122 | case FORMAT_NCHW_VECT_C: |
| 123 | case FORMAT_NHWC_VECT_W: |
| 124 | // Note: the VECT_W is not counted as an independent spatial dim here, |
| 125 | // since it just a component of the width dimension. |
| 126 | return num_dims - 3; // Exclude N,C,VectDim. |
| 127 | default: |
| 128 | LOG(FATAL) << "Unknown format " << format; |
| 129 | return -1; // Avoid compiler warning about missing return value |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | inline int GetFilterTensorSpatialDims(int num_dims, FilterTensorFormat format) { |
| 134 | if (format == FORMAT_OIHW_VECT_I) { |
no outgoing calls
no test coverage detected