GetOutputShapeRange
Description
Obtains the pointer to an output shape range based on the operator output index. The output index refers to the actual index after operator instantiation, not the index in the prototype definition.
Prototype
Range<Shape> *GetOutputShapeRange(const size_t index)
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
index |
Input |
Operator output index, starting from 0. |
Returns
Pointer to the output shape range. If index is invalid, a null pointer is returned.
Restrictions
None
Example
ge::graphStatus InferShapeRangeForXXX(gert::InferShapeRangeContext *context) {
const auto x_shape_range = context->GetInputShapeRange(0);
if (x_shape_range == nullptr) {
// Defensive coding
}
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 coding
}
if (y_shape_range->GetMin() == nullptr || y_shape_range->GetMax() == nullptr) {
// Defensive coding
}
// Shape range inference logic
}
Parent topic: InferShapeRangeContext