AutoMappingByOpFn
Description
The callback function that implements automatic mapping.
Prototype
1
|
Status AutoMappingByOpFn(const ge::Operator &op_src, ge::Operator &op); |
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
op_src |
Input |
Operator in the original model before conversion, including the attributes of the operator in the original model. |
|
op |
Input |
Operator that adapts to Ascend AI Processor. |
Examples
The following describes the scenario where the attributes of the original TensorFlow operator are one-to-one mapped to those of the equivalent supported by Ascend AI Processor.
1 2 3 4 5 |
REGISTER_CUSTOM_OP("SoftplusGrad") .FrameworkType(TENSORFLOW) .OriginOpType("SoftplusGrad") .ParseParamsByOperatorFn(AutoMappingByOpFn) .ImplyType(ImplyType::TVM); |
The following describes the scenario where the attributes of the original TensorFlow operator cannot be mapped to those of the equivalent supported by Ascend AI Processor.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
Status ParseResizeArea(const ge::Operator &op_src, ge::Operator& op) { AutoMappingByOpFn(op_src, op); ge::TensorDesc input_tensor = op.GetInputDesc("images"); input_tensor.SetOriginFormat(ge::FORMAT_NHWC); input_tensor.SetFormat(ge::FORMAT_NHWC); auto ret = op.UpdateInputDesc("images", input_tensor); if(ret != ge::GRAPH_SUCCESS){ return FAILED; } ge::TensorDesc output_tensor = op.GetOutputDesc("y"); output_tensor.SetOriginFormat(ge::FORMAT_NHWC); output_tensor.SetFormat(ge::FORMAT_NHWC); auto ret_output = op.UpdateOutputDesc("y", output_tensor); if(ret_output != ge::GRAPH_SUCCESS){ return FAILED; } return SUCCESS; } // register ResizeArea op to GE REGISTER_CUSTOM_OP("ResizeArea") .FrameworkType(TENSORFLOW) .OriginOpType("ResizeArea") .ParseParamsByOperatorFn(ParseResizeArea) .ImplyType(ImplyType::AI_CPU); |
Parent topic: OpRegistrationData