strides_of

torch_sim.transforms.strides_of(v)[source]

Calculate the cumulative strides of a flattened tensor.

This function computes the cumulative sum of the input tensor v after flattening it. The resulting tensor contains the cumulative strides, which can be useful for indexing or iterating over elements in a flattened representation.

Parameters:

v (Tensor) – A tensor of any shape to be flattened and processed.

Returns:

A tensor of shape (n + 1,) where n is the number of elements in v, containing the cumulative strides.

Return type:

Tensor