AutoMappingByOpFnDynamic
Function Usage
The callback function that implements automatic mapping of the dynamic input/output operator.
Prototype
1
|
Status AutoMappingByOpFnDynamic(const ge::Operator &op_src, ge::Operator &op, const std::vector<DynamicInputOutputInfo> &dynamic_name_attr_value) |
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. For details about the data structure of DynamicInputOutputInfo, see DynamicInputOutputInfo Data Struct. |
DynamicInputOutputInfo Data Struct
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
constexpr int64_t kMaxNameLength = 1048576; // 1M enum DynamicType : int16_t { kInvalid = 0, kInput = 1, kOutput = 2 }; struct DynamicInputOutputInfo { DynamicType type; // input/output const char_t *port_name; int64_t port_name_len; const char_t *attr_name; int64_t attr_name_len; DynamicInputOutputInfo(const DynamicType type_instance, const char_t *const port_name_instance, const int64_t port_name_len_instance, const char_t *const attr_name_instance, const int64_t attr_name_len_instance) : type(type_instance), port_name(port_name_instance), port_name_len(port_name_len_instance), attr_name(attr_name_instance), attr_name_len(attr_name_len_instance) {} DynamicInputOutputInfo() : DynamicInputOutputInfo(kInvalid, nullptr, 0L, nullptr, 0L) {} }; |
|
Parameter |
Description |
|---|---|
|
type |
Specifies dynamic input or output. 0: invalid 1: input 2: output |
|
port_name |
Port name, either an input name or an output name. |
|
port_name_len |
Length of the port name. The maximum length is kMaxNameLength. |
|
attr_name |
Attribute name. |
|
attr_name_len |
Length of the attribute name. The maximum length is kMaxNameLength. |
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
Status QueueDequeueUpToMapping(const ge::Operator& op_src, ge::Operator& op) { vector<DynamicInputOutputInfo> dynamic_name_attr_value; string port_name = "components"; string attr_name = "component_types"; DynamicInputOutputInfo name_attr(kOutput, port_name.c_str(), port_name.size(), attr_name.c_str(), attr_name.size()); dynamic_name_attr_value.push_back(name_attr); AutoMappingByOpFnDynamic(op_src, op, dynamic_name_attr_value); return SUCCESS; } REGISTER_CUSTOM_OP("QueueDequeueUpTo") .FrameworkType(TENSORFLOW) .OriginOpType("QueueDequeueUpToV2") .ParseParamsByOperatorFn(QueueDequeueUpToMapping) .ImplyType(ImplyType::AI_CPU); |