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

Function tensor_elem_at

tests/validation/reference/Utils.h:64–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62// Return a tensor element at a specified coordinate with different border modes
63template <typename T>
64T tensor_elem_at(const SimpleTensor<T> &src, Coordinates coord, BorderMode border_mode, T constant_border_value)
65{
66 const int x = coord.x();
67 const int y = coord.y();
68 const int z = coord.z();
69 const int width = src.shape().x();
70 const int height = src.shape().y();
71 const int depth = src.shape().z();
72
73 // If coordinates beyond range of tensor's width or height
74 if (x < 0 || y < 0 || z < 0 || x >= width || y >= height || z >= depth)
75 {
76 if (border_mode == BorderMode::REPLICATE)
77 {
78 coord.set(0, std::max(0, std::min(x, width - 1)));
79 coord.set(1, std::max(0, std::min(y, height - 1)));
80 }
81 else
82 {
83 return constant_border_value;
84 }
85 }
86
87 return src[coord2index(src.shape(), coord)];
88}
89
90#pragma GCC diagnostic pop
91

Callers 14

non_maxima_suppressionFunction · 0.85
scale_imageFunction · 0.85
erodeFunction · 0.85
im2col_nchwFunction · 0.85
im2col_nhwcFunction · 0.85
depthwise_convolution_fpFunction · 0.85
apply_2d_spatial_filterFunction · 0.85
rgb_to_yuv_calculationFunction · 0.85
yuyv_to_rgb_calculationFunction · 0.85
colorconvert_rgb_to_nv12Function · 0.85
colorconvert_rgb_to_iyuvFunction · 0.85
colorconvert_rgb_to_yuv4Function · 0.85

Calls 6

coord2indexFunction · 0.85
xMethod · 0.45
yMethod · 0.45
zMethod · 0.45
shapeMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected