AutoMappingFnDynamic
Function Usage
The callback function that implements automatic mapping of the dynamic input/output operator.
Prototype
1 | Status AutoMappingFnDynamic(const google::protobuf::Message *op_src, ge::Operator &op, std::map<std::string, std::pair<std::string, std::string>> dynamic_name_attr_value, int32_t in_pos = -1, int32_t out_pos = -1) |
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 AI processor. |
dynamic_name_attr_value |
Input |
Actual number of dynamic inputs or outputs. key specifies whether they are inputs or outputs. The values of key are as follows:
|
in_pos |
Input |
Port ID for the dynamic input. |
out_pos |
Input |
Port ID for the dynamic output. |
Constraints
If the attributes of the original TensorFlow operator are inconsistent with those of operators supported by AI processor, the AutoMappingFnDynamic function cannot be used in the callback function ParseParamsByOperatorFn. In this case, use the AutoMappingByOpFnDynamic API in ParseParamsByOperatorFn to automatically parse the attributes that can be mapped. For usage examples, see Examples.
Sample Code
A code example of dynamic input is as follows.
1 2 3 4 5 6 7 8 9 10 11 12 13 | // register MapStage op to GE Status MapStageMapping(const google::protobuf::Message* op_src, ge::Operator& op) { map<string, pair<string, string>> value; value["in"] = pair<string, string>("values", "fake_dtypes"); AutoMappingFnDynamic(op_src, op, value); return SUCCESS; } REGISTER_CUSTOM_OP("MapStage") .FrameworkType(TENSORFLOW) .OriginOpType("MapStage") .ParseParamsFn(MapStageMapping) .ImplyType(ImplyType::AI_CPU); |
A code example of dynamic output is as follows.
1 2 3 4 5 6 7 8 9 10 11 12 | Status AutoMappingFnSplit(const google::protobuf::Message* op_src, ge::Operator& op) { map<string, pair<string, string>> value; value["out"] = pair<string, string>("y", "num_split"); AutoMappingFnDynamic(op_src, op, value); return SUCCESS; } REGISTER_CUSTOM_OP("Split") .FrameworkType(TENSORFLOW) .OriginOpType("Split") .ParseParamsFn(AutoMappingFnSplit) .ImplyType(ImplyType::TVM); |