目录

operator[]

Function Description

Obtains the dimension value of a specified index axis.

Function Prototype

const int64_t &operator[](size_t idx) const
int64_t &operator[](size_t idx)

Parameters

Parameter Input/Output Description
idx Input Index of dim. You must ensure that the index is valid.

Return Value

Restrictions

You must ensure that the index is valid, that is, idx must be less than kMaxDimNum.

Calling Example

Shape shape0({3, 256, 256});
auto dim0 = shape0[0]; // The dimension size of axis 0 is 3.
auto dim1 = shape0[1]; // The dimension size of axis 1 is 256.
auto dim2 = shape0[2]; // The dimension size of axis 2 is 256.
auto invalid_dim = shape0[kMaxDimNum]; // The behavior is not defined.