|
11 | 11 |
|
12 | 12 | from . import ir |
13 | 13 | from .passmanager import PassManager |
14 | | -from ._mlir_libs._stablehlo import serialize_portable_artifact |
| 14 | +from ._mlir_libs._stablehlo import serialize_portable_artifact, get_current_version |
15 | 15 |
|
16 | 16 | from .extra_shape_fn import byteir_extra_library |
17 | 17 |
|
@@ -259,8 +259,13 @@ def compile( |
259 | 259 | ############################################ |
260 | 260 | # serialize stablehlo to target version |
261 | 261 | ############################################ |
| 262 | + from packaging import version |
| 263 | + target_version = version.Version(output_type.split("+")[1]) |
| 264 | + current_version = version.Version(get_current_version()) |
| 265 | + if target_version > current_version: |
| 266 | + target_version = current_version |
262 | 267 | return serialize_portable_artifact( |
263 | | - module.operation.get_asm(), output_type.split("+")[1] |
| 268 | + module.operation.get_asm(), str(target_version) |
264 | 269 | ) |
265 | 270 |
|
266 | 271 |
|
@@ -380,6 +385,11 @@ def compile_dynamo_model( |
380 | 385 | ############################################ |
381 | 386 | # serialize stablehlo to target version |
382 | 387 | ############################################ |
| 388 | + from packaging import version |
| 389 | + target_version = version.Version(output_type.split("+")[1]) |
| 390 | + current_version = version.Version(get_current_version()) |
| 391 | + if target_version > current_version: |
| 392 | + target_version = current_version |
383 | 393 | return serialize_portable_artifact( |
384 | | - module.operation.get_asm(), output_type.split("+")[1] |
| 394 | + module.operation.get_asm(), str(target_version) |
385 | 395 | ) |
0 commit comments