GetInputTensor

Function Usage

Obtains the pointer to an input tensor based on the operator input index. The input index refers to the actual index after operator instantiation, not the index in the prototype definition.

Prototype

const Tensor *GetInputTensor(const size_t index) const

Parameters

Parameter

Input/Output

Description

index

Input

Operator input index, starting from 0.

Returns

Pointer to a specified input tensor. If the input index is invalid, a null pointer is returned.

For details about the definitions of tensor types (Tensor), see Tensor.

Constraints

The tensor data address can be obtained only when the input is set as a data dependency. If the input is not set as a data dependency, calling this API to get the tensor will only return metadata such as the correct shape, format, and data type, but the actual tensor data address cannot be obtained (the returned address is nullptr). For details about how to set data dependency, see the Ascend C Operator Development.

Examples

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