> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/holoscan/sdk-user-guide/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/holoscan/sdk-user-guide/_mcp/server.

# holoscan::calc_strides

> Fill strides from the given DLTensor object.

```cpp showLineNumbers={false}
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` vector would be resized to the size of `ndim` field of the given DLTensor object.

**Parameters**

**`tensor`** `const DLTensor &`

DLTensor object that holds information to fill strides.

---

**`strides`** `std::vector<int64_t> &`

Strides to fill.

---

**`to_num_elements`** `bool` — default: false

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

---