GetOutputShapeRange

Function

Obtains the pointer to the output shape range corresponding to the operator output index. The output index here refers to the actual index after the operator is instantiated, not the index in the prototype definition.

Function Prototype

Range<Shape> *GetOutputShapeRange(const size_t index)

Parameters

ParameterInput/OutputDescription
indexInputOperator output index, counted from 0.

Return Value

Pointer to the output shape range. If the index is invalid, a null pointer is returned.

Constraints

None

Example

ge::graphStatus InferShapeRangeForXXX(gert::InferShapeRangeContext *context) {
  const auto x_shape_range = context->GetInputShapeRange(0);
  if (x_shape_range == nullptr) {
    // Defensive programming ....
  }
  const auto min_shape = x_shape_range->GetMin();
  const auto max_shape = x_shape_range->GetMax();

  auto y_shape_range = context->GetOutputShapeRange(0);
  if (y_shape_range == nullptr) {
    // Defensive programming ....
  }
  if (y_shape_range->GetMin() == nullptr || y_shape_range->GetMax() == nullptr) {
    // Defensive programming ....
  }
  // shape range inference logic .....
}