目录

GetDynamicInputTensorRange

Function Description

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

Function Prototype

using TensorRange = Range<Tensor>
const TensorRange *GetDynamicInputTensorRange(const size_t ir_index, const size_t relative_index) const

Parameters

Parameter Input/Output Description
ir_index Input Input index 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].

Return Value

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

Restrictions

If the input is not set as a data dependency, when this API is called to obtain the tensor range, only the correct shape, format, and data type information can be obtained from the tensor. The actual tensor data address cannot be obtained (the obtained address is nullptr).

Calling Example

const auto infer_shape_range_func = [](gert::InferShapeRangeContext *context) -> graphStatus {
  auto input_shape_range = context->GetDynamicInputTensorRange(0U, 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;
};