@@ -1296,7 +1296,7 @@ class FrontendGenImpl {
12961296 // To determine the opset version for a node/op:
12971297 // 1: Determine the latest valid opset version. This is the newest version
12981298 // in this opset-version-map that is older or equal to the current graph
1299- // opset. 2:_ Select the newest version from the versions supported by
1299+ // opset. 2: Select the newest version from the versions supported by
13001300 // onnx-mlir that is equal or newer to the latest valid opset version. This
13011301 // allows it to skip over opset versions, that have a newer backwards
13021302 // compatible version.
@@ -1312,9 +1312,15 @@ class FrontendGenImpl {
13121312 // Get the newest opset version for the op that is older or equal to the
13131313 // model opset version. Use the oldest version as fallback
13141314 int newestValidOpsetVersion = opset_list_it->second .back ();
1315- for (int opset : opset_list_it->second ) {
1316- if (opset <= current_opset) {
1317- newestValidOpsetVersion = opset;
1315+ int upperRangeOfNewestValidOpsetVersion = current_opset;
1316+ for (auto opsetIter = opset_list_it->second .begin ();
1317+ opsetIter != opset_list_it->second .end (); ++opsetIter) {
1318+ if (*opsetIter <= current_opset) {
1319+ if (opsetIter != opset_list_it->second .begin ()) {
1320+ upperRangeOfNewestValidOpsetVersion = std::max (
1321+ upperRangeOfNewestValidOpsetVersion, *(opsetIter - 1 ) - 1 );
1322+ }
1323+ newestValidOpsetVersion = *opsetIter;
13181324 break ;
13191325 }
13201326 }
@@ -1324,11 +1330,11 @@ class FrontendGenImpl {
13241330 // A new opset is added to onnx-mlir when it becomes incompatible.
13251331 // All opset newest than the last opset should use the last opset(version)
13261332 if (isDefaultDomain (node.domain ()) &&
1327- newestValidOpsetVersion < supported_opset_list.back () &&
1328- newestValidOpsetVersion < MINIMUM_SUPPORTED_OPSET)
1333+ upperRangeOfNewestValidOpsetVersion < supported_opset_list.back () &&
1334+ upperRangeOfNewestValidOpsetVersion < MINIMUM_SUPPORTED_OPSET)
13291335 llvm::errs () << " \n Warning: ONNX " << node.op_type ()
13301336 << " in your model is using Opset "
1331- << newestValidOpsetVersion
1337+ << upperRangeOfNewestValidOpsetVersion
13321338 << " , which is quite old. Please consider regenerating your "
13331339 " model with a newer Opset.\n\n " ;
13341340
0 commit comments