Returns the dimension index of the specified 'spatial_dim' within an activation tensor. If format is NHWC_VECT_W and spatial_dim is 1, returns the index of the outer width dimension (i.e. dimension 2, whose size would be width / 4 in this case).
| 223 | // the index of the outer width dimension (i.e. dimension 2, whose size would |
| 224 | // be width / 4 in this case). |
| 225 | inline int GetTensorSpatialDimIndex(int num_dims, TensorFormat format, |
| 226 | int spatial_dim) { |
| 227 | CHECK(spatial_dim >= 0 && |
| 228 | spatial_dim < GetTensorSpatialDims(num_dims, format)) |
| 229 | << spatial_dim << " " << num_dims << " " << ToString(format); |
| 230 | switch (format) { |
| 231 | case FORMAT_NHWC: |
| 232 | case FORMAT_NHWC_VECT_W: |
| 233 | return spatial_dim + 1; |
| 234 | case FORMAT_NCHW: |
| 235 | case FORMAT_NCHW_VECT_C: |
| 236 | return spatial_dim + 2; |
| 237 | case FORMAT_HWNC: |
| 238 | case FORMAT_HWCN: |
| 239 | return spatial_dim; |
| 240 | default: |
| 241 | LOG(FATAL) << "Unknown format " << format; |
| 242 | return -1; // Avoid compiler warning about missing return value |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | inline int GetFilterTensorSpatialDimIndex(int num_dims, |
| 247 | FilterTensorFormat format, int dim) { |