Input

Function Usage

In some scenarios, an operator supports different prototype inputs on different AI processor models.

This API can register differentiated operator inputs for different AI processor models. After this API is called, an OpParamDef structure is returned. You can use this structure to configure operator inputs.

Prototype

OpParamDef &Input(const char *name);

Parameters

Parameter

Input/Output

Description

name

Input

Operator input name.

Returns

Operator parameter definition. For details about OpParamDef, see OpParamDef.

Constraints

None

Example

class AddCustom : public OpDef {
public:
    AddCustom(const char* name) : OpDef(name)
    {
        this->Input("x").DataType({ ge::DT_FLOAT16 }).ParamType(OPTIONAL);
        this->Output("y").DataType({ ge::DT_FLOAT16 });
        OpAICoreConfig aicConfig1;
        OpAICoreConfig aicConfig2;
        aicConfig1.Input("x")
            .ParamType(OPTIONAL)
            .DataType({ ge::DT_FLOAT })
            .Format({ ge::FORMAT_ND });
        aicConfig2.Input("x")
            .ParamType(REQUIRED)
            .DataType({ ge::DT_INT32 })
            .Format({ ge::FORMAT_ND });
        this->AICore().AddConfig("ascendxxx1", aicConfig1);
        this->AICore().AddConfig("ascendxxx2", aicConfig2);
    }
};