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

Function coord2index

tests/Utils.h:392–407  ·  view source on GitHub ↗

Linearise the given coordinate. * * Transforms the given coordinate into a linear offset in terms of * elements. * * @param[in] shape Shape of the n-dimensional tensor. * @param[in] coord The to be converted coordinate. * * @return Linear offset to the element. */

Source from the content-addressed store, hash-verified

390 * @return Linear offset to the element.
391 */
392inline int coord2index(const TensorShape &shape, const Coordinates &coord)
393{
394 ARM_COMPUTE_ERROR_ON_MSG(shape.total_size() == 0, "Cannot get index from empty shape");
395 ARM_COMPUTE_ERROR_ON_MSG(coord.num_dimensions() == 0, "Cannot get index of empty coordinate");
396
397 int index = 0;
398 int dim_size = 1;
399
400 for (unsigned int i = 0; i < coord.num_dimensions(); ++i)
401 {
402 index += coord[i] * dim_size;
403 dim_size *= shape[i];
404 }
405
406 return index;
407}
408
409/** Check if a coordinate is within a valid region */
410inline bool is_in_valid_region(const ValidRegion &valid_region, Coordinates coord)

Callers 15

operator()Method · 0.85
operator()Method · 0.85
Utils.cppFile · 0.85
col2imFunction · 0.85
roi_align_1x1Function · 0.85
reverseFunction · 0.85
transposeFunction · 0.85
pad_layerFunction · 0.85
weights_reshapeFunction · 0.85
unrollMethod · 0.85
unrollMethod · 0.85

Calls 2

total_sizeMethod · 0.45
num_dimensionsMethod · 0.45

Tested by

no test coverage detected