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

Function expand_coordinates

tests/validation/reference/Unstack.cpp:38–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36namespace
37{
38inline Coordinates expand_coordinates(Coordinates in_coord, size_t axis, size_t slice, size_t num_dimensions)
39{
40 /*
41 Reconstruct input_coord to read the corresponding value from the correct slice. This is done by adding an extra dimension
42 to the coordinates and shuffling around the values based on the info below.
43
44 For example, if input tensor shape is (X, Y, Z, W);
45
46 If axis == 0, each slice will have the shape (Y, Z, W) and there will be X slices
47
48 If axis == 1, each slice will have the shape (X, Z, W) and there will be Y slices.
49 */
50 Coordinates expanded_coord;
51 expanded_coord.set_num_dimensions(num_dimensions);
52 expanded_coord.set(axis, slice);
53 for (size_t k = 0; k < axis; ++k)
54 {
55 expanded_coord.set(k, in_coord[k]);
56 }
57 for (size_t k = axis + 1; k < num_dimensions; ++k)
58 {
59 expanded_coord.set(k, in_coord[k - 1]);
60 }
61 return expanded_coord;
62}
63
64template <typename T>
65SimpleTensor<T> get_slice(const SimpleTensor<T> &input_tensor, size_t axis, size_t slice)

Callers 1

get_sliceFunction · 0.85

Calls 2

set_num_dimensionsMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected