MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / index2coord

Function index2coord

tests/Utils.h:363–380  ·  view source on GitHub ↗

Convert a linear index into n-dimensional coordinates. * * @param[in] shape Shape of the n-dimensional tensor. * @param[in] index Linear index specifying the i-th element. * * @return n-dimensional coordinates. */

Source from the content-addressed store, hash-verified

361 * @return n-dimensional coordinates.
362 */
363inline Coordinates index2coord(const TensorShape &shape, int index)
364{
365 int num_elements = shape.total_size();
366
367 ARM_COMPUTE_ERROR_ON_MSG(index < 0 || index >= num_elements, "Index has to be in [0, num_elements]");
368 ARM_COMPUTE_ERROR_ON_MSG(num_elements == 0, "Cannot create coordinate from empty shape");
369
370 Coordinates coord{0};
371
372 for (int d = shape.num_dimensions() - 1; d >= 0; --d)
373 {
374 num_elements /= shape[d];
375 coord.set(d, index / num_elements);
376 index %= num_elements;
377 }
378
379 return coord;
380}
381
382/** Linearise the given coordinate.
383 *

Callers 15

fill_boxesMethod · 0.85
fill_with_generatorMethod · 0.85
fillMethod · 0.85
validateFunction · 0.85
validateFunction · 0.85
validate_wrapFunction · 0.85
Utils.cppFile · 0.85
permuteFunction · 0.85
reverseFunction · 0.85
transposeFunction · 0.85
pad_layerFunction · 0.85
quantization_layerFunction · 0.85

Calls 3

total_sizeMethod · 0.45
num_dimensionsMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected