GetDynamicInputShapeRange

Description

Obtains the pointer to a dynamic input shape range based on the input index in the operator prototype definition.

Prototype

const Range<Shape> *GetDynamicInputShapeRange(const size_t ir_index, const size_t relative_index) const

Parameters

Parameter

Input/Output

Description

ir_index

Input

Index of the dynamic input in the operator IR prototype definition, starting from 0.

relative_index

Input

Relative index after the input is instantiated. For example, if three inputs are instantiated for a DYNAMIC_INPUT, the value range of relative_index is [0, 2].

Returns

Pointer to the shape range. If ir_index or relative_index is invalid, a null pointer is returned.

Restrictions

None

Example

const auto infer_shape_range_func = [](gert::InferShapeRangeContext *context) -> graphStatus {
  auto input_shape_range = context->GetDynamicInputShapeRange(0U, 0U);
  auto output_shape_range = context->GetOutputShapeRange(0U);
  output_shape_range->SetMin(const_cast<gert::Shape *>(input_shape_range->GetMin()));
  output_shape_range->SetMax(const_cast<gert::Shape *>(input_shape_range->GetMax()));
  return GRAPH_SUCCESS;
};