Returns the rank of a tensor with 'num_spatial_dims' spatial dimensions and tensor format 'format'. This is the inverse of GetTensorSpatialDims.
| 141 | // Returns the rank of a tensor with 'num_spatial_dims' spatial dimensions and |
| 142 | // tensor format 'format'. This is the inverse of GetTensorSpatialDims. |
| 143 | inline int GetTensorDimsFromSpatialDims(int num_spatial_dims, |
| 144 | TensorFormat format) { |
| 145 | switch (format) { |
| 146 | case FORMAT_NHWC: |
| 147 | case FORMAT_NCHW: |
| 148 | case FORMAT_HWNC: |
| 149 | case FORMAT_HWCN: |
| 150 | return num_spatial_dims + 2; // Include N,C. |
| 151 | case FORMAT_NCHW_VECT_C: |
| 152 | case FORMAT_NHWC_VECT_W: |
| 153 | return num_spatial_dims + 3; // Include N,C,VectDim. |
| 154 | default: |
| 155 | LOG(FATAL) << "Unknown format " << format; |
| 156 | return -1; // Avoid compiler warning about missing return value |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | // Returns the rank of a tensor with 'num_spatial_dims' spatial dimensions and |
| 161 | // filter tensor format 'format'. |
no outgoing calls