目录

GetOptionalInputDesc

Function Description

Obtains the description of an optional input tensor based on the input index in the operator prototype definition.

Function Prototype

const CompileTimeTensorDesc *GetOptionalInputDesc(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 TensorDesc. If the input index is invalid or the input is not instantiated, a null pointer is returned.

For details about the definition of CompileTimeTensorDesc, see CompileTimeTensorDesc.

Restrictions

None

Calling Example

// Assume that **KernelContext *context** already exists.
auto extend_context = reinterpret_cast<ExtendedKernelContext *>(context);
// Case 1: Assume that input 0 of the IR prototype of an operator is optional and there is actually one input.
auto optional_input_td = extend_context->GetOptionalInputDesc(0); // Obtain the tensor description of optional input 0.
// Case 2: Assume that input 0 of the IR prototype of an operator is optional and there is actually no input.
auto optional_input_td = extend_context->GetOptionalInputDesc(0); // nullptr