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

Function GetTensorSpatialDims

tensorflow/core/util/tensor_format.h:115–131  ·  view source on GitHub ↗

Returns the number of spatial dims of a tensor of rank 'num_dims' and tensor format 'format'.

Source from the content-addressed store, hash-verified

113// Returns the number of spatial dims of a tensor of rank 'num_dims' and tensor
114// format 'format'.
115inline 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
133inline int GetFilterTensorSpatialDims(int num_dims, FilterTensorFormat format) {
134 if (format == FORMAT_OIHW_VECT_I) {

Callers 7

CompileImplMethod · 0.85
CompileMethod · 0.85
CompileMethod · 0.85
PoolParametersMethod · 0.85
GetTensorSpatialDimIndexFunction · 0.85
GetTensorDimIndexFunction · 0.85
ShapeFromFormatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected