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. */
| 390 | * @return Linear offset to the element. |
| 391 | */ |
| 392 | inline 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 */ |
| 410 | inline bool is_in_valid_region(const ValidRegion &valid_region, Coordinates coord) |
no test coverage detected