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

Function shape_to_valid_region

tests/Utils.h:220–245  ·  view source on GitHub ↗

Create a valid region based on tensor shape, border mode and border size * * @param[in] a_shape Shape used as size of the valid region. * @param[in] border_undefined (Optional) Boolean indicating if the border mode is undefined. * @param[in] border_size (Optional) Border size used to specify the region to exclude. * * @return A valid region starting at (0, 0, ...) with size of

Source from the content-addressed store, hash-verified

218 * return A valid region starting at (@p border_size.left, @p border_size.top, ...) with reduced size of @p shape.
219 */
220inline ValidRegion
221shape_to_valid_region(const TensorShape &a_shape, bool border_undefined = false, BorderSize border_size = BorderSize(0))
222{
223 ValidRegion valid_region{Coordinates(), a_shape};
224
225 Coordinates &anchor = valid_region.anchor;
226 TensorShape &shape = valid_region.shape;
227
228 if (border_undefined)
229 {
230 ARM_COMPUTE_ERROR_ON(shape.num_dimensions() < 2);
231
232 anchor.set(0, border_size.left);
233 anchor.set(1, border_size.top);
234
235 const int valid_shape_x = std::max(0, static_cast<int>(shape.x()) - static_cast<int>(border_size.left) -
236 static_cast<int>(border_size.right));
237 const int valid_shape_y = std::max(0, static_cast<int>(shape.y()) - static_cast<int>(border_size.top) -
238 static_cast<int>(border_size.bottom));
239
240 shape.set(0, valid_shape_x);
241 shape.set(1, valid_shape_y);
242 }
243
244 return valid_region;
245}
246
247/** Write the value after casting the pointer according to @p data_type.
248 *

Callers 3

validateFunction · 0.85
validate_wrapFunction · 0.85
non_maxima_suppressionFunction · 0.85

Calls 6

BorderSizeClass · 0.85
CoordinatesClass · 0.50
num_dimensionsMethod · 0.45
setMethod · 0.45
xMethod · 0.45
yMethod · 0.45

Tested by

no test coverage detected