SetUnknownRank

Description

In graph mode, when the rank of the input tensor shape is unknown, the rank of the output tensor shape must be set to unknown by using this API.

Prototype

void SetUnknownRank(gert::Shape &shape)

Parameters

Parameter

Input/Output

Description

shape

Output

Shape of the output tensor.

Return Value

None.

Constraints

None.

Example

The following sample code is for reference only. Do not copy and run it.

1
2
3
4
5
6
7
8
9
auto in_shape = context->GetInputShape(0);  // 0 indicates the first input parameter.
OP_CHECK_NULL_WITH_CONTEXT(context, in_shape);
auto out_shape = context->GetOutputShape(0);  // 0 indicates the first output parameter.
OP_CHECK_NULL_WITH_CONTEXT(context, out_shape);

// Check if the shape of the input tensor is of unknown rank. If yes, the shape of the output tensor is set to unknown rank.
if (Ops::Base::IsUnknownRank(*in_shape)) {
    Ops::Base::SetUnknownRank(*out_shape);
}