GetOptionalInputTensorRange
Function Usage
Obtains the pointer to an optional input tensor range based on the input index in the operator prototype definition.
Prototype
1 | const TensorRange *GetOptionalInputTensorRange(const size_t ir_index) const |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
ir_index |
Input |
Input index in the operator IR prototype definition, starting from 0. |
Returns
Pointer to the TensorRange type. The definition is as follows:
1 | using TensorRange = Range<Tensor>; |
If ir_index is invalid or the input is not instantiated, a null pointer is returned.
Constraints
If the input is not set to data dependency, when this API is called to obtain a tensor range, only the correct shape, format, and datatype information can be obtained from the tensor, and the actual tensor data address (the obtained address is nullptr) cannot be obtained.
Examples
1 2 3 4 5 6 7 | const auto infer_shape_range_func = [](gert::InferShapeRangeContext *context) -> graphStatus { auto input_shape_range = context->GetOptionalInputTensorRange(0U); auto output_shape_range = context->GetOutputShapeRange(0U); *output_shape_range->GetMin() = input_shape_range->GetMin()->GetStorageShape(); *output_shape_range->GetMax() = input_shape_range->GetMax()->GetStorageShape(); return GRAPH_SUCCESS; }; |
Parent topic: InferShapeRangeContext