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
| 1179 | /// @input Tensorflow shape in memory::dims type |
| 1180 | /// @return memory::dims containing strides for the tensor. |
| 1181 | inline 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 | /// |
no test coverage detected