The callback function that implements automatic mapping of the dynamic input/output operator.
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)
| 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 adapted to the 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: operator input. - out: operator output. |
| in_pos | Input | Port ID for the dynamic input. |
| out_pos | Output | Port ID for the dynamic output. |
If the attributes of the original TensorFlow operator cannot be one-to-one mapped to those of the operator adapted to the AI processor, the AutoMappingFnDynamic function cannot be applied to the callback function ParseParamsByOperatorFn. In this case, use the AutoMappingByOpFnDynamic API in the callback function to automatically resolve the attributes that can be successfully mapped. For details about the usage example, see Calling Example.
A code example of dynamic input is as follows.
// Register the MapStage operation with 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.
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);