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

Function CalculateTFStrides

tensorflow/core/util/mkl_util.h:1181–1190  ·  view source on GitHub ↗

Function to calculate strides given tensor shape in Tensorflow order E.g., if dims_tf_order is {1, 2, 3, 4}, then as per Tensorflow convention, dimension with size 1 is outermost dimension; while dimension with size 4 is innermost dimension. So strides for this tensor would be {4 * 3 * 2, 4 * 3, 4, 1}, i.e., {24, 12, 4, 1}. @input Tensorflow shape in memory::dims type @return memory::dims contain

Source from the content-addressed store, hash-verified

1179/// @input Tensorflow shape in memory::dims type
1180/// @return memory::dims containing strides for the tensor.
1181inline memory::dims CalculateTFStrides(const memory::dims& dims_tf_order) {
1182 CHECK_GT(dims_tf_order.size(), 0);
1183 memory::dims strides(dims_tf_order.size());
1184 int last_dim_idx = dims_tf_order.size() - 1;
1185 strides[last_dim_idx] = 1;
1186 for (int d = last_dim_idx - 1; d >= 0; d--) {
1187 strides[d] = strides[d + 1] * dims_tf_order[d + 1];
1188 }
1189 return strides;
1190}
1191
1192/// Helper function to create memory descriptor in Blocked format
1193///

Callers 9

ComputeMethod · 0.85
ComputeMethod · 0.85
ComputeMethod · 0.85
MKLTransposeNDFunction · 0.85
ComputeMethod · 0.85
CreateMatMulParamsMethod · 0.85
ComputeMklSliceMethod · 0.85
ComputeMethod · 0.85
GetTfLayoutMethod · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected