MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / GetTensorSpatialDimIndex

Function GetTensorSpatialDimIndex

tensorflow/core/util/tensor_format.h:225–244  ·  view source on GitHub ↗

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).

Source from the content-addressed store, hash-verified

223// the index of the outer width dimension (i.e. dimension 2, whose size would
224// be width / 4 in this case).
225inline 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
246inline int GetFilterTensorSpatialDimIndex(int num_dims,
247 FilterTensorFormat format, int dim) {

Callers 15

matchAndRewriteMethod · 0.85
matchAndRewriteMethod · 0.85
matchAndRewriteMethod · 0.85
CheckConvAttrsFunction · 0.85
MakeXlaForwardConvOpFunction · 0.85
CompileImplMethod · 0.85
XlaTensorFormatFunction · 0.85
CompileMethod · 0.85
MakeShapeFromFormatFunction · 0.85
DimensionsFromShapeFunction · 0.85

Calls 2

GetTensorSpatialDimsFunction · 0.85
ToStringFunction · 0.70

Tested by 1

RunDimensionIndexesTestFunction · 0.68