跳到主要内容

GetOutputShapeRange

函数功能

根据算子输出索引获取对应的输出shape range指针。这里的输出索引是指算子实例化后实际的索引,不是原型定义中的索引。

函数原型

Range<Shape> *GetOutputShapeRange(const size_t index);

参数说明

参数输入/输出说明
index输入算子输出索引,从0开始计数。

返回值

输出shape range指针,index非法时,返回空指针。

约束说明

调用示例

ge::graphStatus InferShapeRangeForXXX(gert::InferShapeRangeContext *context) {
const auto x_shape_range = context->GetInputShapeRange(0);
if (x_shape_range == nullptr) {
// 防御式编程 ....
}
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) {
// 防御式编程 ....
}
if (y_shape_range->GetMin() == nullptr || y_shape_range->GetMax() == nullptr) {
// 防御式编程 ....
}
// shape range推导逻辑 .....
}