|
15 | 15 | from aie.extras.context import mlir_mod_ctx |
16 | 16 | from .compile import compile_mlir_module, compile_external_kernel |
17 | 17 | from .npukernel import NPUKernel |
18 | | -from aie.dialects.aie import AIEDevice |
19 | 18 | from .compile.cache.circular_cache import CircularCache |
20 | 19 | from .compile.cache.utils import _create_function_cache_key, file_lock |
21 | 20 | from .compile import NPU_CACHE_HOME |
@@ -48,8 +47,10 @@ def jit(function=None, use_cache=True): |
48 | 47 |
|
49 | 48 | @functools.wraps(function) |
50 | 49 | def decorator(*args, **kwargs): |
51 | | - from aie.iron.device import NPU1, NPU2, NPU1Col1, NPU2Col1 |
| 50 | + from aie.iron.device import Device |
52 | 51 | from aie.iron.kernel import ExternalFunction |
| 52 | + from aie.dialects._aie_enum_gen import AIEArch |
| 53 | + from aie.dialects.aie import get_target_model |
53 | 54 | from . import DefaultNPURuntime |
54 | 55 |
|
55 | 56 | if DefaultNPURuntime is None: |
@@ -118,17 +119,17 @@ def decorator(*args, **kwargs): |
118 | 119 |
|
119 | 120 | current_device = DefaultNPURuntime.device() |
120 | 121 |
|
121 | | - # Determine target architecture based on device type |
122 | | - if isinstance(current_device, (NPU2, NPU2Col1)): |
123 | | - target_arch = "aie2p" |
124 | | - elif isinstance(current_device, (NPU1, NPU1Col1)): |
125 | | - target_arch = "aie2" |
126 | | - elif current_device in (AIEDevice.npu2, AIEDevice.npu2_1col): |
| 122 | + # Determine target architecture from the device's target model. |
| 123 | + if isinstance(current_device, Device): |
| 124 | + arch = current_device.arch |
| 125 | + else: |
| 126 | + arch = AIEArch(get_target_model(current_device).get_target_arch()) |
| 127 | + if arch == AIEArch.AIE2p: |
127 | 128 | target_arch = "aie2p" |
128 | | - elif current_device in (AIEDevice.npu1, AIEDevice.npu1_1col): |
| 129 | + elif arch == AIEArch.AIE2: |
129 | 130 | target_arch = "aie2" |
130 | 131 | else: |
131 | | - raise RuntimeError(f"Unsupported device type: {type(current_device)}") |
| 132 | + raise RuntimeError(f"Unsupported device arch: {arch}") |
132 | 133 |
|
133 | 134 | # Hash of the IR string, ExternalFunction compiler options, and target architecture |
134 | 135 | module_hash = hash_module(mlir_module, external_kernels, target_arch) |
|
0 commit comments