File indexing completed on 2025-12-16 10:20:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #pragma once
0011
0012 #include <map>
0013 #include <memory>
0014 #include <string>
0015 #include <unordered_map>
0016 #include <utility>
0017 #include <vector>
0018
0019 #include "onnx/version_converter/BaseConverter.h"
0020 #include "onnx/version_converter/adapters/axes_attribute_to_input.h"
0021 #include "onnx/version_converter/adapters/axes_input_to_attribute.h"
0022 #include "onnx/version_converter/adapters/axis_attribute_to_input.h"
0023 #include "onnx/version_converter/adapters/axis_input_to_attribute.h"
0024 #include "onnx/version_converter/adapters/batch_normalization_13_14.h"
0025 #include "onnx/version_converter/adapters/broadcast_backward_compatibility.h"
0026 #include "onnx/version_converter/adapters/broadcast_forward_compatibility.h"
0027 #include "onnx/version_converter/adapters/cast_9_8.h"
0028 #include "onnx/version_converter/adapters/clip_10_11.h"
0029 #include "onnx/version_converter/adapters/compatible.h"
0030 #include "onnx/version_converter/adapters/dropout_11_12.h"
0031 #include "onnx/version_converter/adapters/extend_supported_types.h"
0032 #include "onnx/version_converter/adapters/gemm_6_7.h"
0033 #include "onnx/version_converter/adapters/gemm_7_6.h"
0034 #include "onnx/version_converter/adapters/gridsample_19_20.h"
0035 #include "onnx/version_converter/adapters/group_normalization_20_21.h"
0036 #include "onnx/version_converter/adapters/maxpool_8_7.h"
0037 #include "onnx/version_converter/adapters/no_previous_version.h"
0038 #include "onnx/version_converter/adapters/pad_10_11.h"
0039 #include "onnx/version_converter/adapters/q_dq_21_20.h"
0040 #include "onnx/version_converter/adapters/reshape_4_5.h"
0041 #include "onnx/version_converter/adapters/reshape_5_4.h"
0042 #include "onnx/version_converter/adapters/resize_10_11.h"
0043 #include "onnx/version_converter/adapters/scan_8_9.h"
0044 #include "onnx/version_converter/adapters/scan_9_8.h"
0045 #include "onnx/version_converter/adapters/scatter_10_11.h"
0046 #include "onnx/version_converter/adapters/slice_9_10.h"
0047 #include "onnx/version_converter/adapters/softmax_12_13.h"
0048 #include "onnx/version_converter/adapters/split_12_13.h"
0049 #include "onnx/version_converter/adapters/split_13_12.h"
0050 #include "onnx/version_converter/adapters/split_17_18.h"
0051 #include "onnx/version_converter/adapters/sum_8_7.h"
0052 #include "onnx/version_converter/adapters/topk_9_10.h"
0053 #include "onnx/version_converter/adapters/transformers.h"
0054 #include "onnx/version_converter/adapters/type_restriction.h"
0055 #include "onnx/version_converter/adapters/upsample_6_7.h"
0056 #include "onnx/version_converter/adapters/upsample_8_9.h"
0057 #include "onnx/version_converter/adapters/upsample_9_10.h"
0058 #include "onnx/version_converter/adapters/upsample_9_8.h"
0059
0060 namespace ONNX_NAMESPACE {
0061 namespace version_conversion {
0062
0063 class DefaultVersionConverter : public BaseVersionConverter {
0064 private:
0065 bool DEBUG = false;
0066
0067 std::pair<int, int> version_range;
0068
0069 bool searchOpDomainMap(
0070 const std::unordered_map<std::string, std::map<int64_t, const OpSchema*>>& op_domain_map,
0071 int64_t curr_version,
0072 int64_t step) const {
0073 bool up = step == 1;
0074 const auto version_it = op_domain_map.find("");
0075 return version_it != op_domain_map.end() &&
0076 ((version_it->second.find(curr_version) != version_it->second.end() && !up) ||
0077 (version_it->second.find(curr_version + step) != version_it->second.end() && up));
0078 }
0079
0080 void debug(const std::string& str) const {
0081 if (DEBUG)
0082 std::cerr << str << std::endl;
0083 }
0084
0085 void assertInVersionRange(int64_t version) const {
0086 ONNX_ASSERTM(
0087 version >= version_range.first && version <= version_range.second,
0088 "Warning: invalid version (must be between %d and %d)",
0089 version_range.first,
0090 version_range.second);
0091 }
0092
0093 void assertDefaultDomain(const std::string& initial_domain, const std::string& target_domain) const {
0094 ONNX_ASSERTM(
0095 (initial_domain == "" || initial_domain == "ai.onnx") && (target_domain == "" || target_domain == "ai.onnx"),
0096 "Warning: default onnx version converter can only convert "
0097 " between default domain opset versions ('' or 'ai.onnx')\n");
0098 ONNX_ASSERTM(initial_domain == target_domain, "initial_version and target_version must have the same domains");
0099 }
0100
0101 void convert_graph(std::shared_ptr<Graph> g, const OpSetID& initial_version, const OpSetID& target_version) const;
0102
0103 public:
0104 DefaultVersionConverter() {
0105 const std::unordered_map<std::string, std::pair<int, int>>& versions_map =
0106 OpSchemaRegistry::DomainToVersionRange::Instance().Map();
0107 version_range = versions_map.at("");
0108
0109 const std::vector<OpSchema> all_opschemas = OpSchemaRegistry::get_all_schemas_with_history();
0110
0111 for (const OpSchema& schema : all_opschemas) {
0112 all_schemas[schema.Name()][schema.domain()][(int64_t)schema.since_version()] = &schema;
0113 }
0114
0115
0116 for (auto& op_pair : all_schemas) {
0117 const auto default_versions = op_pair.second.find("");
0118 if (default_versions != op_pair.second.end()) {
0119 int64_t min_version = version_range.second;
0120 for (auto& version_pair : default_versions->second) {
0121 if (version_pair.first < min_version) {
0122 min_version = version_pair.first;
0123 }
0124 }
0125 if (min_version > 1) {
0126 registerAdapter(std::make_unique<NoPreviousVersionAdapter>(
0127 op_pair.first, OpSetID(min_version), OpSetID(min_version - 1)));
0128 }
0129 }
0130 }
0131
0132
0133
0134
0135
0136
0137
0138
0139 registerAdapter("Concat", 3, 4, SetAttributeIfAbsent(kaxis, 1));
0140
0141
0142 std::vector<TensorProto_DataType> concat_unallowed_types = {
0143 TensorProto_DataType_INT32,
0144 TensorProto_DataType_INT64,
0145 TensorProto_DataType_UINT32,
0146 TensorProto_DataType_UINT64,
0147 TensorProto_DataType_UINT8,
0148 TensorProto_DataType_UINT16,
0149 TensorProto_DataType_INT8,
0150 TensorProto_DataType_INT16,
0151 TensorProto_DataType_STRING,
0152 TensorProto_DataType_BOOL};
0153 registerAdapter(std::make_unique<TypeRestriction>("Concat", OpSetID(4), OpSetID(3), concat_unallowed_types));
0154
0155
0156 registerAdapter(std::make_unique<Reshape_4_5>());
0157
0158
0159 registerAdapter(std::make_unique<Reshape_5_4>());
0160
0161
0162
0163 auto removeConsumedInputs = RemoveAttribute(kconsumed_inputs);
0164 registerAdapter("Add", 5, 6, removeConsumedInputs);
0165 registerAdapter("Mul", 5, 6, removeConsumedInputs);
0166 registerAdapter(std::make_unique<CompatibleAdapter>("Gemm", OpSetID(5), OpSetID(6)));
0167 registerAdapter("Relu", 5, 6, removeConsumedInputs);
0168 registerAdapter("BatchNormalization", 5, 6, removeConsumedInputs);
0169 registerAdapter("Sum", 5, 6, removeConsumedInputs);
0170 registerAdapter("Dropout", 5, 6, removeConsumedInputs);
0171 registerAdapter("Abs", 5, 6, removeConsumedInputs);
0172 registerAdapter("Ceil", 5, 6, removeConsumedInputs);
0173 registerAdapter("Clip", 5, 6, removeConsumedInputs);
0174 registerAdapter("Div", 5, 6, removeConsumedInputs);
0175 registerAdapter("Elu", 5, 6, removeConsumedInputs);
0176 registerAdapter("Exp", 5, 6, removeConsumedInputs);
0177 registerAdapter("Floor", 5, 6, removeConsumedInputs);
0178 registerAdapter("HardSigmoid", 5, 6, removeConsumedInputs);
0179 registerAdapter("InstanceNormalization", 5, 6, removeConsumedInputs);
0180 registerAdapter("LeakyRelu", 5, 6, removeConsumedInputs);
0181 registerAdapter("Log", 5, 6, removeConsumedInputs);
0182 registerAdapter("Max", 5, 6, removeConsumedInputs);
0183 registerAdapter("Mean", 5, 6, removeConsumedInputs);
0184 registerAdapter("Min", 5, 6, removeConsumedInputs);
0185 registerAdapter("Neg", 5, 6, removeConsumedInputs);
0186 registerAdapter("PRelu", 5, 6, removeConsumedInputs);
0187 registerAdapter("Reciprocal", 5, 6, removeConsumedInputs);
0188 registerAdapter("Selu", 5, 6, removeConsumedInputs);
0189 registerAdapter("Sigmoid", 5, 6, removeConsumedInputs);
0190 registerAdapter("Sqrt", 5, 6, removeConsumedInputs);
0191 registerAdapter("Sub", 5, 6, removeConsumedInputs);
0192 registerAdapter("Tanh", 5, 6, removeConsumedInputs);
0193
0194
0195 std::vector<TensorProto_DataType> broadcast_unallowed_types = {
0196 TensorProto_DataType_INT32,
0197 TensorProto_DataType_INT64,
0198 TensorProto_DataType_UINT32,
0199 TensorProto_DataType_UINT64};
0200 std::vector<TensorProto_DataType> int_unallowed_types = {
0201 TensorProto_DataType_UINT8,
0202 TensorProto_DataType_UINT16,
0203 TensorProto_DataType_UINT32,
0204 TensorProto_DataType_UINT64,
0205 TensorProto_DataType_INT8,
0206 TensorProto_DataType_INT16,
0207 TensorProto_DataType_INT32,
0208 TensorProto_DataType_INT64};
0209 std::vector<TensorProto_DataType> neg_unallowed_types = {
0210 TensorProto_DataType_INT32, TensorProto_DataType_INT8, TensorProto_DataType_UINT16, TensorProto_DataType_INT64};
0211 registerAdapter(std::make_unique<TypeRestriction>("Add", OpSetID(6), OpSetID(5), broadcast_unallowed_types));
0212 registerAdapter(std::make_unique<TypeRestriction>("Mul", OpSetID(6), OpSetID(5), broadcast_unallowed_types));
0213 registerAdapter(std::make_unique<TypeRestriction>("Sub", OpSetID(6), OpSetID(5), broadcast_unallowed_types));
0214 registerAdapter(std::make_unique<TypeRestriction>("Div", OpSetID(6), OpSetID(5), broadcast_unallowed_types));
0215 registerAdapter(std::make_unique<TypeRestriction>("Abs", OpSetID(6), OpSetID(5), int_unallowed_types));
0216 registerAdapter(std::make_unique<TypeRestriction>("Neg", OpSetID(6), OpSetID(5), neg_unallowed_types));
0217 registerAdapter("BatchNormalization", 6, 5, SetAttribute(kconsumed_inputs, std::vector<int64_t>({0, 0})));
0218 registerAdapter(std::make_unique<CompatibleAdapter>("Gemm", OpSetID(6), OpSetID(5)));
0219 registerAdapter(std::make_unique<CompatibleAdapter>("Relu", OpSetID(6), OpSetID(5)));
0220 registerAdapter(std::make_unique<CompatibleAdapter>("Sum", OpSetID(6), OpSetID(5)));
0221 registerAdapter(std::make_unique<CompatibleAdapter>("Dropout", OpSetID(6), OpSetID(5)));
0222
0223
0224
0225 registerAdapter(std::make_unique<BroadcastForwardCompatibility>("Add", OpSetID(6), OpSetID(7)));
0226 registerAdapter(std::make_unique<CompatibleAdapter>("AveragePool", OpSetID(6), OpSetID(7)));
0227 registerAdapter(std::make_unique<BroadcastForwardCompatibility>("Div", OpSetID(6), OpSetID(7)));
0228 registerAdapter(std::make_unique<BroadcastForwardCompatibility>("Mul", OpSetID(6), OpSetID(7)));
0229 registerAdapter(std::make_unique<BroadcastForwardCompatibility>("Pow", OpSetID(6), OpSetID(7)));
0230 registerAdapter(std::make_unique<CompatibleAdapter>("PRelu", OpSetID(6), OpSetID(7)));
0231 registerAdapter(std::make_unique<BroadcastForwardCompatibility>("Sub", OpSetID(6), OpSetID(7)));
0232 registerAdapter(std::make_unique<Gemm_6_7>());
0233 registerAdapter("BatchNormalization", 6, 7, RemoveAttributeNotEq(kis_test, 0));
0234 registerAdapter("Dropout", 6, 7, RemoveAttributeNotEq(kis_test, 0));
0235 registerAdapter(std::make_unique<Upsample_6_7>());
0236
0237
0238 registerAdapter(std::make_unique<BroadcastBackwardCompatibility>("Add", OpSetID(7), OpSetID(6)));
0239 registerAdapter(std::make_unique<BroadcastBackwardCompatibility>("Div", OpSetID(7), OpSetID(6)));
0240 registerAdapter(std::make_unique<BroadcastBackwardCompatibility>("Mul", OpSetID(7), OpSetID(6)));
0241 registerAdapter(std::make_unique<BroadcastBackwardCompatibility>("Pow", OpSetID(7), OpSetID(6)));
0242 registerAdapter(std::make_unique<CompatibleAdapter>("PRelu", OpSetID(7), OpSetID(6)));
0243 registerAdapter(std::make_unique<BroadcastBackwardCompatibility>("Sub", OpSetID(7), OpSetID(6)));
0244 registerAdapter("BatchNormalization", 7, 6, SetAttribute(kis_test, 1));
0245 registerAdapter("Dropout", 7, 6, SetAttribute(kis_test, 1));
0246 registerAdapter(std::make_unique<Gemm_7_6>());
0247 registerAdapter("AveragePool", 7, 6, RemoveAttribute(kcount_include_pad, 0));
0248
0249
0250 registerAdapter(std::make_unique<CompatibleAdapter>("Max", OpSetID(7), OpSetID(8)));
0251 registerAdapter(std::make_unique<CompatibleAdapter>("Min", OpSetID(7), OpSetID(8)));
0252 registerAdapter(std::make_unique<CompatibleAdapter>("Mean", OpSetID(7), OpSetID(8)));
0253 registerAdapter(std::make_unique<CompatibleAdapter>("Sum", OpSetID(7), OpSetID(8)));
0254 registerAdapter(std::make_unique<CompatibleAdapter>("MaxPool", OpSetID(7), OpSetID(8)));
0255
0256
0257 registerAdapter(std::make_unique<BroadcastBackwardCompatibility>("Max", OpSetID(8), OpSetID(7)));
0258 registerAdapter(std::make_unique<BroadcastBackwardCompatibility>("Min", OpSetID(8), OpSetID(7)));
0259 registerAdapter(std::make_unique<BroadcastBackwardCompatibility>("Mean", OpSetID(8), OpSetID(7)));
0260 registerAdapter(std::make_unique<Sum_8_7>());
0261 registerAdapter(std::make_unique<MaxPool_8_7>());
0262
0263
0264 registerAdapter(std::make_unique<CompatibleAdapter>("Flatten", OpSetID(8), OpSetID(9)));
0265 registerAdapter(std::make_unique<CompatibleAdapter>("Constant", OpSetID(8), OpSetID(9)));
0266 registerAdapter(std::make_unique<CompatibleAdapter>("MatMul", OpSetID(8), OpSetID(9)));
0267 registerAdapter(std::make_unique<CompatibleAdapter>("Gemm", OpSetID(8), OpSetID(9)));
0268 registerAdapter(std::make_unique<CompatibleAdapter>("PRelu", OpSetID(8), OpSetID(9)));
0269 registerAdapter(std::make_unique<CompatibleAdapter>("Greater", OpSetID(8), OpSetID(9)));
0270 registerAdapter(std::make_unique<CompatibleAdapter>("Less", OpSetID(8), OpSetID(9)));
0271 registerAdapter(std::make_unique<CompatibleAdapter>("Cast", OpSetID(8), OpSetID(9)));
0272 registerAdapter("BatchNormalization", 8, 9, RemoveAttribute(kspatial, 1));
0273 registerAdapter(std::make_unique<Scan_8_9>());
0274 registerAdapter(std::make_unique<Upsample_8_9>());
0275
0276
0277 registerAdapter(std::make_unique<CompatibleAdapter>("BatchNormalization", OpSetID(9), OpSetID(8)));
0278 registerAdapter(std::make_unique<ExtendSupportedTypes>("Flatten", OpSetID(9), OpSetID(8)));
0279 registerAdapter(std::make_unique<ExtendSupportedTypes>("Constant", OpSetID(9), OpSetID(8)));
0280 registerAdapter(std::make_unique<ExtendSupportedTypes>("MatMul", OpSetID(9), OpSetID(8)));
0281 registerAdapter(std::make_unique<ExtendSupportedTypes>("Gemm", OpSetID(9), OpSetID(8)));
0282 registerAdapter(std::make_unique<ExtendSupportedTypes>("PRelu", OpSetID(9), OpSetID(8)));
0283 registerAdapter(std::make_unique<ExtendSupportedTypes>("Greater", OpSetID(9), OpSetID(8)));
0284 registerAdapter(std::make_unique<ExtendSupportedTypes>("Less", OpSetID(9), OpSetID(8)));
0285 registerAdapter(std::make_unique<Cast_9_8>());
0286 registerAdapter(std::make_unique<Scan_9_8>());
0287 registerAdapter(std::make_unique<Upsample_9_8>());
0288
0289
0290 registerAdapter(std::make_unique<CompatibleAdapter>("AveragePool", OpSetID(9), OpSetID(10)));
0291 registerAdapter(std::make_unique<CompatibleAdapter>("MaxPool", OpSetID(9), OpSetID(10)));
0292 registerAdapter(std::make_unique<CompatibleAdapter>("Dropout", OpSetID(9), OpSetID(10)));
0293 registerAdapter(std::make_unique<Slice_9_10>());
0294 registerAdapter(std::make_unique<TopK_9_10>());
0295 registerAdapter(std::make_unique<Upsample_9_10>());
0296
0297
0298 registerAdapter(std::make_unique<CompatibleAdapter>("Dropout", OpSetID(10), OpSetID(9)));
0299
0300
0301 registerAdapter(std::make_unique<CompatibleAdapter>("ArgMax", OpSetID(10), OpSetID(11)));
0302 registerAdapter(std::make_unique<CompatibleAdapter>("ArgMin", OpSetID(10), OpSetID(11)));
0303 registerAdapter(std::make_unique<CompatibleAdapter>("AveragePool", OpSetID(10), OpSetID(11)));
0304 registerAdapter(std::make_unique<CompatibleAdapter>("Concat", OpSetID(10), OpSetID(11)));
0305 registerAdapter(std::make_unique<CompatibleAdapter>("Constant", OpSetID(10), OpSetID(11)));
0306 registerAdapter(std::make_unique<CompatibleAdapter>("Compress", OpSetID(10), OpSetID(11)));
0307 registerAdapter(std::make_unique<CompatibleAdapter>("Conv", OpSetID(10), OpSetID(11)));
0308 registerAdapter(std::make_unique<CompatibleAdapter>("ConvTranspose", OpSetID(10), OpSetID(11)));
0309 registerAdapter(std::make_unique<CompatibleAdapter>("DepthToSpace", OpSetID(10), OpSetID(11)));
0310 registerAdapter(std::make_unique<CompatibleAdapter>("Equal", OpSetID(10), OpSetID(11)));
0311 registerAdapter(std::make_unique<CompatibleAdapter>("Flatten", OpSetID(10), OpSetID(11)));
0312 registerAdapter(std::make_unique<CompatibleAdapter>("Gather", OpSetID(10), OpSetID(11)));
0313 registerAdapter(std::make_unique<CompatibleAdapter>("Gemm", OpSetID(10), OpSetID(11)));
0314 registerAdapter(std::make_unique<CompatibleAdapter>("Hardmax", OpSetID(10), OpSetID(11)));
0315 registerAdapter(std::make_unique<CompatibleAdapter>("If", OpSetID(10), OpSetID(11)));
0316 registerAdapter(std::make_unique<CompatibleAdapter>("LogSoftmax", OpSetID(10), OpSetID(11)));
0317 registerAdapter(std::make_unique<CompatibleAdapter>("Loop", OpSetID(10), OpSetID(11)));
0318 registerAdapter(std::make_unique<CompatibleAdapter>("LpPool", OpSetID(10), OpSetID(11)));
0319 registerAdapter(std::make_unique<CompatibleAdapter>("MaxPool", OpSetID(10), OpSetID(11)));
0320 registerAdapter(std::make_unique<CompatibleAdapter>("MaxUnpool", OpSetID(10), OpSetID(11)));
0321 registerAdapter(std::make_unique<CompatibleAdapter>("NonMaxSuppression", OpSetID(10), OpSetID(11)));
0322 registerAdapter(std::make_unique<CompatibleAdapter>("OneHot", OpSetID(10), OpSetID(11)));
0323 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceL1", OpSetID(10), OpSetID(11)));
0324 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceL2", OpSetID(10), OpSetID(11)));
0325 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceLogSum", OpSetID(10), OpSetID(11)));
0326 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceLogSumExp", OpSetID(10), OpSetID(11)));
0327 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceMax", OpSetID(10), OpSetID(11)));
0328 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceMean", OpSetID(10), OpSetID(11)));
0329 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceMin", OpSetID(10), OpSetID(11)));
0330 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceProd", OpSetID(10), OpSetID(11)));
0331 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceSum", OpSetID(10), OpSetID(11)));
0332 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceSumSquare", OpSetID(10), OpSetID(11)));
0333 registerAdapter(std::make_unique<CompatibleAdapter>("Scan", OpSetID(10), OpSetID(11)));
0334 registerAdapter(std::make_unique<CompatibleAdapter>("Softmax", OpSetID(10), OpSetID(11)));
0335 registerAdapter(std::make_unique<CompatibleAdapter>("Slice", OpSetID(10), OpSetID(11)));
0336 registerAdapter(std::make_unique<CompatibleAdapter>("Split", OpSetID(10), OpSetID(11)));
0337 registerAdapter(std::make_unique<CompatibleAdapter>("Squeeze", OpSetID(10), OpSetID(11)));
0338 registerAdapter(std::make_unique<CompatibleAdapter>("TopK", OpSetID(10), OpSetID(11)));
0339 registerAdapter(std::make_unique<CompatibleAdapter>("Unsqueeze", OpSetID(10), OpSetID(11)));
0340 registerAdapter(std::make_unique<Clip_10_11>());
0341 registerAdapter(std::make_unique<Pad_10_11>());
0342 registerAdapter(std::make_unique<Resize_10_11>());
0343 registerAdapter(std::make_unique<Scatter_10_11>());
0344
0345
0346 std::vector<TensorProto_DataType> equal_unallowed_types = {
0347 TensorProto_DataType_UINT8,
0348 TensorProto_DataType_UINT16,
0349 TensorProto_DataType_UINT32,
0350 TensorProto_DataType_UINT64,
0351 TensorProto_DataType_INT8,
0352 TensorProto_DataType_INT16,
0353 TensorProto_DataType_FLOAT16,
0354 TensorProto_DataType_FLOAT,
0355 TensorProto_DataType_DOUBLE};
0356 registerAdapter(std::make_unique<CompatibleAdapter>("ArgMax", OpSetID(11), OpSetID(10)));
0357 registerAdapter(std::make_unique<CompatibleAdapter>("ArgMin", OpSetID(11), OpSetID(10)));
0358 registerAdapter(std::make_unique<CompatibleAdapter>("AveragePool", OpSetID(11), OpSetID(10)));
0359 registerAdapter(std::make_unique<CompatibleAdapter>("Concat", OpSetID(11), OpSetID(10)));
0360 registerAdapter(std::make_unique<CompatibleAdapter>("Constant", OpSetID(11), OpSetID(10)));
0361 registerAdapter(std::make_unique<CompatibleAdapter>("Conv", OpSetID(11), OpSetID(10)));
0362 registerAdapter(std::make_unique<CompatibleAdapter>("ConvTranspose", OpSetID(11), OpSetID(10)));
0363 registerAdapter(std::make_unique<TypeRestriction>("Equal", OpSetID(11), OpSetID(10), equal_unallowed_types));
0364 registerAdapter(std::make_unique<CompatibleAdapter>("Flatten", OpSetID(11), OpSetID(10)));
0365 registerAdapter(std::make_unique<CompatibleAdapter>("LogSoftmax", OpSetID(11), OpSetID(10)));
0366 registerAdapter(std::make_unique<CompatibleAdapter>("MaxPool", OpSetID(11), OpSetID(10)));
0367 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceL1", OpSetID(11), OpSetID(10)));
0368 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceL2", OpSetID(11), OpSetID(10)));
0369 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceLogSum", OpSetID(11), OpSetID(10)));
0370 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceLogSumExp", OpSetID(11), OpSetID(10)));
0371 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceMax", OpSetID(11), OpSetID(10)));
0372 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceMean", OpSetID(11), OpSetID(10)));
0373 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceMin", OpSetID(11), OpSetID(10)));
0374 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceProd", OpSetID(11), OpSetID(10)));
0375 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceSum", OpSetID(11), OpSetID(10)));
0376 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceSumSquare", OpSetID(11), OpSetID(10)));
0377 registerAdapter(std::make_unique<CompatibleAdapter>("Softmax", OpSetID(11), OpSetID(10)));
0378 registerAdapter(std::make_unique<CompatibleAdapter>("Unsqueeze", OpSetID(11), OpSetID(10)));
0379
0380
0381 registerAdapter(std::make_unique<CompatibleAdapter>("ArgMax", OpSetID(11), OpSetID(12)));
0382 registerAdapter(std::make_unique<CompatibleAdapter>("ArgMin", OpSetID(11), OpSetID(12)));
0383 registerAdapter(std::make_unique<CompatibleAdapter>("BatchNormalization", OpSetID(11), OpSetID(12)));
0384 registerAdapter(std::make_unique<CompatibleAdapter>("Constant", OpSetID(11), OpSetID(12)));
0385 registerAdapter(std::make_unique<CompatibleAdapter>("Clip", OpSetID(11), OpSetID(12)));
0386 registerAdapter(std::make_unique<CompatibleAdapter>("GatherND", OpSetID(11), OpSetID(12)));
0387 registerAdapter(std::make_unique<CompatibleAdapter>("Min", OpSetID(11), OpSetID(12)));
0388 registerAdapter(std::make_unique<CompatibleAdapter>("Max", OpSetID(11), OpSetID(12)));
0389 registerAdapter(std::make_unique<CompatibleAdapter>("MaxPool", OpSetID(11), OpSetID(12)));
0390 registerAdapter(std::make_unique<CompatibleAdapter>("Pow", OpSetID(11), OpSetID(12)));
0391 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceMax", OpSetID(11), OpSetID(12)));
0392 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceMin", OpSetID(11), OpSetID(12)));
0393 registerAdapter(std::make_unique<Dropout_11_12>());
0394
0395
0396 std::vector<TensorProto_DataType> maxpool_unallowed_types = {TensorProto_DataType_UINT8, TensorProto_DataType_INT8};
0397 registerAdapter("ArgMax", 12, 11, RemoveAttribute(kselect_last_index, 0));
0398 registerAdapter("ArgMin", 12, 11, RemoveAttribute(kselect_last_index, 0));
0399 registerAdapter(std::make_unique<CompatibleAdapter>("BatchNormalization", OpSetID(12), OpSetID(11)));
0400 registerAdapter(std::make_unique<TypeRestriction>("Clip", OpSetID(12), OpSetID(11), int_unallowed_types));
0401 registerAdapter(std::make_unique<TypeRestriction>("Min", OpSetID(12), OpSetID(11), int_unallowed_types));
0402 registerAdapter(std::make_unique<TypeRestriction>("Max", OpSetID(12), OpSetID(11), int_unallowed_types));
0403 registerAdapter(std::make_unique<TypeRestriction>("MaxPool", OpSetID(12), OpSetID(11), maxpool_unallowed_types));
0404 registerAdapter(std::make_unique<TypeRestriction>("ReduceMax", OpSetID(12), OpSetID(11), maxpool_unallowed_types));
0405 registerAdapter(std::make_unique<TypeRestriction>("ReduceMin", OpSetID(12), OpSetID(11), maxpool_unallowed_types));
0406
0407
0408 registerAdapter(std::make_unique<CompatibleAdapter>("Abs", OpSetID(12), OpSetID(13)));
0409 registerAdapter(std::make_unique<CompatibleAdapter>("Add", OpSetID(12), OpSetID(13)));
0410 registerAdapter(std::make_unique<CompatibleAdapter>("ArgMin", OpSetID(12), OpSetID(13)));
0411 registerAdapter(std::make_unique<CompatibleAdapter>("ArgMax", OpSetID(12), OpSetID(13)));
0412 registerAdapter(std::make_unique<CompatibleAdapter>("Cast", OpSetID(12), OpSetID(13)));
0413 registerAdapter(std::make_unique<CompatibleAdapter>("Ceil", OpSetID(12), OpSetID(13)));
0414 registerAdapter(std::make_unique<CompatibleAdapter>("Clip", OpSetID(12), OpSetID(13)));
0415 registerAdapter(std::make_unique<CompatibleAdapter>("Concat", OpSetID(12), OpSetID(13)));
0416 registerAdapter(std::make_unique<CompatibleAdapter>("Constant", OpSetID(12), OpSetID(13)));
0417 registerAdapter(std::make_unique<CompatibleAdapter>("DepthToSpace", OpSetID(12), OpSetID(13)));
0418 registerAdapter(std::make_unique<CompatibleAdapter>("DequantizeLinear", OpSetID(12), OpSetID(13)));
0419 registerAdapter(std::make_unique<CompatibleAdapter>("Div", OpSetID(12), OpSetID(13)));
0420 registerAdapter(std::make_unique<CompatibleAdapter>("Dropout", OpSetID(12), OpSetID(13)));
0421 registerAdapter(std::make_unique<CompatibleAdapter>("Equal", OpSetID(12), OpSetID(13)));
0422 registerAdapter(std::make_unique<CompatibleAdapter>("Erf", OpSetID(12), OpSetID(13)));
0423 registerAdapter(std::make_unique<CompatibleAdapter>("Exp", OpSetID(12), OpSetID(13)));
0424 registerAdapter(std::make_unique<CompatibleAdapter>("Expand", OpSetID(12), OpSetID(13)));
0425 registerAdapter(std::make_unique<CompatibleAdapter>("Flatten", OpSetID(12), OpSetID(13)));
0426 registerAdapter(std::make_unique<CompatibleAdapter>("Floor", OpSetID(12), OpSetID(13)));
0427 registerAdapter(std::make_unique<CompatibleAdapter>("Gather", OpSetID(12), OpSetID(13)));
0428 registerAdapter(std::make_unique<CompatibleAdapter>("GatherElements", OpSetID(12), OpSetID(13)));
0429 registerAdapter(std::make_unique<CompatibleAdapter>("GatherND", OpSetID(12), OpSetID(13)));
0430 registerAdapter(std::make_unique<CompatibleAdapter>("Gemm", OpSetID(12), OpSetID(13)));
0431 registerAdapter(std::make_unique<CompatibleAdapter>("Greater", OpSetID(12), OpSetID(13)));
0432 registerAdapter(std::make_unique<CompatibleAdapter>("Hardmax", OpSetID(12), OpSetID(13)));
0433 registerAdapter(std::make_unique<CompatibleAdapter>("Identity", OpSetID(12), OpSetID(13)));
0434 registerAdapter(std::make_unique<CompatibleAdapter>("If", OpSetID(12), OpSetID(13)));
0435 registerAdapter(std::make_unique<CompatibleAdapter>("IsNaN", OpSetID(12), OpSetID(13)));
0436 registerAdapter(std::make_unique<CompatibleAdapter>("Less", OpSetID(12), OpSetID(13)));
0437 registerAdapter(std::make_unique<CompatibleAdapter>("Log", OpSetID(12), OpSetID(13)));
0438 registerAdapter(std::make_unique<CompatibleAdapter>("Loop", OpSetID(12), OpSetID(13)));
0439 registerAdapter(std::make_unique<CompatibleAdapter>("LRN", OpSetID(12), OpSetID(13)));
0440 registerAdapter(std::make_unique<CompatibleAdapter>("NegativeLogLikelihoodLoss", OpSetID(12), OpSetID(13)));
0441 registerAdapter(std::make_unique<CompatibleAdapter>("MatMul", OpSetID(12), OpSetID(13)));
0442 registerAdapter(std::make_unique<CompatibleAdapter>("Max", OpSetID(12), OpSetID(13)));
0443 registerAdapter(std::make_unique<CompatibleAdapter>("Mean", OpSetID(12), OpSetID(13)));
0444 registerAdapter(std::make_unique<CompatibleAdapter>("MeanVarianceNormalization", OpSetID(12), OpSetID(13)));
0445 registerAdapter(std::make_unique<CompatibleAdapter>("Min", OpSetID(12), OpSetID(13)));
0446 registerAdapter(std::make_unique<CompatibleAdapter>("Mod", OpSetID(12), OpSetID(13)));
0447 registerAdapter(std::make_unique<CompatibleAdapter>("Mul", OpSetID(12), OpSetID(13)));
0448 registerAdapter(std::make_unique<CompatibleAdapter>("Neg", OpSetID(12), OpSetID(13)));
0449 registerAdapter(std::make_unique<CompatibleAdapter>("NonZero", OpSetID(12), OpSetID(13)));
0450 registerAdapter(std::make_unique<CompatibleAdapter>("Pow", OpSetID(12), OpSetID(13)));
0451 registerAdapter(std::make_unique<CompatibleAdapter>("Pad", OpSetID(12), OpSetID(13)));
0452 registerAdapter(std::make_unique<CompatibleAdapter>("QuantizeLinear", OpSetID(12), OpSetID(13)));
0453 registerAdapter(std::make_unique<CompatibleAdapter>("Reciprocal", OpSetID(12), OpSetID(13)));
0454 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceL1", OpSetID(12), OpSetID(13)));
0455 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceL2", OpSetID(12), OpSetID(13)));
0456 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceLogSum", OpSetID(12), OpSetID(13)));
0457 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceLogSumExp", OpSetID(12), OpSetID(13)));
0458 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceMean", OpSetID(12), OpSetID(13)));
0459 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceMax", OpSetID(12), OpSetID(13)));
0460 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceMin", OpSetID(12), OpSetID(13)));
0461 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceProd", OpSetID(12), OpSetID(13)));
0462 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceSumSquare", OpSetID(12), OpSetID(13)));
0463 registerAdapter(std::make_unique<CompatibleAdapter>("Relu", OpSetID(12), OpSetID(13)));
0464 registerAdapter(std::make_unique<CompatibleAdapter>("Reshape", OpSetID(12), OpSetID(13)));
0465 registerAdapter(std::make_unique<CompatibleAdapter>("Resize", OpSetID(12), OpSetID(13)));
0466 registerAdapter(std::make_unique<CompatibleAdapter>("ScatterElements", OpSetID(12), OpSetID(13)));
0467 registerAdapter(std::make_unique<CompatibleAdapter>("ScatterND", OpSetID(12), OpSetID(13)));
0468 registerAdapter(std::make_unique<CompatibleAdapter>("Shape", OpSetID(12), OpSetID(13)));
0469 registerAdapter(std::make_unique<CompatibleAdapter>("Sigmoid", OpSetID(12), OpSetID(13)));
0470 registerAdapter(std::make_unique<CompatibleAdapter>("Sign", OpSetID(12), OpSetID(13)));
0471 registerAdapter(std::make_unique<CompatibleAdapter>("Size", OpSetID(12), OpSetID(13)));
0472 registerAdapter(std::make_unique<CompatibleAdapter>("Slice", OpSetID(12), OpSetID(13)));
0473 registerAdapter(std::make_unique<CompatibleAdapter>("SoftmaxCrossEntropyLoss", OpSetID(12), OpSetID(13)));
0474 registerAdapter(std::make_unique<CompatibleAdapter>("SpaceToDepth", OpSetID(12), OpSetID(13)));
0475 registerAdapter(std::make_unique<CompatibleAdapter>("Sqrt", OpSetID(12), OpSetID(13)));
0476 registerAdapter(std::make_unique<CompatibleAdapter>("Sub", OpSetID(12), OpSetID(13)));
0477 registerAdapter(std::make_unique<CompatibleAdapter>("Sum", OpSetID(12), OpSetID(13)));
0478 registerAdapter(std::make_unique<CompatibleAdapter>("Tanh", OpSetID(12), OpSetID(13)));
0479 registerAdapter(std::make_unique<CompatibleAdapter>("Tile", OpSetID(12), OpSetID(13)));
0480 registerAdapter(std::make_unique<CompatibleAdapter>("Transpose", OpSetID(12), OpSetID(13)));
0481 registerAdapter(std::make_unique<AxesAttributeToInput>("ReduceSum", OpSetID(12), OpSetID(13)));
0482 registerAdapter(std::make_unique<AxesAttributeToInput>("Squeeze", OpSetID(12), OpSetID(13)));
0483 registerAdapter(std::make_unique<AxesAttributeToInput>("Unsqueeze", OpSetID(12), OpSetID(13)));
0484 registerAdapter(std::make_unique<Split_12_13>());
0485 registerAdapter(std::make_unique<Softmax_12_13>("Softmax"));
0486 registerAdapter(std::make_unique<Softmax_12_13>("LogSoftmax"));
0487
0488
0489 registerAdapter(std::make_unique<CompatibleAdapter>("Constant", OpSetID(13), OpSetID(12)));
0490 registerAdapter(std::make_unique<AxesInputToAttribute>("ReduceSum", OpSetID(13), OpSetID(12)));
0491 registerAdapter(std::make_unique<AxesInputToAttribute>("Squeeze", OpSetID(13), OpSetID(12)));
0492 registerAdapter(std::make_unique<AxesInputToAttribute>("Unsqueeze", OpSetID(13), OpSetID(12)));
0493 registerAdapter(std::make_unique<Split_13_12>());
0494
0495
0496 registerAdapter(std::make_unique<CompatibleAdapter>("Add", OpSetID(13), OpSetID(14)));
0497 registerAdapter(std::make_unique<CompatibleAdapter>("CumSum", OpSetID(13), OpSetID(14)));
0498 registerAdapter(std::make_unique<CompatibleAdapter>("Div", OpSetID(13), OpSetID(14)));
0499 registerAdapter(std::make_unique<CompatibleAdapter>("Identity", OpSetID(13), OpSetID(14)));
0500 registerAdapter(std::make_unique<CompatibleAdapter>("Mul", OpSetID(13), OpSetID(14)));
0501 registerAdapter(std::make_unique<CompatibleAdapter>("Relu", OpSetID(13), OpSetID(14)));
0502 registerAdapter(std::make_unique<CompatibleAdapter>("Reshape", OpSetID(13), OpSetID(14)));
0503 registerAdapter(std::make_unique<CompatibleAdapter>("Sub", OpSetID(13), OpSetID(14)));
0504 registerAdapter("GRU", 13, 14, SetAttribute(klayout, 0));
0505 registerAdapter("LSTM", 13, 14, SetAttribute(klayout, 0));
0506 registerAdapter("RNN", 13, 14, SetAttribute(klayout, 0));
0507 registerAdapter(std::make_unique<BatchNormalization_13_14>());
0508
0509
0510 registerAdapter("GRU", 14, 13, RemoveAttribute(klayout, 0));
0511 registerAdapter("LSTM", 14, 13, RemoveAttribute(klayout, 0));
0512 registerAdapter("RNN", 14, 13, RemoveAttribute(klayout, 0));
0513
0514
0515 registerAdapter(std::make_unique<CompatibleAdapter>("BatchNormalization", OpSetID(14), OpSetID(15)));
0516 registerAdapter(std::make_unique<CompatibleAdapter>("Pow", OpSetID(14), OpSetID(15)));
0517 registerAdapter(std::make_unique<CompatibleAdapter>("Shape", OpSetID(14), OpSetID(15)));
0518
0519
0520 registerAdapter("RoiAlign", 15, 16, SetAttribute(kcoordinate_transformation_mode, "output_half_pixel"));
0521 registerAdapter(std::make_unique<CompatibleAdapter>("ScatterElements", OpSetID(15), OpSetID(16)));
0522 registerAdapter(std::make_unique<CompatibleAdapter>("ScatterND", OpSetID(15), OpSetID(16)));
0523 registerAdapter(std::make_unique<CompatibleAdapter>("Identity", OpSetID(15), OpSetID(16)));
0524 registerAdapter(std::make_unique<CompatibleAdapter>("Loop", OpSetID(15), OpSetID(16)));
0525 registerAdapter(std::make_unique<CompatibleAdapter>("If", OpSetID(15), OpSetID(16)));
0526 registerAdapter(std::make_unique<CompatibleAdapter>("Where", OpSetID(15), OpSetID(16)));
0527 registerAdapter(std::make_unique<CompatibleAdapter>("Scan", OpSetID(15), OpSetID(16)));
0528 registerAdapter(std::make_unique<CompatibleAdapter>("LessOrEqual", OpSetID(15), OpSetID(16)));
0529 registerAdapter(std::make_unique<CompatibleAdapter>("GreaterOrEqual", OpSetID(15), OpSetID(16)));
0530 registerAdapter(std::make_unique<CompatibleAdapter>("LeakyRelu", OpSetID(15), OpSetID(16)));
0531 registerAdapter(std::make_unique<CompatibleAdapter>("PRelu", OpSetID(15), OpSetID(16)));
0532
0533
0534 registerAdapter(std::make_unique<CompatibleAdapter>("Pad", OpSetID(17), OpSetID(18)));
0535 registerAdapter(std::make_unique<CompatibleAdapter>("Resize", OpSetID(17), OpSetID(18)));
0536 registerAdapter(std::make_unique<CompatibleAdapter>("OptionalGetElement", OpSetID(17), OpSetID(18)));
0537 registerAdapter(std::make_unique<CompatibleAdapter>("OptionalHasElement", OpSetID(17), OpSetID(18)));
0538 registerAdapter(std::make_unique<Split_17_18>());
0539 registerAdapter(std::make_unique<CompatibleAdapter>("ScatterND", OpSetID(17), OpSetID(18)));
0540 registerAdapter(std::make_unique<CompatibleAdapter>("ScatterElements", OpSetID(17), OpSetID(18)));
0541 registerAdapter("LpPool", 17, 18, SetAttribute(kceil_mode, 0));
0542 registerAdapter(std::make_unique<AxesAttributeToInput>("ReduceL1", OpSetID(17), OpSetID(18)));
0543 registerAdapter(std::make_unique<AxesAttributeToInput>("ReduceL2", OpSetID(17), OpSetID(18)));
0544 registerAdapter(std::make_unique<AxesAttributeToInput>("ReduceLogSum", OpSetID(17), OpSetID(18)));
0545 registerAdapter(std::make_unique<AxesAttributeToInput>("ReduceLogSumExp", OpSetID(17), OpSetID(18)));
0546 registerAdapter(std::make_unique<AxesAttributeToInput>("ReduceMax", OpSetID(17), OpSetID(18)));
0547 registerAdapter(std::make_unique<AxesAttributeToInput>("ReduceMean", OpSetID(17), OpSetID(18)));
0548 registerAdapter(std::make_unique<AxesAttributeToInput>("ReduceMin", OpSetID(17), OpSetID(18)));
0549 registerAdapter(std::make_unique<AxesAttributeToInput>("ReduceProd", OpSetID(17), OpSetID(18)));
0550 registerAdapter(std::make_unique<AxesAttributeToInput>("ReduceSumSquare", OpSetID(17), OpSetID(18)));
0551
0552
0553 registerAdapter(std::make_unique<AxesInputToAttribute>("ReduceL1", OpSetID(18), OpSetID(17)));
0554 registerAdapter(std::make_unique<AxesInputToAttribute>("ReduceL2", OpSetID(18), OpSetID(17)));
0555 registerAdapter(std::make_unique<AxesInputToAttribute>("ReduceLogSum", OpSetID(18), OpSetID(17)));
0556 registerAdapter(std::make_unique<AxesInputToAttribute>("ReduceLogSumExp", OpSetID(18), OpSetID(17)));
0557 registerAdapter(std::make_unique<AxesInputToAttribute>("ReduceMax", OpSetID(18), OpSetID(17)));
0558 registerAdapter(std::make_unique<AxesInputToAttribute>("ReduceMean", OpSetID(18), OpSetID(17)));
0559 registerAdapter(std::make_unique<AxesInputToAttribute>("ReduceMin", OpSetID(18), OpSetID(17)));
0560 registerAdapter(std::make_unique<AxesInputToAttribute>("ReduceProd", OpSetID(18), OpSetID(17)));
0561 registerAdapter(std::make_unique<AxesInputToAttribute>("ReduceSumSquare", OpSetID(18), OpSetID(17)));
0562
0563
0564 registerAdapter(std::make_unique<CompatibleAdapter>("Equal", OpSetID(18), OpSetID(19)));
0565 registerAdapter(std::make_unique<CompatibleAdapter>("AveragePool", OpSetID(18), OpSetID(19)));
0566 registerAdapter(std::make_unique<CompatibleAdapter>("Cast", OpSetID(18), OpSetID(19)));
0567 registerAdapter(std::make_unique<CompatibleAdapter>("CastLike", OpSetID(18), OpSetID(19)));
0568 registerAdapter(std::make_unique<CompatibleAdapter>("Constant", OpSetID(18), OpSetID(19)));
0569 registerAdapter(std::make_unique<CompatibleAdapter>("DequantizeLinear", OpSetID(18), OpSetID(19)));
0570 registerAdapter(std::make_unique<CompatibleAdapter>("Identity", OpSetID(18), OpSetID(19)));
0571 registerAdapter(std::make_unique<CompatibleAdapter>("If", OpSetID(18), OpSetID(19)));
0572 registerAdapter(std::make_unique<CompatibleAdapter>("Loop", OpSetID(18), OpSetID(19)));
0573 registerAdapter(std::make_unique<CompatibleAdapter>("Pad", OpSetID(18), OpSetID(19)));
0574 registerAdapter(std::make_unique<CompatibleAdapter>("QuantizeLinear", OpSetID(18), OpSetID(19)));
0575 registerAdapter(std::make_unique<CompatibleAdapter>("Reshape", OpSetID(18), OpSetID(19)));
0576 registerAdapter(std::make_unique<CompatibleAdapter>("Resize", OpSetID(18), OpSetID(19)));
0577 registerAdapter(std::make_unique<CompatibleAdapter>("Scan", OpSetID(18), OpSetID(19)));
0578 registerAdapter(std::make_unique<CompatibleAdapter>("Shape", OpSetID(18), OpSetID(19)));
0579 registerAdapter(std::make_unique<CompatibleAdapter>("Size", OpSetID(18), OpSetID(19)));
0580
0581
0582 registerAdapter(std::make_unique<AxisAttributeToInput>("DFT", OpSetID(19), OpSetID(20), 2, 1));
0583 registerAdapter(std::make_unique<CompatibleAdapter>("ConstantOfShape", OpSetID(19), OpSetID(20)));
0584 registerAdapter(std::make_unique<CompatibleAdapter>("IsInf", OpSetID(19), OpSetID(20)));
0585 registerAdapter(std::make_unique<CompatibleAdapter>("IsNaN", OpSetID(19), OpSetID(20)));
0586 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceMax", OpSetID(19), OpSetID(20)));
0587 registerAdapter(std::make_unique<CompatibleAdapter>("ReduceMin", OpSetID(19), OpSetID(20)));
0588 registerAdapter(std::make_unique<GridSample_19_20>());
0589
0590
0591 const std::vector<TensorProto_DataType> is_nan_13_unallowed_types = {
0592 TensorProto_DataType_FLOAT8E4M3FN,
0593 TensorProto_DataType_FLOAT8E4M3FNUZ,
0594 TensorProto_DataType_FLOAT8E5M2,
0595 TensorProto_DataType_FLOAT8E5M2FNUZ};
0596 registerAdapter(std::make_unique<TypeRestriction>("IsNaN", OpSetID(20), OpSetID(19), is_nan_13_unallowed_types));
0597 const std::vector<TensorProto_DataType> is_inf_10_unallowed_types = {
0598 TensorProto_DataType_FLOAT16,
0599 TensorProto_DataType_BFLOAT16,
0600 TensorProto_DataType_FLOAT8E4M3FN,
0601 TensorProto_DataType_FLOAT8E4M3FNUZ,
0602 TensorProto_DataType_FLOAT8E5M2,
0603 TensorProto_DataType_FLOAT8E5M2FNUZ};
0604 registerAdapter(std::make_unique<TypeRestriction>("IsInf", OpSetID(20), OpSetID(19), is_inf_10_unallowed_types));
0605 registerAdapter(std::make_unique<AxisInputToAttribute>("DFT", OpSetID(20), OpSetID(19), 2, -2));
0606 const std::vector<TensorProto_DataType> reduce_min_max_18_unallowed_types = {TensorProto_DataType_BOOL};
0607 registerAdapter(
0608 std::make_unique<TypeRestriction>("ReduceMax", OpSetID(20), OpSetID(19), reduce_min_max_18_unallowed_types));
0609 registerAdapter(
0610 std::make_unique<TypeRestriction>("ReduceMin", OpSetID(20), OpSetID(19), reduce_min_max_18_unallowed_types));
0611
0612
0613 registerAdapter(std::make_unique<CompatibleAdapter>("Cast", OpSetID(20), OpSetID(21)));
0614 registerAdapter(std::make_unique<CompatibleAdapter>("CastLike", OpSetID(20), OpSetID(21)));
0615 registerAdapter(std::make_unique<CompatibleAdapter>("Constant", OpSetID(20), OpSetID(21)));
0616 registerAdapter(std::make_unique<CompatibleAdapter>("ConstantOfShape", OpSetID(20), OpSetID(21)));
0617 registerAdapter(std::make_unique<CompatibleAdapter>("DequantizeLinear", OpSetID(20), OpSetID(21)));
0618 registerAdapter(std::make_unique<CompatibleAdapter>("Flatten", OpSetID(20), OpSetID(21)));
0619 registerAdapter(std::make_unique<GroupNormalization_20_21>());
0620 registerAdapter(std::make_unique<CompatibleAdapter>("Identity", OpSetID(20), OpSetID(21)));
0621 registerAdapter(std::make_unique<CompatibleAdapter>("If", OpSetID(20), OpSetID(21)));
0622 registerAdapter(std::make_unique<CompatibleAdapter>("Loop", OpSetID(20), OpSetID(21)));
0623 registerAdapter(std::make_unique<CompatibleAdapter>("Pad", OpSetID(20), OpSetID(21)));
0624 registerAdapter(std::make_unique<CompatibleAdapter>("QLinearMatMul", OpSetID(20), OpSetID(21)));
0625 registerAdapter(std::make_unique<CompatibleAdapter>("QuantizeLinear", OpSetID(20), OpSetID(21)));
0626 registerAdapter(std::make_unique<CompatibleAdapter>("Reshape", OpSetID(20), OpSetID(21)));
0627 registerAdapter(std::make_unique<CompatibleAdapter>("Scan", OpSetID(20), OpSetID(21)));
0628 registerAdapter(std::make_unique<CompatibleAdapter>("Shape", OpSetID(20), OpSetID(21)));
0629 registerAdapter(std::make_unique<CompatibleAdapter>("Size", OpSetID(20), OpSetID(21)));
0630 registerAdapter(std::make_unique<CompatibleAdapter>("Squeeze", OpSetID(20), OpSetID(21)));
0631 registerAdapter(std::make_unique<CompatibleAdapter>("Transpose", OpSetID(20), OpSetID(21)));
0632 registerAdapter(std::make_unique<CompatibleAdapter>("Unsqueeze", OpSetID(20), OpSetID(21)));
0633 registerAdapter(std::make_unique<CompatibleAdapter>("GroupNormalization", OpSetID(20), OpSetID(21)));
0634
0635
0636 const std::vector<TensorProto_DataType> q_dqmm_20_unallowed_types = {
0637 TensorProto_DataType_BFLOAT16,
0638 TensorProto_DataType_FLOAT16,
0639 TensorProto_DataType_UINT4,
0640 TensorProto_DataType_INT4};
0641 const std::vector<TensorProto_DataType> ir10_types_not_in_ir9 = {
0642 TensorProto_DataType_UINT4, TensorProto_DataType_INT4};
0643 const std::vector<TensorProto_DataType> ir10_types_not_in_ir4 = {
0644 TensorProto_DataType_FLOAT8E4M3FN,
0645 TensorProto_DataType_FLOAT8E4M3FNUZ,
0646 TensorProto_DataType_FLOAT8E5M2,
0647 TensorProto_DataType_FLOAT8E5M2FNUZ,
0648 TensorProto_DataType_UINT4,
0649 TensorProto_DataType_INT4};
0650
0651 registerAdapter(std::make_unique<TypeRestriction>("Cast", OpSetID(21), OpSetID(20), ir10_types_not_in_ir9));
0652 registerAdapter(std::make_unique<TypeRestriction>("CastLike", OpSetID(21), OpSetID(20), ir10_types_not_in_ir9));
0653 registerAdapter(std::make_unique<TypeRestriction>("Constant", OpSetID(21), OpSetID(20), ir10_types_not_in_ir9));
0654 registerAdapter(
0655 std::make_unique<TypeRestriction>("ConstantOfShape", OpSetID(21), OpSetID(20), ir10_types_not_in_ir9));
0656 registerAdapter(std::make_unique<DequantizeLinear_21_20>());
0657 registerAdapter(std::make_unique<TypeRestriction>("Flatten", OpSetID(21), OpSetID(20), ir10_types_not_in_ir4));
0658 registerAdapter(std::make_unique<TypeRestriction>("Identity", OpSetID(21), OpSetID(20), ir10_types_not_in_ir9));
0659 registerAdapter(std::make_unique<TypeRestriction>("If", OpSetID(21), OpSetID(20), ir10_types_not_in_ir9));
0660 registerAdapter(std::make_unique<TypeRestriction>("Loop", OpSetID(21), OpSetID(20), ir10_types_not_in_ir9));
0661 registerAdapter(std::make_unique<TypeRestriction>("Pad", OpSetID(21), OpSetID(20), ir10_types_not_in_ir4));
0662 registerAdapter(
0663 std::make_unique<TypeRestriction>("QLinearMatMul", OpSetID(21), OpSetID(20), q_dqmm_20_unallowed_types));
0664 registerAdapter(std::make_unique<QuantizeLinear_21_20>());
0665 registerAdapter(std::make_unique<TypeRestriction>("Reshape", OpSetID(21), OpSetID(20), ir10_types_not_in_ir9));
0666 registerAdapter(std::make_unique<TypeRestriction>("Scan", OpSetID(21), OpSetID(20), ir10_types_not_in_ir9));
0667 registerAdapter(std::make_unique<TypeRestriction>("Shape", OpSetID(21), OpSetID(20), ir10_types_not_in_ir9));
0668 registerAdapter(std::make_unique<TypeRestriction>("Size", OpSetID(21), OpSetID(20), ir10_types_not_in_ir9));
0669 registerAdapter(std::make_unique<TypeRestriction>("Squeeze", OpSetID(21), OpSetID(20), ir10_types_not_in_ir4));
0670 registerAdapter(std::make_unique<TypeRestriction>("Transpose", OpSetID(21), OpSetID(20), ir10_types_not_in_ir9));
0671 registerAdapter(std::make_unique<TypeRestriction>("Unsqueeze", OpSetID(21), OpSetID(20), ir10_types_not_in_ir4));
0672
0673
0674 registerAdapter(std::make_unique<CompatibleAdapter>("EyeLike", OpSetID(21), OpSetID(22)));
0675 registerAdapter(std::make_unique<CompatibleAdapter>("RandomUniform", OpSetID(21), OpSetID(22)));
0676 registerAdapter(std::make_unique<CompatibleAdapter>("RandomNormal", OpSetID(21), OpSetID(22)));
0677 registerAdapter(std::make_unique<CompatibleAdapter>("RandomUniformLike", OpSetID(21), OpSetID(22)));
0678 registerAdapter(std::make_unique<CompatibleAdapter>("RandomNormalLike", OpSetID(21), OpSetID(22)));
0679 registerAdapter(std::make_unique<CompatibleAdapter>("Multinomial", OpSetID(21), OpSetID(22)));
0680 registerAdapter(std::make_unique<CompatibleAdapter>("Bernoulli", OpSetID(21), OpSetID(22)));
0681 registerAdapter(std::make_unique<CompatibleAdapter>("ThresholdedRelu", OpSetID(21), OpSetID(22)));
0682 registerAdapter(std::make_unique<CompatibleAdapter>("Selu", OpSetID(21), OpSetID(22)));
0683 registerAdapter(std::make_unique<CompatibleAdapter>("Elu", OpSetID(21), OpSetID(22)));
0684 registerAdapter(std::make_unique<CompatibleAdapter>("Mish", OpSetID(21), OpSetID(22)));
0685 registerAdapter(std::make_unique<CompatibleAdapter>("HardSigmoid", OpSetID(21), OpSetID(22)));
0686 registerAdapter(std::make_unique<CompatibleAdapter>("HardSwish", OpSetID(21), OpSetID(22)));
0687 registerAdapter(std::make_unique<CompatibleAdapter>("Softsign", OpSetID(21), OpSetID(22)));
0688 registerAdapter(std::make_unique<CompatibleAdapter>("Softplus", OpSetID(21), OpSetID(22)));
0689 registerAdapter(std::make_unique<CompatibleAdapter>("Sin", OpSetID(21), OpSetID(22)));
0690 registerAdapter(std::make_unique<CompatibleAdapter>("Cos", OpSetID(21), OpSetID(22)));
0691 registerAdapter(std::make_unique<CompatibleAdapter>("Tan", OpSetID(21), OpSetID(22)));
0692 registerAdapter(std::make_unique<CompatibleAdapter>("Asin", OpSetID(21), OpSetID(22)));
0693 registerAdapter(std::make_unique<CompatibleAdapter>("Acos", OpSetID(21), OpSetID(22)));
0694 registerAdapter(std::make_unique<CompatibleAdapter>("Atan", OpSetID(21), OpSetID(22)));
0695 registerAdapter(std::make_unique<CompatibleAdapter>("Sinh", OpSetID(21), OpSetID(22)));
0696 registerAdapter(std::make_unique<CompatibleAdapter>("Cosh", OpSetID(21), OpSetID(22)));
0697 registerAdapter(std::make_unique<CompatibleAdapter>("Asinh", OpSetID(21), OpSetID(22)));
0698 registerAdapter(std::make_unique<CompatibleAdapter>("Acosh", OpSetID(21), OpSetID(22)));
0699 registerAdapter(std::make_unique<CompatibleAdapter>("Atanh", OpSetID(21), OpSetID(22)));
0700 registerAdapter(std::make_unique<CompatibleAdapter>("Round", OpSetID(21), OpSetID(22)));
0701 registerAdapter(std::make_unique<CompatibleAdapter>("Det", OpSetID(21), OpSetID(22)));
0702 registerAdapter(std::make_unique<CompatibleAdapter>("NegativeLogLikelihoodLoss", OpSetID(21), OpSetID(22)));
0703 registerAdapter(std::make_unique<CompatibleAdapter>("AveragePool", OpSetID(21), OpSetID(22)));
0704 registerAdapter(std::make_unique<CompatibleAdapter>("MaxPool", OpSetID(21), OpSetID(22)));
0705 registerAdapter(std::make_unique<CompatibleAdapter>("MaxUnpool", OpSetID(21), OpSetID(22)));
0706 registerAdapter(std::make_unique<CompatibleAdapter>("LpPool", OpSetID(21), OpSetID(22)));
0707 registerAdapter(std::make_unique<CompatibleAdapter>("MaxRoiPool", OpSetID(21), OpSetID(22)));
0708 registerAdapter(std::make_unique<CompatibleAdapter>("Conv", OpSetID(21), OpSetID(22)));
0709 registerAdapter(std::make_unique<CompatibleAdapter>("ConvTranspose", OpSetID(21), OpSetID(22)));
0710 registerAdapter(std::make_unique<CompatibleAdapter>("DeformConv", OpSetID(21), OpSetID(22)));
0711 registerAdapter(std::make_unique<CompatibleAdapter>("GlobalAveragePool", OpSetID(21), OpSetID(22)));
0712 registerAdapter(std::make_unique<CompatibleAdapter>("GlobalMaxPool", OpSetID(21), OpSetID(22)));
0713 registerAdapter(std::make_unique<CompatibleAdapter>("GlobalLpPool", OpSetID(21), OpSetID(22)));
0714 registerAdapter(std::make_unique<CompatibleAdapter>("InstanceNormalization", OpSetID(21), OpSetID(22)));
0715 registerAdapter(std::make_unique<CompatibleAdapter>("LpNormalization", OpSetID(21), OpSetID(22)));
0716 registerAdapter(std::make_unique<CompatibleAdapter>("Dropout", OpSetID(21), OpSetID(22)));
0717 registerAdapter(std::make_unique<CompatibleAdapter>("RoiAlign", OpSetID(21), OpSetID(22)));
0718 registerAdapter(std::make_unique<CompatibleAdapter>("RNN", OpSetID(21), OpSetID(22)));
0719 registerAdapter(std::make_unique<CompatibleAdapter>("GRU", OpSetID(21), OpSetID(22)));
0720 registerAdapter(std::make_unique<CompatibleAdapter>("LSTM", OpSetID(21), OpSetID(22)));
0721 registerAdapter(std::make_unique<CompatibleAdapter>("GridSample", OpSetID(21), OpSetID(22)));
0722
0723
0724 const std::vector<TensorProto_DataType> bfloat16_not_allowed = {TensorProto_DataType_BFLOAT16};
0725 registerAdapter(std::make_unique<TypeRestriction>("EyeLike", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0726 registerAdapter(std::make_unique<TypeRestriction>("AveragePool", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0727 registerAdapter(std::make_unique<TypeRestriction>("MaxPool", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0728 registerAdapter(std::make_unique<TypeRestriction>("RandomUniform", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0729 registerAdapter(std::make_unique<TypeRestriction>("RandomNormal", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0730 registerAdapter(
0731 std::make_unique<TypeRestriction>("RandomNormalLike", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0732 registerAdapter(
0733 std::make_unique<TypeRestriction>("RandomUniformLike", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0734 registerAdapter(std::make_unique<TypeRestriction>("Multinomial", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0735 registerAdapter(std::make_unique<TypeRestriction>("Bernoulli", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0736 registerAdapter(
0737 std::make_unique<TypeRestriction>("ThresholdedRelu", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0738 registerAdapter(std::make_unique<TypeRestriction>("Selu", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0739 registerAdapter(std::make_unique<TypeRestriction>("Elu", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0740 registerAdapter(std::make_unique<TypeRestriction>("Mish", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0741 registerAdapter(std::make_unique<TypeRestriction>("HardSigmoid", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0742 registerAdapter(std::make_unique<TypeRestriction>("HardSwish", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0743 registerAdapter(std::make_unique<TypeRestriction>("Softsign", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0744 registerAdapter(std::make_unique<TypeRestriction>("Softplus", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0745 registerAdapter(std::make_unique<TypeRestriction>("Sin", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0746 registerAdapter(std::make_unique<TypeRestriction>("Cos", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0747 registerAdapter(std::make_unique<TypeRestriction>("Tan", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0748 registerAdapter(std::make_unique<TypeRestriction>("Asin", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0749 registerAdapter(std::make_unique<TypeRestriction>("Acos", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0750 registerAdapter(std::make_unique<TypeRestriction>("Atan", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0751 registerAdapter(std::make_unique<TypeRestriction>("Sinh", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0752 registerAdapter(std::make_unique<TypeRestriction>("Cosh", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0753 registerAdapter(std::make_unique<TypeRestriction>("Asinh", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0754 registerAdapter(std::make_unique<TypeRestriction>("Acosh", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0755 registerAdapter(std::make_unique<TypeRestriction>("Atanh", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0756 registerAdapter(std::make_unique<TypeRestriction>("Round", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0757 registerAdapter(std::make_unique<TypeRestriction>("Det", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0758 registerAdapter(
0759 std::make_unique<TypeRestriction>("NegativeLogLikelihoodLoss", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0760 registerAdapter(std::make_unique<TypeRestriction>("MaxUnpool", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0761 registerAdapter(std::make_unique<TypeRestriction>("LpPool", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0762 registerAdapter(std::make_unique<TypeRestriction>("MaxRoiPool", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0763 registerAdapter(std::make_unique<TypeRestriction>("Conv", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0764 registerAdapter(std::make_unique<TypeRestriction>("ConvTranspose", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0765 registerAdapter(std::make_unique<TypeRestriction>("DeformConv", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0766 registerAdapter(
0767 std::make_unique<TypeRestriction>("GlobalAveragePool", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0768 registerAdapter(std::make_unique<TypeRestriction>("GlobalLpPool", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0769 registerAdapter(
0770 std::make_unique<TypeRestriction>("InstanceNormalization", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0771 registerAdapter(
0772 std::make_unique<TypeRestriction>("LpNormalization", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0773 registerAdapter(std::make_unique<TypeRestriction>("Dropout", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0774 registerAdapter(std::make_unique<TypeRestriction>("RoiAlign", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0775 registerAdapter(std::make_unique<TypeRestriction>("RNN", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0776 registerAdapter(std::make_unique<TypeRestriction>("GRU", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0777 registerAdapter(std::make_unique<TypeRestriction>("LSTM", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0778 registerAdapter(std::make_unique<TypeRestriction>("GridSample", OpSetID(22), OpSetID(21), bfloat16_not_allowed));
0779 }
0780
0781 ModelProto convert_version(const ModelProto& mp_in, const OpSetID& initial_version, const OpSetID& target_version)
0782 const override;
0783 };
0784
0785 ModelProto ConvertVersion(const ModelProto& mp_in, int target_version);
0786 }
0787 }