Skip to navigation

holoscan::calc_strides

Beta
View as MarkdownOpen in Claude
HOLOSCAN_CORE_EXPORT void holoscan::calc_strides(
const DLTensor &tensor,
std::vector<int64_t> &strides,
bool to_num_elements = false
)

Fill strides from the given DLTensor object.

The following fields are used to fill strides:

  • ndim
  • shape
  • dtype

If tensor’s strides is nullptr, strides argument is filled with the calculated strides of the given DLTensor object. Otherwise, strides argument is filled with the given DLTensor object’s strides. strides is resized to ndim, or cleared (left empty) when ndim <= 0 or when implicit strides are requested but the shape pointer is null. Byte strides use the full element size, accounting for vectorized (multi-lane) dtypes.

Parameters

tensor
const DLTensor &

DLTensor object that holds information to fill strides.

strides
std::vector<int64_t> &

[out] Strides to fill.

to_num_elements
boolDefaults to false

If true, the strides in strides argument are in number of elements, not bytes (default: false).