通过本接口启用fallback配置,启用后将自动生成一个fallback函数并注册给GE。fallback函数的核心逻辑是将GE的输入、输出及属性转换为aclnn单算子API所需的参数格式,随后调用aclnn接口。动态图场景下,GE可直接调用fallback函数(函数中调用了aclnn接口),从而简化调度流程。
1 | OpDef &EnableFallBack(void) |
无
OpDef算子定义,OpDef请参考OpDef。
1 2 3 4 5 6 7 8 9 10 11 12 13 | class AddCustom : public OpDef { public: AddCustom(const char* name) : OpDef(name) { this->Input("x").ParamType(REQUIRED).DataType({ge::DT_FLOAT}).Format({ge::FORMAT_ND}); this->Input("y").ParamType(REQUIRED).DataType({ge::DT_FLOAT}).Format({ge::FORMAT_ND}); this->Output("z").ParamType(REQUIRED).DataType({ge::DT_FLOAT}).Format({ge::FORMAT_ND}) this->AICore().AddConfig("ascendxxx"); this->SetInferShape(ge::InferShapeFunc); this->SetInferDataType(ge::InferDataTypeFunc); this->EnableFallBack(); }; OP_ADD(AddCustom); |