ToContiguousStrides

Function Usage

Derives stride information from the existing shape according to contiguous strides. For example, if the shape is [10, 20, 30], the derived stride is [600, 30, 1].

Prototype

void ToContiguousStrides(const Shape &shape, FVector<int64_t, 25> &strides)

Parameters

Parameter

Input/Output

Description

shape

Input

Shape information, for example, a 3D shape: [10, 20, 30].

strides

Output

Stride information, for example, the stride for a 3D shape: [600, 30, 1].

Returns

None

Constraints

None

Example

1
2
3
4
5
6
7
8
9
// Generate a shape object whose shape is [1, 2, 3, 4, 5] and also generate its stride.
void Func() {
    gert::Shape newShape;
    for (int64_t i = 1; i <= 5; i++) {
        newShape.AppendDim(i);
    }
    FVector<int64_t, 25> strides;
    ToContiguousStrides(newShape, strides);
}