目录

GetOptionalInputTensor

Function Description

Obtains the pointer to an optional input tensor based on the input index in the operator prototype definition.

Function Prototype

const Tensor *GetOptionalInputTensor(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.

Return Value

Pointer to the input tensor of a specified ir_index. If the input ir_index is invalid or the input is not instantiated, 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.

Calling Example

ge::graphStatus Tiling4ReduceCommon(TilingContext* context) {
  auto in_shape = context->GetInputShape(0);
  GE_ASSERT_NOTNULL(in_shape);
  auto axes_tensor = context->GetOptionalInputTensor(1);
  // ...
}