Updated on 2022-03-13 GMT+08:00

INFER_SHAPE_AND_TYPE

Function Prototype

INFER_SHAPE_AND_TYPE (x)

Function Description

Registers the Shape and DataType inference function.

Parameter Description

Parameter

Input/Output

Type

Description

x

Input

-

Macro parameter, Shape and DataType inference function

For example, INFER_SHAPE_AND_TYPE(FullConnectionInfer) is used to register the FullConnectionInfer function for inferring operator Shape and DataType.

FullConnectionInfer is declared in DECLARE_INFERFUNC and defined in IMPLEMT_INFERFUNC. For details, see Description of Macros DECLARE_INFERFUNC and IMPLEMT_INFERFUNC.

Return Value

None

Exception Handling

None

Restriction

None

Description of Macros DECLARE_INFERFUNC and IMPLEMT_INFERFUNC

Before registering the function for Shape and DataType inference, you need to declare the function in the DECLARE_INFERFUNC macro and define the function in the IMPLEMT_INFERFUNC macro.

  • Declaring the function
    DECLARE_INFERFUNC(FullConnection, FullConnectionInfer)

    The expanded implementation of the DECLARE_INFERFUNC macro is as follows:

    namespace op {
    class FullConnection;
    }
    static graphStatus FullConnectionInfer(op::FullConnection& op);
  • Defining the function
    IMPLEMT_INFERFUNC(FullConnection, FullConnectionInfer) {
    // Implementation details
    }

    The expanded implementation of the IMPLEMT_INFERFUNC macro is as follows:

    static graphStatus FullConnectionInfer(op::FullConnection& op){
    // Implementation details
    }