Returns the index of the feature dimension. If format is NCHW_VECT_C, returns the index of the outer feature dimension (i.e. dimension 1, whose size would be num_features / 4 in this case).
| 190 | // the index of the outer feature dimension (i.e. dimension 1, whose size would |
| 191 | // be num_features / 4 in this case). |
| 192 | inline int GetTensorFeatureDimIndex(int num_dims, TensorFormat format) { |
| 193 | switch (format) { |
| 194 | case FORMAT_NHWC: |
| 195 | case FORMAT_HWNC: |
| 196 | return num_dims - 1; |
| 197 | case FORMAT_NHWC_VECT_W: |
| 198 | case FORMAT_HWCN: |
| 199 | return num_dims - 2; |
| 200 | case FORMAT_NCHW: |
| 201 | case FORMAT_NCHW_VECT_C: |
| 202 | return 1; |
| 203 | default: |
| 204 | LOG(FATAL) << "Unknown format " << format; |
| 205 | return -1; // Avoid compiler warning about missing return value |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | // Returns the index of the inner feature dimension. |
| 210 | inline int GetTensorInnerFeatureDimIndex(int num_dims, TensorFormat format) { |
no outgoing calls