GetDynamicInputTensor
Description
Obtains the pointer to a dynamic input tensor based on the input index in the operator prototype definition.
Prototype
const Tensor *GetDynamicInputTensor(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]. |
Returns
Pointer to a specified input tensor. If ir_index or relative_index is invalid, a null pointer is returned.
For details about the definition of the tensor type, see Tensor.
Restrictions
If the input is not set to data dependency, when this API is called to obtain a tensor, 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.
Example
ge::graphStatus Tiling4ReduceCommon(TilingContext* context) {
auto in_shape = context->GetInputShape(0);
GE_ASSERT_NOTNULL(in_shape);
auto axes_tensor_10 = context->GetDynamicInputTensor(1, 0);
auto axes_tensor_11 = context->GetDynamicInputTensor(1, 1);
...
}