Skip to content

Commit 189c863

Browse files
authored
Merge pull request #436 from Xilinx/jrickert.version_warning
Make old opset warning based on newest version in opset range, not oldest
2 parents 5d2f70f + 1289209 commit 189c863

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

src/Builder/FrontendDialectTransformer.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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() << "\nWarning: 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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
// RUN: onnx-mlir --EmitONNXBasic --printIR %s 2>&1 | FileCheck %s
3+
4+
// COM: GlobalAveragePool was introduced in opset 1 and updated in opset 22. Make sure we do not print a warning for old versions in opsets in between.
5+
<
6+
ir_version: 4,
7+
opset_import: ["" : 14]
8+
>
9+
main (float[1,192,35,35] in0) => (float[1,192,1,1] out0) {
10+
out0 = GlobalAveragePool(in0)
11+
}
12+
13+
// CHECK-NOT: Warning
14+
// CHECK-NOT: which is quite old

0 commit comments

Comments
 (0)