Merged
feat(pypto_pro): replace internal 'a5' with NPUArch enum #6781
LiwenerAdd on Sep 30
feat(pypto_pro): replace internal 'a5' with NPUArch enum #6781
Merged
Merged fromm0_55221889/pypto9.2.0intocann/pypto9.2.0
Total: 72 files changed+637-401
| @@ -29,12 +29,12 @@ sanitizer默认为False,不开启时,Kernel的编译和执行行为完全不 | |||
| 29 | 29 | ||
| 30 | ### 检测报告说明 | 30 | ### 检测报告说明 |
| 31 | 31 | ||
| 32 | -报告文件中每段结果以kernel标签行开头,括号内为该次启动所用kernel的编译产物目录,如`(./build/view_over_source_kernel__a5__d0/tk_none)`。同名kernel存在多个编译实例(不同TilingKey、数据类型或设备)时,该目录用于区分检测结果来自哪个实例;该目录下同时有检测结果文件`pypto_sanitizer_report.txt`和原始记录`sanitizer_report.bin`。 | 32 | +报告文件中每段结果以kernel标签行开头,括号内为该次启动所用kernel的编译产物目录,如`(./build/view_over_source_kernel__3510__d0/tk_none)`。同名kernel存在多个编译实例(不同TilingKey、数据类型或设备)时,该目录用于区分检测结果来自哪个实例;该目录下同时有检测结果文件`pypto_sanitizer_report.txt`和原始记录`sanitizer_report.bin`。 |
| 33 | 33 | ||
| 34 | 每段结果先给出检出数量,再逐条列出检出项,以GM访问越界为例: | 34 | 每段结果先给出检出数量,再逐条列出检出项,以GM访问越界为例: |
| 35 | 35 | ||
| 36 | ```text | 36 | ```text |
| 37 | -===== kernel 'oob_kernel' (./build/oob_kernel__a5__d0/tk_none) ===== | 37 | +===== kernel 'oob_kernel' (./build/oob_kernel__3510__d0/tk_none) ===== |
| 38 | PyPTO Sanitizer: 1 issue(s) detected | 38 | PyPTO Sanitizer: 1 issue(s) detected |
| 39 | [1/1] GM_OUT_OF_BOUNDS: offsets [32, 0] + valid_shape [64, 64] exceed tensor shape (64, 64) — dim0: offset 32 + valid_shape 64 = 96 > 64 (over by 32) at demo.py:68 | 39 | [1/1] GM_OUT_OF_BOUNDS: offsets [32, 0] + valid_shape [64, 64] exceed tensor shape (64, 64) — dim0: offset 32 + valid_shape 64 = 96 > 64 (over by 32) at demo.py:68 |
| 40 | Hint: The tile valid_shape plus the loop offsets must stay inside the tensor logical shape on every dimension | 40 | Hint: The tile valid_shape plus the loop offsets must stay inside the tensor logical shape on every dimension |
| @@ -78,7 +78,7 @@ def oob_kernel(x: pypto_pro.language.Tensor[[64, 64], pypto_pro.language.DT_FP16 | |||
| 78 | ``` | 78 | ``` |
| 79 | 79 | ||
| 80 | ```text | 80 | ```text |
| 81 | -===== kernel 'oob_kernel' (./build/oob_kernel__a5__d0/tk_none) ===== | 81 | +===== kernel 'oob_kernel' (./build/oob_kernel__3510__d0/tk_none) ===== |
| 82 | PyPTO Sanitizer: 1 issue(s) detected | 82 | PyPTO Sanitizer: 1 issue(s) detected |
| 83 | [1/1] GM_OUT_OF_BOUNDS: offsets [32, 0] + valid_shape [64, 64] exceed tensor shape (64, 64) — dim0: offset 32 + valid_shape 64 = 96 > 64 (over by 32) at demo.py:68 | 83 | [1/1] GM_OUT_OF_BOUNDS: offsets [32, 0] + valid_shape [64, 64] exceed tensor shape (64, 64) — dim0: offset 32 + valid_shape 64 = 96 > 64 (over by 32) at demo.py:68 |
| 84 | Hint: The tile valid_shape plus the loop offsets must stay inside the tensor logical shape on every dimension | 84 | Hint: The tile valid_shape plus the loop offsets must stay inside the tensor logical shape on every dimension |
| @@ -104,7 +104,7 @@ def gm_scalar_oob_kernel(out: pypto_pro.language.Tensor[[64], pypto_pro.language | |||
| 104 | ``` | 104 | ``` |
| 105 | 105 | ||
| 106 | ```text | 106 | ```text |
| 107 | -===== kernel 'gm_scalar_oob_kernel' (./build/gm_scalar_oob_kernel__a5__d0/tk_none) ===== | 107 | +===== kernel 'gm_scalar_oob_kernel' (./build/gm_scalar_oob_kernel__3510__d0/tk_none) ===== |
| 108 | PyPTO Sanitizer: 1 issue(s) detected | 108 | PyPTO Sanitizer: 1 issue(s) detected |
| 109 | [1/1] GM_OUT_OF_BOUNDS: scalar access at linear offset 64 exceeds 64 elements at demo.py:17 | 109 | [1/1] GM_OUT_OF_BOUNDS: scalar access at linear offset 64 exceeds 64 elements at demo.py:17 |
| 110 | Hint: getval/setval offsets must stay inside the tensor element count | 110 | Hint: getval/setval offsets must stay inside the tensor element count |
| @@ -126,7 +126,7 @@ t2 = pypto_pro.language.make_tensor(x, [200, 200]) | |||
| 126 | ``` | 126 | ``` |
| 127 | 127 | ||
| 128 | ```text | 128 | ```text |
| 129 | -===== kernel 'view_over_source_kernel' (./build/view_over_source_kernel__a5__d0/tk_none) ===== | 129 | +===== kernel 'view_over_source_kernel' (./build/view_over_source_kernel__3510__d0/tk_none) ===== |
| 130 | PyPTO Sanitizer: 1 issue(s) detected | 130 | PyPTO Sanitizer: 1 issue(s) detected |
| 131 | [1/1] GM_OUT_OF_BOUNDS: make_tensor view [200, 200] covers 80000 bytes, source tensor [128, 128] holds 32768 bytes at demo.py:1255 | 131 | [1/1] GM_OUT_OF_BOUNDS: make_tensor view [200, 200] covers 80000 bytes, source tensor [128, 128] holds 32768 bytes at demo.py:1255 |
| 132 | Hint: A view shares its source's storage; keep its shape/stride size within the source | 132 | Hint: A view shares its source's storage; keep its shape/stride size within the source |
| @@ -154,7 +154,7 @@ pypto_pro.language.move(a_l0a, cur_a, offset=[32, 0]) | |||
| 154 | ``` | 154 | ``` |
| 155 | 155 | ||
| 156 | ```text | 156 | ```text |
| 157 | -===== kernel 'tile_move_offset_oob_kernel' (./build/tile_move_offset_oob_kernel__a5__d0/tk_none) ===== | 157 | +===== kernel 'tile_move_offset_oob_kernel' (./build/tile_move_offset_oob_kernel__3510__d0/tk_none) ===== |
| 158 | PyPTO Sanitizer: 1 issue(s) detected | 158 | PyPTO Sanitizer: 1 issue(s) detected |
| 159 | [1/1] TILE_OUT_OF_BOUNDS: offsets [32, 0] + valid_shape [64, 64] exceed tile shape [64, 64] — dim0: offset 32 + valid_shape 64 = 96 > 64 (over by 32) at demo.py:227 | 159 | [1/1] TILE_OUT_OF_BOUNDS: offsets [32, 0] + valid_shape [64, 64] exceed tile shape [64, 64] — dim0: offset 32 + valid_shape 64 = 96 > 64 (over by 32) at demo.py:227 |
| 160 | Hint: Keep the tile's valid shape within the declared TileType dims | 160 | Hint: Keep the tile's valid shape within the declared TileType dims |
| @@ -176,7 +176,7 @@ pypto_pro.language.insert(dst, src, offset=[96, 0]) | |||
| 176 | ``` | 176 | ``` |
| 177 | 177 | ||
| 178 | ```text | 178 | ```text |
| 179 | -===== kernel 'insert_oob_kernel' (./build/insert_oob_kernel__a5__d0/tk_none) ===== | 179 | +===== kernel 'insert_oob_kernel' (./build/insert_oob_kernel__3510__d0/tk_none) ===== |
| 180 | PyPTO Sanitizer: 1 issue(s) detected | 180 | PyPTO Sanitizer: 1 issue(s) detected |
| 181 | [1/1] TILE_OUT_OF_BOUNDS: offsets [96, 0] + valid_shape [64, 64] exceed tile shape [128, 64] — dim0: offset 96 + valid_shape 64 = 160 > 128 (over by 32) at demo.py:64 | 181 | [1/1] TILE_OUT_OF_BOUNDS: offsets [96, 0] + valid_shape [64, 64] exceed tile shape [128, 64] — dim0: offset 96 + valid_shape 64 = 160 > 128 (over by 32) at demo.py:64 |
| 182 | Hint: Keep the tile's valid shape within the declared TileType dims | 182 | Hint: Keep the tile's valid shape within the declared TileType dims |
| @@ -201,7 +201,7 @@ pypto_pro.language.store(out, t, [0, 0]) | |||
| 201 | ``` | 201 | ``` |
| 202 | 202 | ||
| 203 | ```text | 203 | ```text |
| 204 | -===== kernel 'validshape_oob_kernel' (./build/validshape_oob_kernel__a5__d0/tk_none) ===== | 204 | +===== kernel 'validshape_oob_kernel' (./build/validshape_oob_kernel__3510__d0/tk_none) ===== |
| 205 | PyPTO Sanitizer: 3 issue(s) detected | 205 | PyPTO Sanitizer: 3 issue(s) detected |
| 206 | [1/3] GM_OUT_OF_BOUNDS: offsets [0, 0] + valid_shape [65, 64] exceed tensor shape (64, 64) — dim0: offset 0 + valid_shape 65 = 65 > 64 (over by 1) at demo.py:46 | 206 | [1/3] GM_OUT_OF_BOUNDS: offsets [0, 0] + valid_shape [65, 64] exceed tensor shape (64, 64) — dim0: offset 0 + valid_shape 65 = 65 > 64 (over by 1) at demo.py:46 |
| 207 | Hint: The tile valid_shape plus the loop offsets must stay inside the tensor logical shape on every dimension | 207 | Hint: The tile valid_shape plus the loop offsets must stay inside the tensor logical shape on every dimension |
| @@ -228,7 +228,7 @@ pypto_pro.language.setval(out, 0, pypto_pro.language.getval(t, 4096)) | |||
| 228 | ``` | 228 | ``` |
| 229 | 229 | ||
| 230 | ```text | 230 | ```text |
| 231 | -===== kernel 'tile_scalar_oob_kernel' (./build/tile_scalar_oob_kernel__a5__d0/tk_none) ===== | 231 | +===== kernel 'tile_scalar_oob_kernel' (./build/tile_scalar_oob_kernel__3510__d0/tk_none) ===== |
| 232 | PyPTO Sanitizer: 1 issue(s) detected | 232 | PyPTO Sanitizer: 1 issue(s) detected |
| 233 | [1/1] TILE_OUT_OF_BOUNDS: scalar tile access at linear offset 4096 exceeds 4096 elements (dims [64,64]) at demo.py:31 | 233 | [1/1] TILE_OUT_OF_BOUNDS: scalar tile access at linear offset 4096 exceeds 4096 elements (dims [64,64]) at demo.py:31 |
| 234 | Hint: getval/setval offsets must stay inside the tile element count | 234 | Hint: getval/setval offsets must stay inside the tile element count |
| @@ -252,7 +252,7 @@ tb = tb_group.current() | |||
| 252 | ``` | 252 | ``` |
| 253 | 253 | ||
| 254 | ```text | 254 | ```text |
| 255 | -===== kernel 'overlap_kernel' (./build/overlap_kernel__a5__d0/tk_none) ===== | 255 | +===== kernel 'overlap_kernel' (./build/overlap_kernel__3510__d0/tk_none) ===== |
| 256 | PyPTO Sanitizer: 1 issue(s) detected | 256 | PyPTO Sanitizer: 1 issue(s) detected |
| 257 | [1/1] TILE_OVERLAP: tile range [Vec 0x0, 0x2000) overlaps another tile [Vec 0x1000, 0x3000) at demo.py:124 | 257 | [1/1] TILE_OVERLAP: tile range [Vec 0x0, 0x2000) overlaps another tile [Vec 0x1000, 0x3000) at demo.py:124 |
| 258 | Hint: Two tiles must not share on-chip address space | 258 | Hint: Two tiles must not share on-chip address space |
| @@ -276,7 +276,7 @@ pypto_pro.language.system.mutex_unlock(mutex_id=7, pipe=pypto_pro.language.PipeT | |||
| 276 | ``` | 276 | ``` |
| 277 | 277 | ||
| 278 | ```text | 278 | ```text |
| 279 | -===== kernel 'mutex_unlock_before_lock_kernel' (./build/mutex_unlock_before_lock_kernel__a5__d0/tk_none) ===== | 279 | +===== kernel 'mutex_unlock_before_lock_kernel' (./build/mutex_unlock_before_lock_kernel__3510__d0/tk_none) ===== |
| 280 | PyPTO Sanitizer: 1 issue(s) detected | 280 | PyPTO Sanitizer: 1 issue(s) detected |
| 281 | [1/1] MUTEX_UNLOCK_BEFORE_LOCK: mutex_unlock(mutex_id=7, pipe=MTE2, region=1) without a preceding mutex_lock at demo.py:705 | 281 | [1/1] MUTEX_UNLOCK_BEFORE_LOCK: mutex_unlock(mutex_id=7, pipe=MTE2, region=1) without a preceding mutex_lock at demo.py:705 |
| 282 | Hint: Every mutex_unlock must be paired with a mutex_lock on the same (region, mutex_id, pipe) | 282 | Hint: Every mutex_unlock must be paired with a mutex_lock on the same (region, mutex_id, pipe) |
| @@ -47,7 +47,7 @@ def transform( | |||
| 47 | ```python | 47 | ```python |
| 48 | import pypto_pro.language as pl | 48 | import pypto_pro.language as pl |
| 49 | 49 | ||
| 50 | -@pl.jit(arch="a5") | 50 | +@pl.jit(arch="3510") |
| 51 | def transform_kernel( | 51 | def transform_kernel( |
| 52 | input_tensor: pl.Tensor[[1, ELEMENTS], pl.DT_FP32], | 52 | input_tensor: pl.Tensor[[1, ELEMENTS], pl.DT_FP32], |
| 53 | output: pl.Tensor[[1, ELEMENTS], pl.DT_FP32], | 53 | output: pl.Tensor[[1, ELEMENTS], pl.DT_FP32], |
| @@ -63,7 +63,7 @@ max_threads声明单个线程块的上限,threads指定本次调用的实际 | |||
| 63 | 63 | ||
| 64 | ### 从Host启动外层Kernel | 64 | ### 从Host启动外层Kernel |
| 65 | 65 | ||
| 66 | -在A5环境中,通过Host启动外层jit kernel函数: | 66 | +通过Host启动外层jit kernel函数: |
| 67 | 67 | ||
| 68 | ```python | 68 | ```python |
| 69 | import torch | 69 | import torch |
| @@ -201,7 +201,7 @@ def gather_rows( | |||
| 201 | output[row, col] = input_tensor[input_row, col] | 201 | output[row, col] = input_tensor[input_row, col] |
| 202 | 202 | ||
| 203 | 203 | ||
| 204 | -@pl.jit(arch="a5") | 204 | +@pl.jit(arch="3510") |
| 205 | def gather_kernel( | 205 | def gather_kernel( |
| 206 | input_tensor: pl.Tensor[[INPUT_ROWS, WIDTH], pl.DT_FP32], | 206 | input_tensor: pl.Tensor[[INPUT_ROWS, WIDTH], pl.DT_FP32], |
| 207 | indices: pl.Tensor[[1, OUTPUT_ROWS], pl.DT_INT32], | 207 | indices: pl.Tensor[[1, OUTPUT_ROWS], pl.DT_INT32], |
| @@ -222,7 +222,7 @@ gather_kernel[None, BLOCKS](input_tensor, indices, output, OUTPUT_ROWS) | |||
| 222 | 222 | ||
| 223 | ## 当前能力边界 | 223 | ## 当前能力边界 |
| 224 | 224 | ||
| 225 | -- SIMT入口必须由外层A5 Vector执行域调用,不支持Host直接启动SIMT函数或在SIMT函数中嵌套调用SIMT入口函数。 | 225 | +- SIMT入口必须由外层Vector执行域调用,不支持Host直接启动SIMT函数或在SIMT函数中嵌套调用SIMT入口函数。 |
| 226 | - SIMT中不支持Tile创建、SIMD Tile计算、Reg计算或System流水操作。 | 226 | - SIMT中不支持Tile创建、SIMD Tile计算、Reg计算或System流水操作。 |
| 227 | - 不支持动态GM Shape、Tile Subview、L1 Buffer Tile、DN/NZ布局和通用指针参数。 | 227 | - 不支持动态GM Shape、Tile Subview、L1 Buffer Tile、DN/NZ布局和通用指针参数。 |
| 228 | - 未提供Warp shuffle/vote/reduce、线程私有数组和显式Cached GM访问接口。 | 228 | - 未提供Warp shuffle/vote/reduce、线程私有数组和显式Cached GM访问接口。 |
| @@ -47,7 +47,7 @@ $$ | |||
| 47 | 47 | ||
| 48 | ### Warp执行与分支 | 48 | ### Warp执行与分支 |
| 49 | 49 | ||
| 50 | -Warp是硬件在线程块内组织执行的单位,当前A5的Warp Size为32,线程按块内线性编号划分到Warp;线程总数不是32的整数倍时,最后一个Warp只有部分线程有效。 | 50 | +Warp是硬件在线程块内组织执行的单位,Warp Size为32,线程按块内线性编号划分到Warp;线程总数不是32的整数倍时,最后一个Warp只有部分线程有效。 |
| 51 | 51 | ||
| 52 | 同一Warp中的线程可以根据数据进入不同分支,但分支发散会降低执行效率,线程数取32的整数倍是可考虑的性能选择。 | 52 | 同一Warp中的线程可以根据数据进入不同分支,但分支发散会降低执行效率,线程数取32的整数倍是可考虑的性能选择。 |
| 53 | 53 | ||
| @@ -90,7 +90,7 @@ def copy_by_index( | |||
| 90 | output[0, global_idx] = source[0, global_idx] | 90 | output[0, global_idx] = source[0, global_idx] |
| 91 | 91 | ||
| 92 | 92 | ||
| 93 | -@pl.jit(arch="a5") | 93 | +@pl.jit(arch="3510") |
| 94 | def copy_kernel( | 94 | def copy_kernel( |
| 95 | source: pl.Tensor[[1, 24], pl.DT_FP32], | 95 | source: pl.Tensor[[1, 24], pl.DT_FP32], |
| 96 | output: pl.Tensor[[1, 24], pl.DT_FP32], | 96 | output: pl.Tensor[[1, 24], pl.DT_FP32], |
| @@ -122,7 +122,7 @@ PyPTO Pro支持SIMT入口函数和SIMT辅助函数。入口函数描述Thread Bl | |||
| 122 | | SIMT入口函数 | @pypto_pro.language.vector_function(mode="simt", max_threads=N) | 定义每个Thread执行的完整计算,结果写入传入的Tile或Tensor。 | 由外层JIT Kernel通过`simt_func[threads](...)`调用。 | | 122 | | SIMT入口函数 | @pypto_pro.language.vector_function(mode="simt", max_threads=N) | 定义每个Thread执行的完整计算,结果写入传入的Tile或Tensor。 | 由外层JIT Kernel通过`simt_func[threads](...)`调用。 | |
| 123 | | SIMT辅助函数 | @pypto_pro.language.vector_function(mode="simt") | 封装可复用的逐Thread计算,可以不返回值或返回一个Scalar。 | 由SIMT入口函数或其他辅助函数调用。 | | 123 | | SIMT辅助函数 | @pypto_pro.language.vector_function(mode="simt") | 封装可复用的逐Thread计算,可以不返回值或返回一个Scalar。 | 由SIMT入口函数或其他辅助函数调用。 | |
| 124 | 124 | ||
| 125 | -Host先启动外层@pypto_pro.language.jit(arch="a5") Kernel,再由外层Kernel在Vector执行域中启动SIMT入口函数;入口函数可以继续调用辅助函数。辅助函数在调用它的线程中执行,不创建新线程。具体定义和调用方式见[SIMT计算](../../development/vector_computation/simt_computation.md)。 | 125 | +Host先启动外层@pypto_pro.language.jit(arch="3510") Kernel,再由外层Kernel在Vector执行域中启动SIMT入口函数;入口函数可以继续调用辅助函数。辅助函数在调用它的线程中执行,不创建新线程。具体定义和调用方式见[SIMT计算](../../development/vector_computation/simt_computation.md)。 |
| 126 | 126 | ||
| 127 | **图2 SIMD/SIMT混合模式启动关系** | 127 | **图2 SIMD/SIMT混合模式启动关系** |
| 128 | 128 | ||
| @@ -79,7 +79,7 @@ THREADS = 256 | |||
| 79 | 与SIMD版相同,Kernel先分配片上Tile Group,再在Vector段完成数据搬入、计算和数据搬出。输入与输出Tile各占1024字节;归约状态Tile占32字节,其中前两个FP32元素分别保存最大值与指数和。三个Tile Group使用互不重叠的片上地址和不同的Mutex ID。 | 79 | 与SIMD版相同,Kernel先分配片上Tile Group,再在Vector段完成数据搬入、计算和数据搬出。输入与输出Tile各占1024字节;归约状态Tile占32字节,其中前两个FP32元素分别保存最大值与指数和。三个Tile Group使用互不重叠的片上地址和不同的Mutex ID。 |
| 80 | 80 | ||
| 81 | ```python | 81 | ```python |
| 82 | - @pl.jit(arch="a5", auto_mutex=True) | 82 | + @pl.jit(arch="3510", auto_mutex=True) |
| 83 | def softmax_simt_kernel( | 83 | def softmax_simt_kernel( |
| 84 | src: pl.Tensor[[1, THREADS], pl.DT_FP32], | 84 | src: pl.Tensor[[1, THREADS], pl.DT_FP32], |
| 85 | dst: pl.Tensor[[1, THREADS], pl.DT_FP32], | 85 | dst: pl.Tensor[[1, THREADS], pl.DT_FP32], |
| @@ -35,6 +35,7 @@ | |||
| 35 | #include "ir/scalar_expr_ops.h" | 35 | #include "ir/scalar_expr_ops.h" |
| 36 | #include "ir/stmt.h" | 36 | #include "ir/stmt.h" |
| 37 | #include "ir/type.h" | 37 | #include "ir/type.h" |
| 38 | +#include "tilefwk/platform.h" | ||
| 38 | 39 | ||
| 39 | namespace pypto { | 40 | namespace pypto { |
| 40 | 41 | ||
| @@ -124,7 +125,7 @@ public: | |||
| 124 | * \param program The IR Program to generate code for | 125 | * \param program The IR Program to generate code for |
| 125 | * \return Generated C++ code as a single string | 126 | * \return Generated C++ code as a single string |
| 126 | */ | 127 | */ |
| 127 | - [[nodiscard]] std::string GenerateSingle(const ir::ProgramPtr& program, const std::string& arch); | 128 | + [[nodiscard]] std::string GenerateSingle(const ir::ProgramPtr& program, npu::tile_fwk::NPUArch arch); |
| 128 | 129 | ||
| 129 | /** | 130 | /** |
| 130 | * \brief Tiling struct headers generated by the last GenerateSingle call. | 131 | * \brief Tiling struct headers generated by the last GenerateSingle call. |
| @@ -165,7 +166,7 @@ public: | |||
| 165 | const TypeConverter& GetTypeConverter() const { return type_converter_; } | 166 | const TypeConverter& GetTypeConverter() const { return type_converter_; } |
| 166 | 167 | ||
| 167 | /** \brief Get the target architecture */ | 168 | /** \brief Get the target architecture */ |
| 168 | - const std::string& GetArch() const { return arch_; } | 169 | + npu::tile_fwk::NPUArch GetArch() const { return arch_; } |
| 169 | 170 | ||
| 170 | /** \brief Get the fixed Cube/Vector target selected for this generation. */ | 171 | /** \brief Get the fixed Cube/Vector target selected for this generation. */ |
| 171 | ir::SectionKind GetTarget() const { return target_; } | 172 | ir::SectionKind GetTarget() const { return target_; } |
| @@ -579,13 +580,13 @@ private: | |||
| 579 | std::map<std::string, std::string> tiling_headers_; ///< Tiling struct headers (filename -> content) | 580 | std::map<std::string, std::string> tiling_headers_; ///< Tiling struct headers (filename -> content) |
| 580 | std::map<std::string, StructDefinition> struct_definitions_; ///< Struct type name ->definition | 581 | std::map<std::string, StructDefinition> struct_definitions_; ///< Struct type name ->definition |
| 581 | 582 | ||
| 582 | - CodeEmitter emitter_; ///< Code emitter for structured output | 583 | + CodeEmitter emitter_; ///< Code emitter for structured output |
| 583 | - CodeContext context_; ///< Context for variable tracking | 584 | + CodeContext context_; ///< Context for variable tracking |
| 584 | - TypeConverter type_converter_; ///< Type converter | 585 | + TypeConverter type_converter_; ///< Type converter |
| 585 | - const backend::Backend* backend_; ///< CCE backend instance (for op info, core type) | 586 | + const backend::Backend* backend_; ///< CCE backend instance (for op info, core type) |
| 586 | - std::string arch_ = "a3"; ///< Target architecture ("a2", "a3", "a5") | 587 | + npu::tile_fwk::NPUArch arch_ = npu::tile_fwk::NPUArch::DAV_2201; ///< Target architecture |
| 587 | - const ir::SectionKind target_; ///< Fixed Cube/Vector target for this generator | 588 | + const ir::SectionKind target_; ///< Fixed Cube/Vector target for this generator |
| 588 | - bool in_vf_section_ = false; ///< True only while emitting a nested VF section | 589 | + bool in_vf_section_ = false; ///< True only while emitting a nested VF section |
| 589 | ir::FunctionType current_function_type_ = ir::FunctionType::OPAQUE; | 590 | ir::FunctionType current_function_type_ = ir::FunctionType::OPAQUE; |
| 590 | std::map<std::string, ir::FunctionPtr> simt_callees_; | 591 | std::map<std::string, ir::FunctionPtr> simt_callees_; |
| 591 | std::unordered_map<std::string, std::string> tensor_to_pointer_; ///< Tensor var name ->raw pointer expression | 592 | std::unordered_map<std::string, std::string> tensor_to_pointer_; ///< Tensor var name ->raw pointer expression |
| @@ -655,5 +655,5 @@ inline constexpr char kMemorySpaceAcc[] = "Acc"; | |||
| 655 | // Buffer capacity (bytes) of ``space`` for ``arch``, read from the platform | 655 | // Buffer capacity (bytes) of ``space`` for ``arch``, read from the platform |
| 656 | // ini shipped with the package. Returns 0 when the arch or space key is not | 656 | // ini shipped with the package. Returns 0 when the arch or space key is not |
| 657 | // recognized / the ini cannot be found or parsed. | 657 | // recognized / the ini cannot be found or parsed. |
| 658 | -size_t GetMemoryLimitForArch(const std::string& arch, const std::string& space); | 658 | +size_t GetMemoryLimitForArch(NPUArch arch, const std::string& space); |
| 659 | } // namespace npu::tile_fwk | 659 | } // namespace npu::tile_fwk |
| @@ -1393,7 +1393,7 @@ static std::string MakeCrossCoreSetCodegenCCE(const ir::CallPtr& op, codegen::Co | |||
| 1393 | auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base); | 1393 | auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base); |
| 1394 | auto pipe = op->GetKwarg<int>("pipe"); | 1394 | auto pipe = op->GetKwarg<int>("pipe"); |
| 1395 | std::string pipe_str = PipeTypeToCCEString(static_cast<ir::PipeType>(pipe)); | 1395 | std::string pipe_str = PipeTypeToCCEString(static_cast<ir::PipeType>(pipe)); |
| 1396 | - bool is_a5 = (codegen.GetArch() == "a5"); | 1396 | + bool is_a5 = (codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510); |
| 1397 | auto sync_mode = static_cast<ir::CrossCoreSyncMode>(op->GetKwarg<int>("sync_mode")); | 1397 | auto sync_mode = static_cast<ir::CrossCoreSyncMode>(op->GetKwarg<int>("sync_mode")); |
| 1398 | bool is_intra_unicast = sync_mode == ir::CrossCoreSyncMode::INTRA_BLOCK || | 1398 | bool is_intra_unicast = sync_mode == ir::CrossCoreSyncMode::INTRA_BLOCK || |
| 1399 | sync_mode == ir::CrossCoreSyncMode::UNICAST_BLOCK; | 1399 | sync_mode == ir::CrossCoreSyncMode::UNICAST_BLOCK; |
| @@ -1461,7 +1461,7 @@ static std::string MakeCrossCoreWaitCodegenCCE(const ir::CallPtr& op, codegen::C | |||
| 1461 | bool is_intra_unicast = (sync_mode == ir::CrossCoreSyncMode::INTRA_BLOCK || | 1461 | bool is_intra_unicast = (sync_mode == ir::CrossCoreSyncMode::INTRA_BLOCK || |
| 1462 | sync_mode == ir::CrossCoreSyncMode::UNICAST_BLOCK); | 1462 | sync_mode == ir::CrossCoreSyncMode::UNICAST_BLOCK); |
| 1463 | bool wait_two_vec_subcores = (sync_mode == ir::CrossCoreSyncMode::INTRA_BLOCK); | 1463 | bool wait_two_vec_subcores = (sync_mode == ir::CrossCoreSyncMode::INTRA_BLOCK); |
| 1464 | - bool is_a5 = (codegen.GetArch() == "a5"); | 1464 | + bool is_a5 = (codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510); |
| 1465 | if (is_a5 && is_intra_unicast) { | 1465 | if (is_a5 && is_intra_unicast) { |
| 1466 | // A5 + INTRA_BLOCK(2) or UNICAST_BLOCK(3): wait_intra_block | 1466 | // A5 + INTRA_BLOCK(2) or UNICAST_BLOCK(3): wait_intra_block |
| 1467 | // CUBE waiting for VEC: INTRA_BLOCK expands to two calls (v0: id, v1: id+16); UNICAST_BLOCK single call | 1467 | // CUBE waiting for VEC: INTRA_BLOCK expands to two calls (v0: id, v1: id+16); UNICAST_BLOCK single call |
| @@ -2096,7 +2096,7 @@ REGISTER_BACKEND_OP(BackendCCE, "system.set_mm_layout_transform") | |||
| 2096 | .f_codegen([](const ir::CallPtr& op, codegen::CodegenBase& codegen_base) { | 2096 | .f_codegen([](const ir::CallPtr& op, codegen::CodegenBase& codegen_base) { |
| 2097 | auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base); | 2097 | auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base); |
| 2098 | auto enabled = op->GetKwarg<int>("enabled"); | 2098 | auto enabled = op->GetKwarg<int>("enabled"); |
| 2099 | - if (codegen.GetArch() == "a5") { | 2099 | + if (codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510) { |
| 2100 | // Direct register manipulation: MM_LAYOUT_MODE_BIT = 51 | 2100 | // Direct register manipulation: MM_LAYOUT_MODE_BIT = 51 |
| 2101 | if (enabled) { | 2101 | if (enabled) { |
| 2102 | codegen.Emit("set_ctrl(sbitset1(get_ctrl(), 51));"); | 2102 | codegen.Emit("set_ctrl(sbitset1(get_ctrl(), 51));"); |
| @@ -310,8 +310,8 @@ std::string MakeSimtCastCodegenCCE(const ir::CallPtr& op, codegen::CodegenBase& | |||
| 310 | auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base); | 310 | auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base); |
| 311 | PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext()) | 311 | PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext()) |
| 312 | << "simt.cast reached CCE codegen outside a SIMT function"; | 312 | << "simt.cast reached CCE codegen outside a SIMT function"; |
| 313 | - PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == "a5") | 313 | + PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510) |
| 314 | - << "simt.cast currently requires arch='a5'"; | 314 | + << "simt.cast currently requires arch='3510'"; |
| 315 | PRO_CODEGEN_CHECK(ExternalError::INVALID_ARGUMENT, op->args_.size() == 1) | 315 | PRO_CODEGEN_CHECK(ExternalError::INVALID_ARGUMENT, op->args_.size() == 1) |
| 316 | << "simt.cast requires one scalar argument"; | 316 | << "simt.cast requires one scalar argument"; |
| 317 | 317 | ||
| @@ -351,8 +351,8 @@ std::string MakeSimtBitcastCodegenCCE(const ir::CallPtr& op, codegen::CodegenBas | |||
| 351 | auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base); | 351 | auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base); |
| 352 | PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext()) | 352 | PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext()) |
| 353 | << "simt.bitcast reached CCE codegen outside a SIMT function"; | 353 | << "simt.bitcast reached CCE codegen outside a SIMT function"; |
| 354 | - PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == "a5") | 354 | + PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510) |
| 355 | - << "simt.bitcast currently requires arch='a5'"; | 355 | + << "simt.bitcast currently requires arch='3510'"; |
| 356 | PRO_CODEGEN_CHECK(ExternalError::INVALID_ARGUMENT, op->args_.size() == 1) | 356 | PRO_CODEGEN_CHECK(ExternalError::INVALID_ARGUMENT, op->args_.size() == 1) |
| 357 | << "simt.bitcast requires one scalar argument"; | 357 | << "simt.bitcast requires one scalar argument"; |
| 358 | 358 | ||
| @@ -448,8 +448,8 @@ SimtUnaryCodegenInput GetSimtUnaryCodegenInput(const ir::CallPtr& op, codegen::C | |||
| 448 | auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base); | 448 | auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base); |
| 449 | PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext()) | 449 | PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext()) |
| 450 | << op->name_ << " reached CCE codegen outside a SIMT function"; | 450 | << op->name_ << " reached CCE codegen outside a SIMT function"; |
| 451 | - PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == "a5") | 451 | + PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510) |
| 452 | - << op->name_ << " currently requires arch='a5'"; | 452 | + << op->name_ << " currently requires arch='3510'"; |
| 453 | auto scalar_type = ir::As<ir::ScalarType>(op->args_[0]->GetType()); | 453 | auto scalar_type = ir::As<ir::ScalarType>(op->args_[0]->GetType()); |
| 454 | PRO_CODEGEN_CHECK(ExternalError::INVALID_TYPE, scalar_type != nullptr) << op->name_ << " operand must be a scalar"; | 454 | PRO_CODEGEN_CHECK(ExternalError::INVALID_TYPE, scalar_type != nullptr) << op->name_ << " operand must be a scalar"; |
| 455 | return {scalar_type->dtype_, codegen.GetExprAsCode(op->args_[0])}; | 455 | return {scalar_type->dtype_, codegen.GetExprAsCode(op->args_[0])}; |
| @@ -822,8 +822,8 @@ std::string MakeSimtMinCodegenCCE(const ir::CallPtr& op, codegen::CodegenBase& c | |||
| 822 | auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base); | 822 | auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base); |
| 823 | PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext()) | 823 | PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext()) |
| 824 | << "simt.min reached CCE codegen outside a SIMT function"; | 824 | << "simt.min reached CCE codegen outside a SIMT function"; |
| 825 | - PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == "a5") | 825 | + PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510) |
| 826 | - << "simt.min currently requires arch='a5'"; | 826 | + << "simt.min currently requires arch='3510'"; |
| 827 | auto scalar_type = ir::As<ir::ScalarType>(op->args_[0]->GetType()); | 827 | auto scalar_type = ir::As<ir::ScalarType>(op->args_[0]->GetType()); |
| 828 | PRO_CODEGEN_CHECK(ExternalError::INVALID_TYPE, scalar_type != nullptr) << "simt.min operand must be a scalar"; | 828 | PRO_CODEGEN_CHECK(ExternalError::INVALID_TYPE, scalar_type != nullptr) << "simt.min operand must be a scalar"; |
| 829 | const auto& dtype = scalar_type->dtype_; | 829 | const auto& dtype = scalar_type->dtype_; |
| @@ -851,8 +851,8 @@ std::string MakeSimtMaxCodegenCCE(const ir::CallPtr& op, codegen::CodegenBase& c | |||
| 851 | auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base); | 851 | auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base); |
| 852 | PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext()) | 852 | PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext()) |
| 853 | << "simt.max reached CCE codegen outside a SIMT function"; | 853 | << "simt.max reached CCE codegen outside a SIMT function"; |
| 854 | - PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == "a5") | 854 | + PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510) |
| 855 | - << "simt.max currently requires arch='a5'"; | 855 | + << "simt.max currently requires arch='3510'"; |
| 856 | auto scalar_type = ir::As<ir::ScalarType>(op->args_[0]->GetType()); | 856 | auto scalar_type = ir::As<ir::ScalarType>(op->args_[0]->GetType()); |
| 857 | PRO_CODEGEN_CHECK(ExternalError::INVALID_TYPE, scalar_type != nullptr) << "simt.max operand must be a scalar"; | 857 | PRO_CODEGEN_CHECK(ExternalError::INVALID_TYPE, scalar_type != nullptr) << "simt.max operand must be a scalar"; |
| 858 | const auto& dtype = scalar_type->dtype_; | 858 | const auto& dtype = scalar_type->dtype_; |
| @@ -880,8 +880,8 @@ std::string MakeSimtFmaCodegenCCE(const ir::CallPtr& op, codegen::CodegenBase& c | |||
| 880 | auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base); | 880 | auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base); |
| 881 | PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext()) | 881 | PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext()) |
| 882 | << "simt.fma reached CCE codegen outside a SIMT function"; | 882 | << "simt.fma reached CCE codegen outside a SIMT function"; |
| 883 | - PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == "a5") | 883 | + PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510) |
| 884 | - << "simt.fma currently requires arch='a5'"; | 884 | + << "simt.fma currently requires arch='3510'"; |
| 885 | return "__fma(" + codegen.GetExprAsCode(op->args_[0]) + ", " + codegen.GetExprAsCode(op->args_[1]) + ", " + | 885 | return "__fma(" + codegen.GetExprAsCode(op->args_[0]) + ", " + codegen.GetExprAsCode(op->args_[1]) + ", " + |
| 886 | codegen.GetExprAsCode(op->args_[2]) + ")"; | 886 | codegen.GetExprAsCode(op->args_[2]) + ")"; |
| 887 | } | 887 | } |
| @@ -936,8 +936,8 @@ std::string MakeSimtAtomicCodegenCCE(const ir::CallPtr& op, codegen::CodegenBase | |||
| 936 | SimtAtomicSpec spec = GetSimtAtomicSpec(op->name_); | 936 | SimtAtomicSpec spec = GetSimtAtomicSpec(op->name_); |
| 937 | PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext()) | 937 | PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext()) |
| 938 | << op->name_ << " reached CCE codegen outside a SIMT function"; | 938 | << op->name_ << " reached CCE codegen outside a SIMT function"; |
| 939 | - PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == "a5") | 939 | + PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510) |
| 940 | - << op->name_ << " currently requires arch='a5'"; | 940 | + << op->name_ << " currently requires arch='3510'"; |
| 941 | PRO_CODEGEN_CHECK(ExternalError::INVALID_ARGUMENT, op->args_.size() == spec.operand_count + 2) | 941 | PRO_CODEGEN_CHECK(ExternalError::INVALID_ARGUMENT, op->args_.size() == spec.operand_count + 2) |
| 942 | << op->name_ << " requires container, offset, and " << spec.operand_count << " scalar operand(s)"; | 942 | << op->name_ << " requires container, offset, and " << spec.operand_count << " scalar operand(s)"; |
| 943 | 943 | ||
| @@ -981,8 +981,8 @@ std::string MakeSimtLaunchCodegenCCE(const ir::CallPtr& op, codegen::CodegenBase | |||
| 981 | << "Nested simt.launch is not supported"; | 981 | << "Nested simt.launch is not supported"; |
| 982 | PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.GetTarget() == ir::SectionKind::Vector) | 982 | PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.GetTarget() == ir::SectionKind::Vector) |
| 983 | << "simt.launch requires the Vector target"; | 983 | << "simt.launch requires the Vector target"; |
| 984 | - PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == "a5") | 984 | + PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510) |
| 985 | - << "simt.launch currently requires arch='a5'"; | 985 | + << "simt.launch currently requires arch='3510'"; |
| 986 | int64_t thread_dims[3] = {}; | 986 | int64_t thread_dims[3] = {}; |
| 987 | for (size_t i = 0; i < 3; ++i) { | 987 | for (size_t i = 0; i < 3; ++i) { |
| 988 | auto dim = ir::As<ir::ConstInt>(op->args_[i]); | 988 | auto dim = ir::As<ir::ConstInt>(op->args_[i]); |
| @@ -624,13 +624,15 @@ std::vector<ir::FunctionPtr> OrderSimtCallees(const std::map<std::string, ir::Fu | |||
| 624 | 624 | ||
| 625 | } // namespace | 625 | } // namespace |
| 626 | 626 | ||
| 627 | -std::string CCECodegen::GenerateSingle(const ir::ProgramPtr& program, const std::string& arch) | 627 | +std::string CCECodegen::GenerateSingle(const ir::ProgramPtr& program, npu::tile_fwk::NPUArch arch) |
| 628 | { | 628 | { |
| 629 | PRO_CODEGEN_CHECK(npu::tile_fwk::InternalError::CODEGEN_INNER_ERROR, program != nullptr) | 629 | PRO_CODEGEN_CHECK(npu::tile_fwk::InternalError::CODEGEN_INNER_ERROR, program != nullptr) |
| 630 | << "Cannot generate code for null program"; | 630 | << "Cannot generate code for null program"; |
| 631 | 631 | ||
| 632 | ResetFunctionGenerationState(); | 632 | ResetFunctionGenerationState(); |
| 633 | arch_ = arch; | 633 | arch_ = arch; |
| 634 | + PRO_CODEGEN_CHECK(ExternalError::INVALID_VAL, arch_ != npu::tile_fwk::NPUArch::DAV_UNKNOWN) | ||
| 635 | + << "unknown arch '" << npu::tile_fwk::NPUArchToString(arch_) << "'"; | ||
| 634 | 636 | ||
| 635 | // Parser-produced Programs always carry the tuple metadata table created at | 637 | // Parser-produced Programs always carry the tuple metadata table created at |
| 636 | // the top-level parse entry. Codegen relies on absence *within* that table to | 638 | // the top-level parse entry. Codegen relies on absence *within* that table to |
| @@ -664,8 +666,8 @@ std::string CCECodegen::GenerateSingle(const ir::ProgramPtr& program, const std: | |||
| 664 | if (!simt_funcs.empty() || !simt_callees_.empty()) { | 666 | if (!simt_funcs.empty() || !simt_callees_.empty()) { |
| 665 | PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, target_ == ir::SectionKind::Vector) | 667 | PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, target_ == ir::SectionKind::Vector) |
| 666 | << "SIMT functions can only be generated for the Vector target"; | 668 | << "SIMT functions can only be generated for the Vector target"; |
| 667 | - PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, arch_ == "a5") | 669 | + PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, arch_ == npu::tile_fwk::NPUArch::DAV_3510) |
| 668 | - << "SIMT direct CCE generation currently requires arch='a5'"; | 670 | + << "SIMT direct CCE generation currently requires arch='3510'"; |
| 669 | } | 671 | } |
| 670 | 672 | ||
| 671 | emitter_.Clear(); | 673 | emitter_.Clear(); |
| @@ -674,7 +676,7 @@ std::string CCECodegen::GenerateSingle(const ir::ProgramPtr& program, const std: | |||
| 674 | 676 | ||
| 675 | // Detect cross-core sync (a5 uses hardware sync, not ffts) | 677 | // Detect cross-core sync (a5 uses hardware sync, not ffts) |
| 676 | bool has_cross_sync = DetectCrossCoreSyncOps(kernel_func->body_); | 678 | bool has_cross_sync = DetectCrossCoreSyncOps(kernel_func->body_); |
| 677 | - bool needs_ffts = has_cross_sync && (arch_ != "a5"); | 679 | + bool needs_ffts = has_cross_sync && (arch_ != npu::tile_fwk::NPUArch::DAV_3510); |
| 678 | 680 | ||
| 679 | for (const auto& simt_callee : OrderSimtCallees(simt_callees_)) { | 681 | for (const auto& simt_callee : OrderSimtCallees(simt_callees_)) { |
| 680 | GenerateSimtFunction(simt_callee); | 682 | GenerateSimtFunction(simt_callee); |
| @@ -917,7 +919,7 @@ void CCECodegen::EmitSingleFunctionSignature(const ir::FunctionPtr& func, bool h | |||
| 917 | if (has_cross_sync) { | 919 | if (has_cross_sync) { |
| 918 | emitter_.EmitLine("set_ffts_base_addr((unsigned long)ffts_addr);"); | 920 | emitter_.EmitLine("set_ffts_base_addr((unsigned long)ffts_addr);"); |
| 919 | } | 921 | } |
| 920 | - if (target_ == ir::SectionKind::Vector && arch_ == "a3") { | 922 | + if (target_ == ir::SectionKind::Vector && arch_ == npu::tile_fwk::NPUArch::DAV_2201) { |
| 921 | emitter_.EmitLine("set_mask_norm();"); | 923 | emitter_.EmitLine("set_mask_norm();"); |
| 922 | emitter_.EmitLine("set_vector_mask(-1, -1);"); | 924 | emitter_.EmitLine("set_vector_mask(-1, -1);"); |
| 923 | } | 925 | } |
| @@ -2820,7 +2822,7 @@ void CCECodegen::CollectMutexPipeInfo(const ir::StmtPtr& stmt) | |||
| 2820 | 2822 | ||
| 2821 | bool CCECodegen::ShouldSkipVPipeMutex(ir::PipeType pipe, const std::vector<int>& buf_ids) const | 2823 | bool CCECodegen::ShouldSkipVPipeMutex(ir::PipeType pipe, const std::vector<int>& buf_ids) const |
| 2822 | { | 2824 | { |
| 2823 | - if (pipe != ir::PipeType::V || arch_ != "a5") | 2825 | + if (pipe != ir::PipeType::V || arch_ != npu::tile_fwk::NPUArch::DAV_3510) |
| 2824 | return false; | 2826 | return false; |
| 2825 | for (int bid : buf_ids) { | 2827 | for (int bid : buf_ids) { |
| 2826 | auto it = mutex_pipes_.find(bid); | 2828 | auto it = mutex_pipes_.find(bid); |
| @@ -360,12 +360,11 @@ void Platform::ReloadMemoryPaths(const std::string& archType) | |||
| 360 | } | 360 | } |
| 361 | } | 361 | } |
| 362 | 362 | ||
| 363 | -size_t GetMemoryLimitForArch(const std::string& arch, const std::string& space) | 363 | +size_t GetMemoryLimitForArch(NPUArch arch, const std::string& space) |
| 364 | { | 364 | { |
| 365 | - // Arch (machine-level legacy name kept as pypto_pro API) -> standard soc_version ini. | 365 | + // Compilation arch -> standard soc_version ini. PyPTO Pro only supports 3510 (Ascend950 series). |
| 366 | - // PyPTO Pro only supports A5 (NPU_ARCH 3510, Ascend950 series). | 366 | + static const std::unordered_map<NPUArch, std::string> archToIni = { |
| 367 | - static const std::unordered_map<std::string, std::string> archToIni = { | 367 | + {NPUArch::DAV_3510, "Ascend950PR_9579"}, |
| 368 | - {"a5", "Ascend950PR_9579"}, | ||
| 369 | }; | 368 | }; |
| 370 | const auto iniIt = archToIni.find(arch); | 369 | const auto iniIt = archToIni.find(arch); |
| 371 | if (iniIt == archToIni.end()) { | 370 | if (iniIt == archToIni.end()) { |
| @@ -387,7 +386,7 @@ size_t GetMemoryLimitForArch(const std::string& arch, const std::string& space) | |||
| 387 | return 0; | 386 | return 0; |
| 388 | } | 387 | } |
| 389 | } catch (const std::exception& e) { | 388 | } catch (const std::exception& e) { |
| 390 | - PLATFORM_LOGW("GetMemoryLimitForArch(%s) failed: %s.", arch.c_str(), e.what()); | 389 | + PLATFORM_LOGW("GetMemoryLimitForArch(%s) failed: %s.", NPUArchToString(arch).c_str(), e.what()); |
| 391 | return 0; | 390 | return 0; |
| 392 | } | 391 | } |
| 393 | return memoryLimit; | 392 | return memoryLimit; |
| @@ -147,3 +147,9 @@ TEST_F(TestPlatform, A5Stub) | |||
| 147 | EXPECT_EQ(path.size(), Num2); | 147 | EXPECT_EQ(path.size(), Num2); |
| 148 | path.clear(); | 148 | path.clear(); |
| 149 | } | 149 | } |
| 150 | + | ||
| 151 | +TEST(PlatformArchTest, GetMemoryLimitForArchRejectsUnconfiguredArchAndSpace) | ||
| 152 | +{ | ||
| 153 | + EXPECT_EQ(GetMemoryLimitForArch(NPUArch::DAV_2201, kMemorySpaceVec), 0u); | ||
| 154 | + EXPECT_EQ(GetMemoryLimitForArch(NPUArch::DAV_3510, "UnmappedSpace"), 0u); | ||
| 155 | +} | ||
| @@ -157,7 +157,7 @@ std::string RunSsbufCodegen(const std::string& op_name) | |||
| 157 | ir::Span::Unknown()); | 157 | ir::Span::Unknown()); |
| 158 | 158 | ||
| 159 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 159 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 160 | - return codegen.GenerateSingle(MakeProgram(body, {}, debug_info), "a5"); | 160 | + return codegen.GenerateSingle(MakeProgram(body, {}, debug_info), npu::tile_fwk::NPUArch::DAV_3510); |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | // A `tile = block.make_tile()` statement, which is what declares *tile* in the generated code. | 163 | // A `tile = block.make_tile()` statement, which is what declares *tile* in the generated code. |
| @@ -174,7 +174,7 @@ std::string GenerateKernel(const std::vector<ir::StmtPtr>& stmts, const std::vec | |||
| 174 | { | 174 | { |
| 175 | auto body = std::make_shared<const ir::SeqStmts>(stmts, ir::Span::Unknown()); | 175 | auto body = std::make_shared<const ir::SeqStmts>(stmts, ir::Span::Unknown()); |
| 176 | codegen::CCECodegen codegen(section); | 176 | codegen::CCECodegen codegen(section); |
| 177 | - return codegen.GenerateSingle(MakeProgram(body, params), "a5"); | 177 | + return codegen.GenerateSingle(MakeProgram(body, params), npu::tile_fwk::NPUArch::DAV_3510); |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | // One MX scale load, run through full codegen: declare *tile*, then load it from tensor *scale*. | 180 | // One MX scale load, run through full codegen: declare *tile*, then load it from tensor *scale*. |
| @@ -983,7 +983,7 @@ TEST(BackendCCEBlockOutOps, GeneratesLoadAndStoreThroughFullCodegen) | |||
| 983 | ir::Span::Unknown()); | 983 | ir::Span::Unknown()); |
| 984 | 984 | ||
| 985 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 985 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 986 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {tensor}), "a5"); | 986 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {tensor}), npu::tile_fwk::NPUArch::DAV_3510); |
| 987 | 987 | ||
| 988 | EXPECT_CONTAINS(generated, "TASSIGN(tensor, tensor_ptr + "); | 988 | EXPECT_CONTAINS(generated, "TASSIGN(tensor, tensor_ptr + "); |
| 989 | EXPECT_CONTAINS(generated, "TLOAD(tile"); | 989 | EXPECT_CONTAINS(generated, "TLOAD(tile"); |
| @@ -1654,7 +1654,7 @@ TEST(BackendCCEBlockOutOps, GeneratesStructCreateThroughAssignStmt) | |||
| 1654 | auto body = std::make_shared<const ir::AssignStmt>(result, create, ir::Span::Unknown()); | 1654 | auto body = std::make_shared<const ir::AssignStmt>(result, create, ir::Span::Unknown()); |
| 1655 | 1655 | ||
| 1656 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 1656 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 1657 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 1657 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 1658 | 1658 | ||
| 1659 | EXPECT_CONTAINS(generated, "class MyStruct"); | 1659 | EXPECT_CONTAINS(generated, "class MyStruct"); |
| 1660 | EXPECT_CONTAINS(generated, "MyStruct result = {"); | 1660 | EXPECT_CONTAINS(generated, "MyStruct result = {"); |
| @@ -137,7 +137,7 @@ TEST(BackendCceOpsTest, GetBlockIdx) | |||
| 137 | auto body = std::make_shared<const ir::AssignStmt>(result, call, ir::Span::Unknown()); | 137 | auto body = std::make_shared<const ir::AssignStmt>(result, call, ir::Span::Unknown()); |
| 138 | 138 | ||
| 139 | codegen::CCECodegen codegen(ir::SectionKind::Cube); | 139 | codegen::CCECodegen codegen(ir::SectionKind::Cube); |
| 140 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 140 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 141 | EXPECT_NE(generated.find("(int64_t)(get_block_idx())"), std::string::npos); | 141 | EXPECT_NE(generated.find("(int64_t)(get_block_idx())"), std::string::npos); |
| 142 | } | 142 | } |
| 143 | 143 | ||
| @@ -162,7 +162,7 @@ TEST(BackendCceOpsTest, GetBlockNum) | |||
| 162 | auto body = std::make_shared<const ir::AssignStmt>(result, call, ir::Span::Unknown()); | 162 | auto body = std::make_shared<const ir::AssignStmt>(result, call, ir::Span::Unknown()); |
| 163 | 163 | ||
| 164 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 164 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 165 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 165 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 166 | EXPECT_NE(generated.find("(int64_t)(get_block_num())"), std::string::npos); | 166 | EXPECT_NE(generated.find("(int64_t)(get_block_num())"), std::string::npos); |
| 167 | } | 167 | } |
| 168 | 168 | ||
| @@ -187,7 +187,7 @@ TEST(BackendCceOpsTest, GetSubBlockIdx) | |||
| 187 | auto body = std::make_shared<const ir::AssignStmt>(result, call, ir::Span::Unknown()); | 187 | auto body = std::make_shared<const ir::AssignStmt>(result, call, ir::Span::Unknown()); |
| 188 | 188 | ||
| 189 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 189 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 190 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 190 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 191 | EXPECT_NE(generated.find("(int64_t)(get_subblockid())"), std::string::npos); | 191 | EXPECT_NE(generated.find("(int64_t)(get_subblockid())"), std::string::npos); |
| 192 | } | 192 | } |
| 193 | 193 | ||
| @@ -216,7 +216,7 @@ TEST(BackendCceOpsTest, DebugTrap) | |||
| 216 | 216 | ||
| 217 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 217 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 218 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 218 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 219 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 219 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 220 | EXPECT_NE(generated.find("trap();"), std::string::npos); | 220 | EXPECT_NE(generated.find("trap();"), std::string::npos); |
| 221 | } | 221 | } |
| 222 | 222 | ||
| @@ -230,7 +230,7 @@ TEST(BackendCceOpsTest, BarM) | |||
| 230 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 230 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 231 | 231 | ||
| 232 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 232 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 233 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 233 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 234 | EXPECT_NE(generated.find("pipe_barrier(PIPE_M);"), std::string::npos); | 234 | EXPECT_NE(generated.find("pipe_barrier(PIPE_M);"), std::string::npos); |
| 235 | } | 235 | } |
| 236 | 236 | ||
| @@ -261,7 +261,7 @@ TEST(BackendCceOpsTest, BarAll) | |||
| 261 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 261 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 262 | 262 | ||
| 263 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 263 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 264 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 264 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 265 | EXPECT_NE(generated.find("pipe_barrier(PIPE_ALL);"), std::string::npos); | 265 | EXPECT_NE(generated.find("pipe_barrier(PIPE_ALL);"), std::string::npos); |
| 266 | } | 266 | } |
| 267 | 267 | ||
| @@ -276,7 +276,7 @@ TEST(BackendCceOpsTest, SetMaskCount) | |||
| 276 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 276 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 277 | 277 | ||
| 278 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 278 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 279 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 279 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 280 | EXPECT_NE(generated.find("set_mask_count();"), std::string::npos); | 280 | EXPECT_NE(generated.find("set_mask_count();"), std::string::npos); |
| 281 | } | 281 | } |
| 282 | 282 | ||
| @@ -287,7 +287,7 @@ TEST(BackendCceOpsTest, SetMaskNorm) | |||
| 287 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 287 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 288 | 288 | ||
| 289 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 289 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 290 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 290 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 291 | EXPECT_NE(generated.find("set_mask_norm();"), std::string::npos); | 291 | EXPECT_NE(generated.find("set_mask_norm();"), std::string::npos); |
| 292 | } | 292 | } |
| 293 | 293 | ||
| @@ -297,7 +297,7 @@ TEST(BackendCceOpsTest, ResetMask) | |||
| 297 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 297 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 298 | 298 | ||
| 299 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 299 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 300 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 300 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 301 | EXPECT_NE(generated.find("set_vector_mask(static_cast<uint64_t>(-1), static_cast<uint64_t>(-1));"), | 301 | EXPECT_NE(generated.find("set_vector_mask(static_cast<uint64_t>(-1), static_cast<uint64_t>(-1));"), |
| 302 | std::string::npos); | 302 | std::string::npos); |
| 303 | } | 303 | } |
| @@ -309,7 +309,7 @@ TEST(BackendCceOpsTest, SetVecMask) | |||
| 309 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 309 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 310 | 310 | ||
| 311 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 311 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 312 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 312 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 313 | EXPECT_NE(generated.find("set_vector_mask(255, 128);"), std::string::npos); | 313 | EXPECT_NE(generated.find("set_vector_mask(255, 128);"), std::string::npos); |
| 314 | } | 314 | } |
| 315 | 315 | ||
| @@ -325,7 +325,7 @@ TEST(BackendCceOpsTest, SyncSrc) | |||
| 325 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 325 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 326 | 326 | ||
| 327 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 327 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 328 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 328 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 329 | EXPECT_NE(generated.find("set_flag(PIPE_V, PIPE_S, (event_t)3);"), std::string::npos); | 329 | EXPECT_NE(generated.find("set_flag(PIPE_V, PIPE_S, (event_t)3);"), std::string::npos); |
| 330 | } | 330 | } |
| 331 | 331 | ||
| @@ -337,7 +337,7 @@ TEST(BackendCceOpsTest, SyncDst) | |||
| 337 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 337 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 338 | 338 | ||
| 339 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 339 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 340 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 340 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 341 | EXPECT_NE(generated.find("wait_flag(PIPE_V, PIPE_S, (event_t)3);"), std::string::npos); | 341 | EXPECT_NE(generated.find("wait_flag(PIPE_V, PIPE_S, (event_t)3);"), std::string::npos); |
| 342 | } | 342 | } |
| 343 | 343 | ||
| @@ -371,7 +371,7 @@ TEST(BackendCceOpsTest, SyncSrcDyn) | |||
| 371 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 371 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 372 | 372 | ||
| 373 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 373 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 374 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {event_id}), "a3"); | 374 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {event_id}), npu::tile_fwk::NPUArch::DAV_2201); |
| 375 | EXPECT_NE(generated.find("set_flag(PIPE_M, PIPE_V, (event_t)event_id);"), std::string::npos); | 375 | EXPECT_NE(generated.find("set_flag(PIPE_M, PIPE_V, (event_t)event_id);"), std::string::npos); |
| 376 | } | 376 | } |
| 377 | 377 | ||
| @@ -384,7 +384,7 @@ TEST(BackendCceOpsTest, SyncDstDyn) | |||
| 384 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 384 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 385 | 385 | ||
| 386 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 386 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 387 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {event_id}), "a3"); | 387 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {event_id}), npu::tile_fwk::NPUArch::DAV_2201); |
| 388 | EXPECT_NE(generated.find("wait_flag(PIPE_M, PIPE_V, (event_t)event_id);"), std::string::npos); | 388 | EXPECT_NE(generated.find("wait_flag(PIPE_M, PIPE_V, (event_t)event_id);"), std::string::npos); |
| 389 | } | 389 | } |
| 390 | 390 | ||
| @@ -400,7 +400,7 @@ TEST(BackendCceOpsTest, SetCrossCoreA3) | |||
| 400 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 400 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 401 | 401 | ||
| 402 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 402 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 403 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 403 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 404 | EXPECT_NE(generated.find("ffts_cross_core_sync(PIPE_V, getFFTSMsg(0, 2));"), std::string::npos); | 404 | EXPECT_NE(generated.find("ffts_cross_core_sync(PIPE_V, getFFTSMsg(0, 2));"), std::string::npos); |
| 405 | } | 405 | } |
| 406 | 406 | ||
| @@ -412,7 +412,7 @@ TEST(BackendCceOpsTest, WaitCrossCoreA3) | |||
| 412 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 412 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 413 | 413 | ||
| 414 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 414 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 415 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 415 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 416 | EXPECT_NE(generated.find("wait_flag_dev(2);"), std::string::npos); | 416 | EXPECT_NE(generated.find("wait_flag_dev(2);"), std::string::npos); |
| 417 | } | 417 | } |
| 418 | 418 | ||
| @@ -424,7 +424,7 @@ TEST(BackendCceOpsTest, SetCrossCoreDynA3) | |||
| 424 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 424 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 425 | 425 | ||
| 426 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 426 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 427 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 427 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 428 | EXPECT_NE(generated.find("ffts_cross_core_sync(PIPE_V, getFFTSMsg(0, 7));"), std::string::npos); | 428 | EXPECT_NE(generated.find("ffts_cross_core_sync(PIPE_V, getFFTSMsg(0, 7));"), std::string::npos); |
| 429 | } | 429 | } |
| 430 | 430 | ||
| @@ -436,7 +436,7 @@ TEST(BackendCceOpsTest, WaitCrossCoreDynA3) | |||
| 436 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 436 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 437 | 437 | ||
| 438 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 438 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 439 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 439 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 440 | EXPECT_NE(generated.find("wait_flag_dev(7);"), std::string::npos); | 440 | EXPECT_NE(generated.find("wait_flag_dev(7);"), std::string::npos); |
| 441 | } | 441 | } |
| 442 | 442 | ||
| @@ -452,7 +452,7 @@ TEST(BackendCceOpsTest, SetCrossCoreA5InterBlock) | |||
| 452 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 452 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 453 | 453 | ||
| 454 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 454 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 455 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 455 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 456 | EXPECT_NE(generated.find("ffts_cross_core_sync(PIPE_V, getFFTSMsg(0, 2));"), std::string::npos); | 456 | EXPECT_NE(generated.find("ffts_cross_core_sync(PIPE_V, getFFTSMsg(0, 2));"), std::string::npos); |
| 457 | } | 457 | } |
| 458 | 458 | ||
| @@ -464,7 +464,7 @@ TEST(BackendCceOpsTest, WaitCrossCoreA5InterBlock) | |||
| 464 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 464 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 465 | 465 | ||
| 466 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 466 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 467 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 467 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 468 | EXPECT_NE(generated.find("wait_flag_dev(PIPE_V, 2);"), std::string::npos); | 468 | EXPECT_NE(generated.find("wait_flag_dev(PIPE_V, 2);"), std::string::npos); |
| 469 | } | 469 | } |
| 470 | 470 | ||
| @@ -480,7 +480,7 @@ TEST(BackendCceOpsTest, SetCrossCoreA5IntraBlock) | |||
| 480 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 480 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 481 | 481 | ||
| 482 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 482 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 483 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 483 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 484 | EXPECT_NE(generated.find("set_intra_block(PIPE_V, 3);"), std::string::npos); | 484 | EXPECT_NE(generated.find("set_intra_block(PIPE_V, 3);"), std::string::npos); |
| 485 | } | 485 | } |
| 486 | 486 | ||
| @@ -492,7 +492,7 @@ TEST(BackendCceOpsTest, WaitCrossCoreA5IntraBlock) | |||
| 492 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 492 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 493 | 493 | ||
| 494 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 494 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 495 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 495 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 496 | EXPECT_NE(generated.find("wait_intra_block(PIPE_V, 3);"), std::string::npos); | 496 | EXPECT_NE(generated.find("wait_intra_block(PIPE_V, 3);"), std::string::npos); |
| 497 | } | 497 | } |
| 498 | 498 | ||
| @@ -504,7 +504,7 @@ TEST(BackendCceOpsTest, SetCrossCoreDynA5IntraBlock) | |||
| 504 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 504 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 505 | 505 | ||
| 506 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 506 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 507 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 507 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 508 | EXPECT_NE(generated.find("set_intra_block(PIPE_V, 8);"), std::string::npos); | 508 | EXPECT_NE(generated.find("set_intra_block(PIPE_V, 8);"), std::string::npos); |
| 509 | } | 509 | } |
| 510 | 510 | ||
| @@ -516,7 +516,7 @@ TEST(BackendCceOpsTest, WaitCrossCoreDynA5IntraBlock) | |||
| 516 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 516 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 517 | 517 | ||
| 518 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 518 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 519 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 519 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 520 | EXPECT_NE(generated.find("wait_intra_block(PIPE_V, 8);"), std::string::npos); | 520 | EXPECT_NE(generated.find("wait_intra_block(PIPE_V, 8);"), std::string::npos); |
| 521 | } | 521 | } |
| 522 | 522 | ||
| @@ -533,7 +533,7 @@ TEST(BackendCceOpsTest, CubeCrossCoreA5IntraBlockSignalsBothVectorSubcores) | |||
| 533 | ir::Span::Unknown()); | 533 | ir::Span::Unknown()); |
| 534 | 534 | ||
| 535 | codegen::CCECodegen codegen(ir::SectionKind::Cube); | 535 | codegen::CCECodegen codegen(ir::SectionKind::Cube); |
| 536 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 536 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 537 | EXPECT_NE(generated.find("set_intra_block(PIPE_V, 3);"), std::string::npos); | 537 | EXPECT_NE(generated.find("set_intra_block(PIPE_V, 3);"), std::string::npos); |
| 538 | EXPECT_NE(generated.find("set_intra_block(PIPE_V, 19);"), std::string::npos); | 538 | EXPECT_NE(generated.find("set_intra_block(PIPE_V, 19);"), std::string::npos); |
| 539 | EXPECT_NE(generated.find("wait_intra_block(PIPE_V, 3);"), std::string::npos); | 539 | EXPECT_NE(generated.find("wait_intra_block(PIPE_V, 3);"), std::string::npos); |
| @@ -554,7 +554,7 @@ TEST(BackendCceOpsTest, CubeCrossCoreDynamicA5IntraBlockSignalsBothVectorSubcore | |||
| 554 | ir::Span::Unknown()); | 554 | ir::Span::Unknown()); |
| 555 | 555 | ||
| 556 | codegen::CCECodegen codegen(ir::SectionKind::Cube); | 556 | codegen::CCECodegen codegen(ir::SectionKind::Cube); |
| 557 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {event_id}), "a5"); | 557 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {event_id}), npu::tile_fwk::NPUArch::DAV_3510); |
| 558 | EXPECT_NE(generated.find("set_intra_block(PIPE_V, event_id);"), std::string::npos); | 558 | EXPECT_NE(generated.find("set_intra_block(PIPE_V, event_id);"), std::string::npos); |
| 559 | EXPECT_NE(generated.find("set_intra_block(PIPE_V, event_id + 16);"), std::string::npos); | 559 | EXPECT_NE(generated.find("set_intra_block(PIPE_V, event_id + 16);"), std::string::npos); |
| 560 | EXPECT_NE(generated.find("wait_intra_block(PIPE_V, event_id);"), std::string::npos); | 560 | EXPECT_NE(generated.find("wait_intra_block(PIPE_V, event_id);"), std::string::npos); |
| @@ -573,7 +573,7 @@ TEST(BackendCceOpsTest, MutexLock) | |||
| 573 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 573 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 574 | 574 | ||
| 575 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 575 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 576 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 576 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 577 | EXPECT_NE(generated.find("get_buf(PIPE_S, 1, 0);"), std::string::npos); | 577 | EXPECT_NE(generated.find("get_buf(PIPE_S, 1, 0);"), std::string::npos); |
| 578 | } | 578 | } |
| 579 | 579 | ||
| @@ -585,7 +585,7 @@ TEST(BackendCceOpsTest, MutexUnlock) | |||
| 585 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 585 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 586 | 586 | ||
| 587 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 587 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 588 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 588 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 589 | EXPECT_NE(generated.find("rls_buf(PIPE_S, 1, 0);"), std::string::npos); | 589 | EXPECT_NE(generated.find("rls_buf(PIPE_S, 1, 0);"), std::string::npos); |
| 590 | } | 590 | } |
| 591 | 591 | ||
| @@ -597,7 +597,7 @@ TEST(BackendCceOpsTest, MutexLockDyn) | |||
| 597 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 597 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 598 | 598 | ||
| 599 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 599 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 600 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 600 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 601 | EXPECT_NE(generated.find("get_buf(PIPE_S, 2, 0);"), std::string::npos); | 601 | EXPECT_NE(generated.find("get_buf(PIPE_S, 2, 0);"), std::string::npos); |
| 602 | } | 602 | } |
| 603 | 603 | ||
| @@ -609,7 +609,7 @@ TEST(BackendCceOpsTest, MutexUnlockDyn) | |||
| 609 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 609 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 610 | 610 | ||
| 611 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 611 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 612 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 612 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 613 | EXPECT_NE(generated.find("rls_buf(PIPE_S, 2, 0);"), std::string::npos); | 613 | EXPECT_NE(generated.find("rls_buf(PIPE_S, 2, 0);"), std::string::npos); |
| 614 | } | 614 | } |
| 615 | 615 | ||
| @@ -627,7 +627,7 @@ TEST(BackendCceOpsTest, VMutexWithoutCandidateIdsIsNotSkipped) | |||
| 627 | ir::Span::Unknown()); | 627 | ir::Span::Unknown()); |
| 628 | 628 | ||
| 629 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 629 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 630 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 630 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 631 | EXPECT_NE(generated.find("get_buf(PIPE_V, 6, 0);"), std::string::npos); | 631 | EXPECT_NE(generated.find("get_buf(PIPE_V, 6, 0);"), std::string::npos); |
| 632 | EXPECT_NE(generated.find("rls_buf(PIPE_V, 7, 0);"), std::string::npos); | 632 | EXPECT_NE(generated.find("rls_buf(PIPE_V, 7, 0);"), std::string::npos); |
| 633 | } | 633 | } |
| @@ -641,7 +641,7 @@ TEST(BackendCceOpsTest, AutoVMutexIsSkippedWhenAllCandidatesAreVOnly) | |||
| 641 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 641 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 642 | 642 | ||
| 643 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 643 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 644 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 644 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 645 | EXPECT_EQ(generated.find("get_buf(PIPE_V, 6, 0);"), std::string::npos); | 645 | EXPECT_EQ(generated.find("get_buf(PIPE_V, 6, 0);"), std::string::npos); |
| 646 | } | 646 | } |
| 647 | 647 | ||
| @@ -661,7 +661,7 @@ TEST(BackendCceOpsTest, AutoVMutexUsesTheWholeCandidateSetBeforeSkipping) | |||
| 661 | ir::Span::Unknown()); | 661 | ir::Span::Unknown()); |
| 662 | 662 | ||
| 663 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 663 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 664 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 664 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 665 | EXPECT_NE(generated.find("get_buf(PIPE_V, 6, 0);"), std::string::npos); | 665 | EXPECT_NE(generated.find("get_buf(PIPE_V, 6, 0);"), std::string::npos); |
| 666 | EXPECT_NE(generated.find("get_buf(PIPE_MTE2, 7, 0);"), std::string::npos); | 666 | EXPECT_NE(generated.find("get_buf(PIPE_MTE2, 7, 0);"), std::string::npos); |
| 667 | } | 667 | } |
| @@ -680,7 +680,7 @@ TEST(BackendCceOpsTest, ManualConstantMutexDoesNotAffectAutoVMutexSkipForSameId) | |||
| 680 | ir::Span::Unknown()); | 680 | ir::Span::Unknown()); |
| 681 | 681 | ||
| 682 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 682 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 683 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 683 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 684 | EXPECT_EQ(generated.find("get_buf(PIPE_V, 6, 0);"), std::string::npos); | 684 | EXPECT_EQ(generated.find("get_buf(PIPE_V, 6, 0);"), std::string::npos); |
| 685 | EXPECT_NE(generated.find("get_buf(PIPE_MTE2, 6, 0);"), std::string::npos); | 685 | EXPECT_NE(generated.find("get_buf(PIPE_MTE2, 6, 0);"), std::string::npos); |
| 686 | } | 686 | } |
| @@ -699,7 +699,7 @@ TEST(BackendCceOpsTest, ManualConstantMutexOnAnotherPipeDoesNotBlockAutoVMutexSk | |||
| 699 | ir::Span::Unknown()); | 699 | ir::Span::Unknown()); |
| 700 | 700 | ||
| 701 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 701 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 702 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 702 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 703 | EXPECT_EQ(generated.find("get_buf(PIPE_V, 6, 0);"), std::string::npos); | 703 | EXPECT_EQ(generated.find("get_buf(PIPE_V, 6, 0);"), std::string::npos); |
| 704 | EXPECT_NE(generated.find("get_buf(PIPE_MTE2, 7, 0);"), std::string::npos); | 704 | EXPECT_NE(generated.find("get_buf(PIPE_MTE2, 7, 0);"), std::string::npos); |
| 705 | } | 705 | } |
| @@ -719,7 +719,7 @@ TEST(BackendCceOpsTest, ManualDynamicMutexDoesNotGloballyDisableAutoVMutexSkip) | |||
| 719 | ir::Span::Unknown()); | 719 | ir::Span::Unknown()); |
| 720 | 720 | ||
| 721 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 721 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 722 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {dynamic_id}), "a5"); | 722 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {dynamic_id}), npu::tile_fwk::NPUArch::DAV_3510); |
| 723 | EXPECT_EQ(generated.find("get_buf(PIPE_V, 6, 0);"), std::string::npos); | 723 | EXPECT_EQ(generated.find("get_buf(PIPE_V, 6, 0);"), std::string::npos); |
| 724 | EXPECT_NE(generated.find("get_buf(PIPE_MTE2, manual_id, 0);"), std::string::npos); | 724 | EXPECT_NE(generated.find("get_buf(PIPE_MTE2, manual_id, 0);"), std::string::npos); |
| 725 | } | 725 | } |
| @@ -738,7 +738,7 @@ TEST(BackendCceOpsTest, MutexDynDedupUnlocksFirstOccurrencesInInputOrder) | |||
| 738 | ir::Span::Unknown()); | 738 | ir::Span::Unknown()); |
| 739 | 739 | ||
| 740 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 740 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 741 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {id0, id1}), "a5"); | 741 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {id0, id1}), npu::tile_fwk::NPUArch::DAV_3510); |
| 742 | auto release_id0 = generated.find("rls_buf(PIPE_S, id0, 0);"); | 742 | auto release_id0 = generated.find("rls_buf(PIPE_S, id0, 0);"); |
| 743 | auto release_id1 = generated.find("rls_buf(PIPE_S, id1, 0);", release_id0); | 743 | auto release_id1 = generated.find("rls_buf(PIPE_S, id1, 0);", release_id0); |
| 744 | auto duplicate_guard = generated.find("if ((id0 != id0) && (id0 != id1)) {", release_id1); | 744 | auto duplicate_guard = generated.find("if ((id0 != id0) && (id0 != id1)) {", release_id1); |
| @@ -767,7 +767,8 @@ TEST(BackendCceOpsTest, MutexDynSkipsDedupWithinOneTile) | |||
| 767 | ir::Span::Unknown()); | 767 | ir::Span::Unknown()); |
| 768 | 768 | ||
| 769 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 769 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 770 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {output0, output1, source}), "a5"); | 770 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {output0, output1, source}), |
| 771 | + npu::tile_fwk::NPUArch::DAV_3510); | ||
| 771 | const std::string same_tile_guard = "if ((output1 != output0)) {"; | 772 | const std::string same_tile_guard = "if ((output1 != output0)) {"; |
| 772 | const std::string cross_tile_guard = "if ((source != output0) && (source != output1)) {"; | 773 | const std::string cross_tile_guard = "if ((source != output0) && (source != output1)) {"; |
| 773 | auto acquire_output0 = generated.find("get_buf(PIPE_S, output0, 0);"); | 774 | auto acquire_output0 = generated.find("get_buf(PIPE_S, output0, 0);"); |
| @@ -801,7 +802,7 @@ TEST(BackendCceOpsTest, SetMmLayoutTransformEnabled) | |||
| 801 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 802 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 802 | 803 | ||
| 803 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 804 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 804 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 805 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 805 | EXPECT_NE(generated.find("set_ctrl(sbitset1(get_ctrl(), 51));"), std::string::npos); | 806 | EXPECT_NE(generated.find("set_ctrl(sbitset1(get_ctrl(), 51));"), std::string::npos); |
| 806 | } | 807 | } |
| 807 | 808 | ||
| @@ -813,7 +814,7 @@ TEST(BackendCceOpsTest, SetMmLayoutTransformDisabled) | |||
| 813 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 814 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 814 | 815 | ||
| 815 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 816 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 816 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 817 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 817 | EXPECT_NE(generated.find("set_ctrl(sbitset0(get_ctrl(), 51));"), std::string::npos); | 818 | EXPECT_NE(generated.find("set_ctrl(sbitset0(get_ctrl(), 51));"), std::string::npos); |
| 818 | } | 819 | } |
| 819 | 820 | ||
| @@ -831,7 +832,7 @@ TEST(BackendCceOpsTest, PtrAddPtr) | |||
| 831 | auto body = std::make_shared<const ir::AssignStmt>(result, call, ir::Span::Unknown()); | 832 | auto body = std::make_shared<const ir::AssignStmt>(result, call, ir::Span::Unknown()); |
| 832 | 833 | ||
| 833 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 834 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 834 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {ptr_var}), "a3"); | 835 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {ptr_var}), npu::tile_fwk::NPUArch::DAV_2201); |
| 835 | EXPECT_NE(generated.find("+ 10)"), std::string::npos); | 836 | EXPECT_NE(generated.find("+ 10)"), std::string::npos); |
| 836 | } | 837 | } |
| 837 | 838 | ||
| @@ -845,7 +846,7 @@ TEST(BackendCceOpsTest, PtrMakePtr) | |||
| 845 | auto body = std::make_shared<const ir::AssignStmt>(result, call, ir::Span::Unknown()); | 846 | auto body = std::make_shared<const ir::AssignStmt>(result, call, ir::Span::Unknown()); |
| 846 | 847 | ||
| 847 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 848 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 848 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {ptr_var}), "a3"); | 849 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {ptr_var}), npu::tile_fwk::NPUArch::DAV_2201); |
| 849 | EXPECT_NE(generated.find("__gm__ float*"), std::string::npos); | 850 | EXPECT_NE(generated.find("__gm__ float*"), std::string::npos); |
| 850 | } | 851 | } |
| 851 | 852 | ||
| @@ -917,7 +918,7 @@ TEST(BackendCceOpsTest, BlockMakeTileAndSetValTile) | |||
| 917 | ir::Span::Unknown()); | 918 | ir::Span::Unknown()); |
| 918 | 919 | ||
| 919 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 920 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 920 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 921 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 921 | EXPECT_NE(generated.find(".SetValue(5, 42);"), std::string::npos); | 922 | EXPECT_NE(generated.find(".SetValue(5, 42);"), std::string::npos); |
| 922 | } | 923 | } |
| 923 | 924 | ||
| @@ -939,7 +940,7 @@ TEST(BackendCceOpsTest, BlockGetValTile) | |||
| 939 | ir::Span::Unknown()); | 940 | ir::Span::Unknown()); |
| 940 | 941 | ||
| 941 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 942 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 942 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 943 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 943 | EXPECT_NE(generated.find("(int64_t)(tile.GetValue(3))"), std::string::npos); | 944 | EXPECT_NE(generated.find("(int64_t)(tile.GetValue(3))"), std::string::npos); |
| 944 | } | 945 | } |
| 945 | 946 | ||
| @@ -957,7 +958,7 @@ TEST(BackendCceOpsTest, BlockGetValTensor) | |||
| 957 | auto body = std::make_shared<const ir::AssignStmt>(result, call, ir::Span::Unknown()); | 958 | auto body = std::make_shared<const ir::AssignStmt>(result, call, ir::Span::Unknown()); |
| 958 | 959 | ||
| 959 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 960 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 960 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {tensor}), "a3"); | 961 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {tensor}), npu::tile_fwk::NPUArch::DAV_2201); |
| 961 | EXPECT_NE(generated.find("*((__gm__ float*)"), std::string::npos); | 962 | EXPECT_NE(generated.find("*((__gm__ float*)"), std::string::npos); |
| 962 | EXPECT_NE(generated.find("+ 5)"), std::string::npos); | 963 | EXPECT_NE(generated.find("+ 5)"), std::string::npos); |
| 963 | } | 964 | } |
| @@ -972,7 +973,7 @@ TEST(BackendCceOpsTest, BlockGetValTensorInt32CastsResult) | |||
| 972 | auto body = std::make_shared<const ir::AssignStmt>(result, call, ir::Span::Unknown()); | 973 | auto body = std::make_shared<const ir::AssignStmt>(result, call, ir::Span::Unknown()); |
| 973 | 974 | ||
| 974 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 975 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 975 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {tensor}), "a3"); | 976 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {tensor}), npu::tile_fwk::NPUArch::DAV_2201); |
| 976 | EXPECT_NE(generated.find("(int64_t)(*((__gm__ int32_t*)"), std::string::npos); | 977 | EXPECT_NE(generated.find("(int64_t)(*((__gm__ int32_t*)"), std::string::npos); |
| 977 | } | 978 | } |
| 978 | 979 | ||
| @@ -986,7 +987,7 @@ TEST(BackendCceOpsTest, BlockGetValTensorUint64DoesNotCastResult) | |||
| 986 | auto body = std::make_shared<const ir::AssignStmt>(result, call, ir::Span::Unknown()); | 987 | auto body = std::make_shared<const ir::AssignStmt>(result, call, ir::Span::Unknown()); |
| 987 | 988 | ||
| 988 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 989 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 989 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {tensor}), "a3"); | 990 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {tensor}), npu::tile_fwk::NPUArch::DAV_2201); |
| 990 | EXPECT_NE(generated.find("*((__gm__ uint64_t*)"), std::string::npos); | 991 | EXPECT_NE(generated.find("*((__gm__ uint64_t*)"), std::string::npos); |
| 991 | EXPECT_EQ(generated.find("(uint64_t)(*((__gm__ uint64_t*)"), std::string::npos); | 992 | EXPECT_EQ(generated.find("(uint64_t)(*((__gm__ uint64_t*)"), std::string::npos); |
| 992 | } | 993 | } |
| @@ -999,7 +1000,7 @@ TEST(BackendCceOpsTest, BlockSetValTensor) | |||
| 999 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 1000 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 1000 | 1001 | ||
| 1001 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 1002 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 1002 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {tensor}), "a3"); | 1003 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {tensor}), npu::tile_fwk::NPUArch::DAV_2201); |
| 1003 | EXPECT_NE(generated.find("*((__gm__ float*)"), std::string::npos); | 1004 | EXPECT_NE(generated.find("*((__gm__ float*)"), std::string::npos); |
| 1004 | EXPECT_NE(generated.find("+ 5) = 42;"), std::string::npos); | 1005 | EXPECT_NE(generated.find("+ 5) = 42;"), std::string::npos); |
| 1005 | } | 1006 | } |
| @@ -1141,7 +1142,7 @@ TEST(BackendCceOpsTest, SyncAllHardMix) | |||
| 1141 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 1142 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 1142 | 1143 | ||
| 1143 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 1144 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 1144 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 1145 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 1145 | EXPECT_NE(generated.find("SYNCALL<SyncCoreType::Mix>();"), std::string::npos); | 1146 | EXPECT_NE(generated.find("SYNCALL<SyncCoreType::Mix>();"), std::string::npos); |
| 1146 | } | 1147 | } |
| 1147 | 1148 | ||
| @@ -1153,7 +1154,7 @@ TEST(BackendCceOpsTest, SyncAllHardAIVOnly) | |||
| 1153 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 1154 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 1154 | 1155 | ||
| 1155 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 1156 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 1156 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 1157 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 1157 | EXPECT_NE(generated.find("SYNCALL<SyncCoreType::AIVOnly>();"), std::string::npos); | 1158 | EXPECT_NE(generated.find("SYNCALL<SyncCoreType::AIVOnly>();"), std::string::npos); |
| 1158 | } | 1159 | } |
| 1159 | 1160 | ||
| @@ -1168,7 +1169,7 @@ TEST(BackendCceOpsTest, DcciTensorDefaultKwargs) | |||
| 1168 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 1169 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 1169 | 1170 | ||
| 1170 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 1171 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 1171 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {tensor}), "a3"); | 1172 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {tensor}), npu::tile_fwk::NPUArch::DAV_2201); |
| 1172 | EXPECT_NE(generated.find("dcci("), std::string::npos); | 1173 | EXPECT_NE(generated.find("dcci("), std::string::npos); |
| 1173 | EXPECT_NE(generated.find("ENTIRE_DATA_CACHE"), std::string::npos); | 1174 | EXPECT_NE(generated.find("ENTIRE_DATA_CACHE"), std::string::npos); |
| 1174 | EXPECT_NE(generated.find("CACHELINE_OUT"), std::string::npos); | 1175 | EXPECT_NE(generated.find("CACHELINE_OUT"), std::string::npos); |
| @@ -1183,7 +1184,7 @@ TEST(BackendCceOpsTest, DcciTensorWithOffsetAndKwargs) | |||
| 1183 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 1184 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 1184 | 1185 | ||
| 1185 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 1186 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 1186 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {tensor}), "a3"); | 1187 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {tensor}), npu::tile_fwk::NPUArch::DAV_2201); |
| 1187 | EXPECT_NE(generated.find("dcci("), std::string::npos); | 1188 | EXPECT_NE(generated.find("dcci("), std::string::npos); |
| 1188 | EXPECT_NE(generated.find("SINGLE_CACHE_LINE"), std::string::npos); | 1189 | EXPECT_NE(generated.find("SINGLE_CACHE_LINE"), std::string::npos); |
| 1189 | EXPECT_NE(generated.find("CACHELINE_UB"), std::string::npos); | 1190 | EXPECT_NE(generated.find("CACHELINE_UB"), std::string::npos); |
| @@ -1220,7 +1221,7 @@ TEST(BackendCceOpsTest, DcciTileDefaultKwargs) | |||
| 1220 | ir::Span::Unknown()); | 1221 | ir::Span::Unknown()); |
| 1221 | 1222 | ||
| 1222 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 1223 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 1223 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 1224 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 1224 | EXPECT_NE(generated.find("dcci("), std::string::npos); | 1225 | EXPECT_NE(generated.find("dcci("), std::string::npos); |
| 1225 | EXPECT_NE(generated.find("__ubuf__ void*"), std::string::npos); | 1226 | EXPECT_NE(generated.find("__ubuf__ void*"), std::string::npos); |
| 1226 | EXPECT_NE(generated.find("ENTIRE_DATA_CACHE"), std::string::npos); | 1227 | EXPECT_NE(generated.find("ENTIRE_DATA_CACHE"), std::string::npos); |
| @@ -1519,7 +1520,7 @@ TEST(BackendCceOpsTest, DebugPrintf) | |||
| 1519 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 1520 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 1520 | 1521 | ||
| 1521 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 1522 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 1522 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 1523 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 1523 | EXPECT_NE(generated.find("pypto_printf"), std::string::npos); | 1524 | EXPECT_NE(generated.find("pypto_printf"), std::string::npos); |
| 1524 | } | 1525 | } |
| 1525 | 1526 | ||
| @@ -1531,7 +1532,7 @@ TEST(BackendCceOpsTest, DebugAssert) | |||
| 1531 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 1532 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 1532 | 1533 | ||
| 1533 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 1534 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 1534 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 1535 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 1535 | EXPECT_NE(generated.find("if (!("), std::string::npos); | 1536 | EXPECT_NE(generated.find("if (!("), std::string::npos); |
| 1536 | EXPECT_NE(generated.find("kernel.py"), std::string::npos); | 1537 | EXPECT_NE(generated.find("kernel.py"), std::string::npos); |
| 1537 | EXPECT_NE(generated.find("Assertion failed: x > 0"), std::string::npos); | 1538 | EXPECT_NE(generated.find("Assertion failed: x > 0"), std::string::npos); |
| @@ -1545,7 +1546,7 @@ TEST(BackendCceOpsTest, DebugAssertWithFormatAndArgs) | |||
| 1545 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 1546 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 1546 | 1547 | ||
| 1547 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 1548 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 1548 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 1549 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 1549 | EXPECT_NE(generated.find("if (!("), std::string::npos); | 1550 | EXPECT_NE(generated.find("if (!("), std::string::npos); |
| 1550 | EXPECT_NE(generated.find("pypto_printf"), std::string::npos); | 1551 | EXPECT_NE(generated.find("pypto_printf"), std::string::npos); |
| 1551 | } | 1552 | } |
| @@ -1558,7 +1559,7 @@ TEST(BackendCceOpsTest, DebugAssertWithTextOnlyFormat) | |||
| 1558 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); | 1559 | auto body = std::make_shared<const ir::EvalStmt>(call, ir::Span::Unknown()); |
| 1559 | 1560 | ||
| 1560 | codegen::CCECodegen codegen(ir::SectionKind::Vector); | 1561 | codegen::CCECodegen codegen(ir::SectionKind::Vector); |
| 1561 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a3"); | 1562 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 1562 | EXPECT_NE(generated.find("pypto_printf(\"flag is false\\n\")"), std::string::npos); | 1563 | EXPECT_NE(generated.find("pypto_printf(\"flag is false\\n\")"), std::string::npos); |
| 1563 | } | 1564 | } |
| 1564 | 1565 | ||
| @@ -77,7 +77,7 @@ TEST(CCECodegenHeaderTest, CoversHeaderOnlyStateAccessors) | |||
| 77 | CCECodegen codegen(ir::SectionKind::Vector); | 77 | CCECodegen codegen(ir::SectionKind::Vector); |
| 78 | 78 | ||
| 79 | EXPECT_TRUE(codegen.GetCurrentResultTarget().empty()); | 79 | EXPECT_TRUE(codegen.GetCurrentResultTarget().empty()); |
| 80 | - EXPECT_EQ(codegen.GetArch(), "a3"); | 80 | + EXPECT_EQ(codegen.GetArch(), npu::tile_fwk::NPUArch::DAV_2201); |
| 81 | EXPECT_EQ(codegen.GetTarget(), ir::SectionKind::Vector); | 81 | EXPECT_EQ(codegen.GetTarget(), ir::SectionKind::Vector); |
| 82 | EXPECT_FALSE(codegen.IsInVFSection()); | 82 | EXPECT_FALSE(codegen.IsInVFSection()); |
| 83 | EXPECT_EQ(codegen.GetTileAddress("unknown_tile"), "0x0"); | 83 | EXPECT_EQ(codegen.GetTileAddress("unknown_tile"), "0x0"); |
| @@ -135,14 +135,14 @@ TEST(CCECodegenTest, EmitsTargetSpecificGuardsNamesAndVectorSetup) | |||
| 135 | auto body = std::make_shared<const ir::ReturnStmt>(ir::Span::Unknown()); | 135 | auto body = std::make_shared<const ir::ReturnStmt>(ir::Span::Unknown()); |
| 136 | 136 | ||
| 137 | CCECodegen cube_codegen(ir::SectionKind::Cube); | 137 | CCECodegen cube_codegen(ir::SectionKind::Cube); |
| 138 | - auto cube = cube_codegen.GenerateSingle(MakeProgram(body), "a3"); | 138 | + auto cube = cube_codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 139 | EXPECT_NE(cube.find("#if defined(__DAV_CUBE__)"), std::string::npos); | 139 | EXPECT_NE(cube.find("#if defined(__DAV_CUBE__)"), std::string::npos); |
| 140 | EXPECT_NE(cube.find("kernel_impl_cube("), std::string::npos); | 140 | EXPECT_NE(cube.find("kernel_impl_cube("), std::string::npos); |
| 141 | EXPECT_EQ(cube.find("set_mask_norm();"), std::string::npos); | 141 | EXPECT_EQ(cube.find("set_mask_norm();"), std::string::npos); |
| 142 | EXPECT_EQ(cube.find("set_vector_mask(-1, -1);"), std::string::npos); | 142 | EXPECT_EQ(cube.find("set_vector_mask(-1, -1);"), std::string::npos); |
| 143 | 143 | ||
| 144 | CCECodegen vector_codegen(ir::SectionKind::Vector); | 144 | CCECodegen vector_codegen(ir::SectionKind::Vector); |
| 145 | - auto vector = vector_codegen.GenerateSingle(MakeProgram(body), "a3"); | 145 | + auto vector = vector_codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201); |
| 146 | EXPECT_NE(vector.find("#if defined(__DAV_VEC__)"), std::string::npos); | 146 | EXPECT_NE(vector.find("#if defined(__DAV_VEC__)"), std::string::npos); |
| 147 | EXPECT_NE(vector.find("kernel_impl_vector("), std::string::npos); | 147 | EXPECT_NE(vector.find("kernel_impl_vector("), std::string::npos); |
| 148 | EXPECT_NE(vector.find("set_mask_norm();"), std::string::npos); | 148 | EXPECT_NE(vector.find("set_mask_norm();"), std::string::npos); |
| @@ -162,7 +162,7 @@ TEST(CCECodegenTest, EmitsInt64DynamicTensorDimensions) | |||
| 162 | auto body = std::make_shared<const ir::ReturnStmt>(ir::Span::Unknown()); | 162 | auto body = std::make_shared<const ir::ReturnStmt>(ir::Span::Unknown()); |
| 163 | 163 | ||
| 164 | CCECodegen codegen(ir::SectionKind::Vector); | 164 | CCECodegen codegen(ir::SectionKind::Vector); |
| 165 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {x}), "a5"); | 165 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {x}), npu::tile_fwk::NPUArch::DAV_3510); |
| 166 | EXPECT_NE(generated.find("int64_t __pypto_dyn_x_0"), std::string::npos); | 166 | EXPECT_NE(generated.find("int64_t __pypto_dyn_x_0"), std::string::npos); |
| 167 | EXPECT_NE(generated.find("int64_t __pypto_dyn_x_1"), std::string::npos); | 167 | EXPECT_NE(generated.find("int64_t __pypto_dyn_x_1"), std::string::npos); |
| 168 | EXPECT_EQ(generated.find("int32_t __pypto_dyn_x_0"), std::string::npos); | 168 | EXPECT_EQ(generated.find("int32_t __pypto_dyn_x_0"), std::string::npos); |
| @@ -183,12 +183,12 @@ TEST(CCECodegenTest, EmitsTargetSpecificTilingStructCopy) | |||
| 183 | auto program = MakeProgram(body, {tiling}, debug_info); | 183 | auto program = MakeProgram(body, {tiling}, debug_info); |
| 184 | 184 | ||
| 185 | CCECodegen cube_codegen(ir::SectionKind::Cube); | 185 | CCECodegen cube_codegen(ir::SectionKind::Cube); |
| 186 | - auto cube = cube_codegen.GenerateSingle(program, "a5"); | 186 | + auto cube = cube_codegen.GenerateSingle(program, npu::tile_fwk::NPUArch::DAV_3510); |
| 187 | EXPECT_NE(cube.find("copy_data_align64((uint8_t*)&tiling, (__gm__ uint8_t *)tiling_ptr"), std::string::npos); | 187 | EXPECT_NE(cube.find("copy_data_align64((uint8_t*)&tiling, (__gm__ uint8_t *)tiling_ptr"), std::string::npos); |
| 188 | EXPECT_EQ(cube.find("copy_gm_to_ubuf_align_v2"), std::string::npos); | 188 | EXPECT_EQ(cube.find("copy_gm_to_ubuf_align_v2"), std::string::npos); |
| 189 | 189 | ||
| 190 | CCECodegen vector_codegen(ir::SectionKind::Vector); | 190 | CCECodegen vector_codegen(ir::SectionKind::Vector); |
| 191 | - auto vector = vector_codegen.GenerateSingle(program, "a5"); | 191 | + auto vector = vector_codegen.GenerateSingle(program, npu::tile_fwk::NPUArch::DAV_3510); |
| 192 | EXPECT_NE(vector.find("tiling_in_ub"), std::string::npos); | 192 | EXPECT_NE(vector.find("tiling_in_ub"), std::string::npos); |
| 193 | EXPECT_NE(vector.find("copy_gm_to_ubuf_align_v2"), std::string::npos); | 193 | EXPECT_NE(vector.find("copy_gm_to_ubuf_align_v2"), std::string::npos); |
| 194 | EXPECT_NE(vector.find("copy_data_align64((uint8_t*)&tiling, (__ubuf__ uint8_t *)tiling_in_ub"), std::string::npos); | 194 | EXPECT_NE(vector.find("copy_data_align64((uint8_t*)&tiling, (__ubuf__ uint8_t *)tiling_in_ub"), std::string::npos); |
| @@ -199,11 +199,13 @@ TEST(CCECodegenTest, RejectsUnprojectedOrWrongTargetSections) | |||
| 199 | auto body = std::make_shared<const ir::ReturnStmt>(ir::Span::Unknown()); | 199 | auto body = std::make_shared<const ir::ReturnStmt>(ir::Span::Unknown()); |
| 200 | auto cube_section = std::make_shared<const ir::SectionStmt>(ir::SectionKind::Cube, body, ir::Span::Unknown()); | 200 | auto cube_section = std::make_shared<const ir::SectionStmt>(ir::SectionKind::Cube, body, ir::Span::Unknown()); |
| 201 | CCECodegen vector_codegen(ir::SectionKind::Vector); | 201 | CCECodegen vector_codegen(ir::SectionKind::Vector); |
| 202 | - EXPECT_THROW((void)vector_codegen.GenerateSingle(MakeProgram(cube_section), "a5"), pypto::ir::InternalError); | 202 | + EXPECT_THROW((void)vector_codegen.GenerateSingle(MakeProgram(cube_section), npu::tile_fwk::NPUArch::DAV_3510), |
| 203 | + pypto::ir::InternalError); | ||
| 203 | 204 | ||
| 204 | auto vf_section = std::make_shared<const ir::SectionStmt>(ir::SectionKind::VF, body, ir::Span::Unknown()); | 205 | auto vf_section = std::make_shared<const ir::SectionStmt>(ir::SectionKind::VF, body, ir::Span::Unknown()); |
| 205 | CCECodegen cube_codegen(ir::SectionKind::Cube); | 206 | CCECodegen cube_codegen(ir::SectionKind::Cube); |
| 206 | - EXPECT_THROW((void)cube_codegen.GenerateSingle(MakeProgram(vf_section), "a5"), pypto::ir::InternalError); | 207 | + EXPECT_THROW((void)cube_codegen.GenerateSingle(MakeProgram(vf_section), npu::tile_fwk::NPUArch::DAV_3510), |
| 208 | + pypto::ir::InternalError); | ||
| 207 | } | 209 | } |
| 208 | 210 | ||
| 209 | TEST(CCECodegenTest, RejectsProgramWithoutDebugInfo) | 211 | TEST(CCECodegenTest, RejectsProgramWithoutDebugInfo) |
| @@ -216,7 +218,7 @@ TEST(CCECodegenTest, RejectsProgramWithoutDebugInfo) | |||
| 216 | ir::Span::Unknown()); | 218 | ir::Span::Unknown()); |
| 217 | 219 | ||
| 218 | CCECodegen codegen(ir::SectionKind::Vector); | 220 | CCECodegen codegen(ir::SectionKind::Vector); |
| 219 | - EXPECT_THROW((void)codegen.GenerateSingle(program, "a5"), pypto::ir::InternalError); | 221 | + EXPECT_THROW((void)codegen.GenerateSingle(program, npu::tile_fwk::NPUArch::DAV_3510), pypto::ir::InternalError); |
| 220 | } | 222 | } |
| 221 | 223 | ||
| 222 | TEST(CCECodegenHeaderTest, CoversPointerAndBasicCodegenHelpers) | 224 | TEST(CCECodegenHeaderTest, CoversPointerAndBasicCodegenHelpers) |
| @@ -295,7 +297,7 @@ TEST(CCECodegenTest, GeneratesNativeLoopJumpsAndReturn) | |||
| 295 | ir::Span::Unknown()); | 297 | ir::Span::Unknown()); |
| 296 | 298 | ||
| 297 | CCECodegen codegen(ir::SectionKind::Vector); | 299 | CCECodegen codegen(ir::SectionKind::Vector); |
| 298 | - std::string generated = codegen.GenerateSingle(MakeProgram(body, {condition}), "a5"); | 300 | + std::string generated = codegen.GenerateSingle(MakeProgram(body, {condition}), npu::tile_fwk::NPUArch::DAV_3510); |
| 299 | 301 | ||
| 300 | EXPECT_NE(generated.find("for (int64_t i"), std::string::npos); | 302 | EXPECT_NE(generated.find("for (int64_t i"), std::string::npos); |
| 301 | EXPECT_NE(generated.find("continue;"), std::string::npos); | 303 | EXPECT_NE(generated.find("continue;"), std::string::npos); |
| @@ -321,7 +323,7 @@ TEST(CCECodegenTest, WritesBackLoopCarriedValueBeforeContinue) | |||
| 321 | std::vector<ir::VarPtr>{return_var}, ir::Span::Unknown()); | 323 | std::vector<ir::VarPtr>{return_var}, ir::Span::Unknown()); |
| 322 | 324 | ||
| 323 | CCECodegen codegen(ir::SectionKind::Vector); | 325 | CCECodegen codegen(ir::SectionKind::Vector); |
| 324 | - std::string generated = codegen.GenerateSingle(MakeProgram(for_loop), "a5"); | 326 | + std::string generated = codegen.GenerateSingle(MakeProgram(for_loop), npu::tile_fwk::NPUArch::DAV_3510); |
| 325 | 327 | ||
| 326 | EXPECT_NE(generated.find("acc = acc_updated;"), std::string::npos); | 328 | EXPECT_NE(generated.find("acc = acc_updated;"), std::string::npos); |
| 327 | EXPECT_NE(generated.find("continue;"), std::string::npos); | 329 | EXPECT_NE(generated.find("continue;"), std::string::npos); |
| @@ -351,7 +353,7 @@ TEST(CCECodegenTest, SnapshotsCyclicCarriedValuesBeforeForJump) | |||
| 351 | ir::Span::Unknown()); | 353 | ir::Span::Unknown()); |
| 352 | 354 | ||
| 353 | CCECodegen codegen(ir::SectionKind::Vector); | 355 | CCECodegen codegen(ir::SectionKind::Vector); |
| 354 | - auto generated = codegen.GenerateSingle(MakeProgram(loop), "a5"); | 356 | + auto generated = codegen.GenerateSingle(MakeProgram(loop), npu::tile_fwk::NPUArch::DAV_3510); |
| 355 | auto save_left = generated.find("int64_t left__next = right;"); | 357 | auto save_left = generated.find("int64_t left__next = right;"); |
| 356 | auto save_right = generated.find("int64_t right__next = left;"); | 358 | auto save_right = generated.find("int64_t right__next = left;"); |
| 357 | auto write_left = generated.find("left = left__next;"); | 359 | auto write_left = generated.find("left = left__next;"); |
| @@ -381,7 +383,7 @@ TEST(CCECodegenTest, SnapshotsWhileCarriedExpressionsBeforeWritingSlots) | |||
| 381 | ir::Span::Unknown()); | 383 | ir::Span::Unknown()); |
| 382 | 384 | ||
| 383 | CCECodegen codegen(ir::SectionKind::Vector); | 385 | CCECodegen codegen(ir::SectionKind::Vector); |
| 384 | - auto generated = codegen.GenerateSingle(MakeProgram(loop), "a5"); | 386 | + auto generated = codegen.GenerateSingle(MakeProgram(loop), npu::tile_fwk::NPUArch::DAV_3510); |
| 385 | auto save = generated.find("int64_t right__next = (left + right);"); | 387 | auto save = generated.find("int64_t right__next = (left + right);"); |
| 386 | auto write = generated.find("left = left__next;"); | 388 | auto write = generated.find("left = left__next;"); |
| 387 | ASSERT_NE(save, std::string::npos); | 389 | ASSERT_NE(save, std::string::npos); |
| @@ -412,7 +414,7 @@ TEST(CCECodegenTest, SnapshotsCarriedTupleStorageBeforeWritingSlots) | |||
| 412 | ir::Span::Unknown()); | 414 | ir::Span::Unknown()); |
| 413 | 415 | ||
| 414 | CCECodegen codegen(ir::SectionKind::Vector); | 416 | CCECodegen codegen(ir::SectionKind::Vector); |
| 415 | - auto generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 417 | + auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 416 | auto save = generated.find("right__next[1] = left[1];"); | 418 | auto save = generated.find("right__next[1] = left[1];"); |
| 417 | auto write = generated.find("left[0] = left__next[0];"); | 419 | auto write = generated.find("left[0] = left__next[0];"); |
| 418 | ASSERT_NE(save, std::string::npos); | 420 | ASSERT_NE(save, std::string::npos); |
| @@ -446,7 +448,7 @@ TEST(CCECodegenTest, SnapshotsSingleAggregateBeforePermutingItsLeaves) | |||
| 446 | debug_info->RegisterTupleTypeInfo(type, {ir::TupleTypeKind::NAMED_TUPLE, std::nullopt, {"first", "second"}}); | 448 | debug_info->RegisterTupleTypeInfo(type, {ir::TupleTypeKind::NAMED_TUPLE, std::nullopt, {"first", "second"}}); |
| 447 | 449 | ||
| 448 | CCECodegen codegen(ir::SectionKind::Vector); | 450 | CCECodegen codegen(ir::SectionKind::Vector); |
| 449 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {}, debug_info), "a5"); | 451 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {}, debug_info), npu::tile_fwk::NPUArch::DAV_3510); |
| 450 | auto save = generated.find("int64_t state__next__item_1 = state__item_0;"); | 452 | auto save = generated.find("int64_t state__next__item_1 = state__item_0;"); |
| 451 | auto write = generated.find("state__item_0 = state__next__item_0;"); | 453 | auto write = generated.find("state__item_0 = state__next__item_0;"); |
| 452 | ASSERT_NE(save, std::string::npos); | 454 | ASSERT_NE(save, std::string::npos); |
| @@ -468,7 +470,7 @@ TEST(CCECodegenTest, PreservesSingleIterationLoopForAddrReg) | |||
| 468 | std::vector<ir::VarPtr>{}, ir::Span::Unknown()); | 470 | std::vector<ir::VarPtr>{}, ir::Span::Unknown()); |
| 469 | 471 | ||
| 470 | CCECodegen codegen(ir::SectionKind::Vector); | 472 | CCECodegen codegen(ir::SectionKind::Vector); |
| 471 | - std::string generated = codegen.GenerateSingle(MakeProgram(for_loop), "a5"); | 473 | + std::string generated = codegen.GenerateSingle(MakeProgram(for_loop), npu::tile_fwk::NPUArch::DAV_3510); |
| 472 | 474 | ||
| 473 | EXPECT_NE(generated.find("for (int64_t i"), std::string::npos); | 475 | EXPECT_NE(generated.find("for (int64_t i"), std::string::npos); |
| 474 | EXPECT_NE(generated.find("AddrReg addr"), std::string::npos); | 476 | EXPECT_NE(generated.find("AddrReg addr"), std::string::npos); |
| @@ -496,7 +498,7 @@ TEST(CCECodegenTest, UsesOneBackingArrayForDynamicAndStaticTupleReads) | |||
| 496 | ir::Span::Unknown()); | 498 | ir::Span::Unknown()); |
| 497 | 499 | ||
| 498 | CCECodegen codegen(ir::SectionKind::Vector); | 500 | CCECodegen codegen(ir::SectionKind::Vector); |
| 499 | - std::string generated = codegen.GenerateSingle(MakeProgram(body, {index}), "a5"); | 501 | + std::string generated = codegen.GenerateSingle(MakeProgram(body, {index}), npu::tile_fwk::NPUArch::DAV_3510); |
| 500 | 502 | ||
| 501 | EXPECT_EQ(generated.find("const int64_t values"), std::string::npos); | 503 | EXPECT_EQ(generated.find("const int64_t values"), std::string::npos); |
| 502 | EXPECT_NE(generated.find("int64_t values"), std::string::npos); | 504 | EXPECT_NE(generated.find("int64_t values"), std::string::npos); |
| @@ -523,7 +525,7 @@ TEST(CCECodegenTest, SharesBackingArrayAcrossTupleAliases) | |||
| 523 | ir::Span::Unknown()); | 525 | ir::Span::Unknown()); |
| 524 | 526 | ||
| 525 | CCECodegen codegen(ir::SectionKind::Vector); | 527 | CCECodegen codegen(ir::SectionKind::Vector); |
| 526 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {index}), "a5"); | 528 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {index}), npu::tile_fwk::NPUArch::DAV_3510); |
| 527 | 529 | ||
| 528 | EXPECT_EQ(generated.find("const int64_t first"), std::string::npos); | 530 | EXPECT_EQ(generated.find("const int64_t first"), std::string::npos); |
| 529 | EXPECT_EQ(CountOccurrences(generated, "int64_t first"), 1); | 531 | EXPECT_EQ(CountOccurrences(generated, "int64_t first"), 1); |
| @@ -547,8 +549,8 @@ TEST(CCECodegenTest, ClearsTupleBackingArraysBetweenGenerations) | |||
| 547 | auto program = MakeProgram(body, {index}); | 549 | auto program = MakeProgram(body, {index}); |
| 548 | 550 | ||
| 549 | CCECodegen codegen(ir::SectionKind::Vector); | 551 | CCECodegen codegen(ir::SectionKind::Vector); |
| 550 | - auto first = codegen.GenerateSingle(program, "a5"); | 552 | + auto first = codegen.GenerateSingle(program, npu::tile_fwk::NPUArch::DAV_3510); |
| 551 | - auto second = codegen.GenerateSingle(program, "a5"); | 553 | + auto second = codegen.GenerateSingle(program, npu::tile_fwk::NPUArch::DAV_3510); |
| 552 | 554 | ||
| 553 | EXPECT_EQ(first.find("const int64_t values"), std::string::npos); | 555 | EXPECT_EQ(first.find("const int64_t values"), std::string::npos); |
| 554 | EXPECT_EQ(second.find("const int64_t values"), std::string::npos); | 556 | EXPECT_EQ(second.find("const int64_t values"), std::string::npos); |
| @@ -568,8 +570,8 @@ TEST(CCECodegenTest, ClearsTileTypeStateBetweenGenerations) | |||
| 568 | auto program = MakeProgram(body); | 570 | auto program = MakeProgram(body); |
| 569 | 571 | ||
| 570 | CCECodegen codegen(ir::SectionKind::Vector); | 572 | CCECodegen codegen(ir::SectionKind::Vector); |
| 571 | - auto first = codegen.GenerateSingle(program, "a5"); | 573 | + auto first = codegen.GenerateSingle(program, npu::tile_fwk::NPUArch::DAV_3510); |
| 572 | - auto second = codegen.GenerateSingle(program, "a5"); | 574 | + auto second = codegen.GenerateSingle(program, npu::tile_fwk::NPUArch::DAV_3510); |
| 573 | 575 | ||
| 574 | constexpr const char* tile_type_declaration = "using tile_Type = "; | 576 | constexpr const char* tile_type_declaration = "using tile_Type = "; |
| 575 | EXPECT_NE(first.find(tile_type_declaration), std::string::npos); | 577 | EXPECT_NE(first.find(tile_type_declaration), std::string::npos); |
| @@ -605,7 +607,7 @@ TEST(CCECodegenTest, MaterializesHomogeneousTileTuple) | |||
| 605 | ir::Span::Unknown()); | 607 | ir::Span::Unknown()); |
| 606 | 608 | ||
| 607 | CCECodegen codegen(ir::SectionKind::Vector); | 609 | CCECodegen codegen(ir::SectionKind::Vector); |
| 608 | - auto generated = codegen.GenerateSingle(MakeProgram(body, {index}), "a5"); | 610 | + auto generated = codegen.GenerateSingle(MakeProgram(body, {index}), npu::tile_fwk::NPUArch::DAV_3510); |
| 609 | 611 | ||
| 610 | EXPECT_NE(generated.find("tiles"), std::string::npos); | 612 | EXPECT_NE(generated.find("tiles"), std::string::npos); |
| 611 | EXPECT_NE(generated.find("[] = {tile0"), std::string::npos); | 613 | EXPECT_NE(generated.find("[] = {tile0"), std::string::npos); |
| @@ -698,7 +700,7 @@ TEST(CCECodegenTest, EmitsArrayAccessForUnmaterializedTupleVar) | |||
| 698 | auto body = std::make_shared<const ir::ReturnStmt>(ir::Span::Unknown()); | 700 | auto body = std::make_shared<const ir::ReturnStmt>(ir::Span::Unknown()); |
| 699 | auto program = MakeProgram(body); | 701 | auto program = MakeProgram(body); |
| 700 | CCECodegen codegen(ir::SectionKind::Vector); | 702 | CCECodegen codegen(ir::SectionKind::Vector); |
| 701 | - (void)codegen.GenerateSingle(program, "a5"); | 703 | + (void)codegen.GenerateSingle(program, npu::tile_fwk::NPUArch::DAV_3510); |
| 702 | EXPECT_EQ(codegen.GetExprAsCode(item), "values[1]"); | 704 | EXPECT_EQ(codegen.GetExprAsCode(item), "values[1]"); |
| 703 | } | 705 | } |
| 704 | 706 | ||
| @@ -714,7 +716,7 @@ TEST(CCECodegenTest, EmitsFieldAccessForUnmaterializedStructVar) | |||
| 714 | auto body = std::make_shared<const ir::ReturnStmt>(ir::Span::Unknown()); | 716 | auto body = std::make_shared<const ir::ReturnStmt>(ir::Span::Unknown()); |
| 715 | auto program = MakeProgram(body, {}, debug_info); | 717 | auto program = MakeProgram(body, {}, debug_info); |
| 716 | CCECodegen codegen(ir::SectionKind::Vector); | 718 | CCECodegen codegen(ir::SectionKind::Vector); |
| 717 | - (void)codegen.GenerateSingle(program, "a5"); | 719 | + (void)codegen.GenerateSingle(program, npu::tile_fwk::NPUArch::DAV_3510); |
| 718 | EXPECT_EQ(codegen.GetExprAsCode(item), "config.cols"); | 720 | EXPECT_EQ(codegen.GetExprAsCode(item), "config.cols"); |
| 719 | } | 721 | } |
| 720 | 722 | ||
| @@ -744,7 +746,7 @@ TEST(CCECodegenTest, EmitsUnusedIfPhiWithoutDce) | |||
| 744 | std::vector<ir::VarPtr>{unused_phi}, ir::Span::Unknown()); | 746 | std::vector<ir::VarPtr>{unused_phi}, ir::Span::Unknown()); |
| 745 | 747 | ||
| 746 | CCECodegen codegen(ir::SectionKind::Vector); | 748 | CCECodegen codegen(ir::SectionKind::Vector); |
| 747 | - std::string generated = codegen.GenerateSingle(MakeProgram(if_stmt, {condition}), "a5"); | 749 | + std::string generated = codegen.GenerateSingle(MakeProgram(if_stmt, {condition}), npu::tile_fwk::NPUArch::DAV_3510); |
| 748 | 750 | ||
| 749 | EXPECT_NE(generated.find("if (condition"), std::string::npos); | 751 | EXPECT_NE(generated.find("if (condition"), std::string::npos); |
| 750 | EXPECT_NE(generated.find("unused_phi"), std::string::npos); | 752 | EXPECT_NE(generated.find("unused_phi"), std::string::npos); |
| @@ -778,7 +780,8 @@ TEST(CCECodegenTest, MergesArrayTuplePhiThroughOneBackingArray) | |||
| 778 | ir::Span::Unknown()); | 780 | ir::Span::Unknown()); |
| 779 | 781 | ||
| 780 | CCECodegen codegen(ir::SectionKind::Vector); | 782 | CCECodegen codegen(ir::SectionKind::Vector); |
| 781 | - std::string generated = codegen.GenerateSingle(MakeProgram(body, {condition, index}), "a5"); | 783 | + std::string generated = codegen.GenerateSingle(MakeProgram(body, {condition, index}), |
| 784 | + npu::tile_fwk::NPUArch::DAV_3510); | ||
| 782 | 785 | ||
| 783 | EXPECT_EQ(CountOccurrences(generated, "int64_t selected[2];"), 1); | 786 | EXPECT_EQ(CountOccurrences(generated, "int64_t selected[2];"), 1); |
| 784 | EXPECT_NE(generated.find("selected[0] = left[0];"), std::string::npos); | 787 | EXPECT_NE(generated.find("selected[0] = left[0];"), std::string::npos); |
| @@ -801,7 +804,7 @@ TEST(CCECodegenTest, DoesNotMaterializeHomogeneousTupleOfTuples) | |||
| 801 | ir::Span::Unknown()); | 804 | ir::Span::Unknown()); |
| 802 | 805 | ||
| 803 | CCECodegen codegen(ir::SectionKind::Vector); | 806 | CCECodegen codegen(ir::SectionKind::Vector); |
| 804 | - std::string generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 807 | + std::string generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 805 | 808 | ||
| 806 | EXPECT_EQ(generated.find("nested[]"), std::string::npos); | 809 | EXPECT_EQ(generated.find("nested[]"), std::string::npos); |
| 807 | EXPECT_EQ(generated.find("nested[2]"), std::string::npos); | 810 | EXPECT_EQ(generated.find("nested[2]"), std::string::npos); |
| @@ -840,7 +843,8 @@ TEST(CCECodegenTest, FlattensAggregateTuplePhiIntoLeafSlots) | |||
| 840 | {ir::TupleTypeKind::NAMED_TUPLE, std::nullopt, {"first", "second"}}); | 843 | {ir::TupleTypeKind::NAMED_TUPLE, std::nullopt, {"first", "second"}}); |
| 841 | 844 | ||
| 842 | CCECodegen codegen(ir::SectionKind::Vector); | 845 | CCECodegen codegen(ir::SectionKind::Vector); |
| 843 | - std::string generated = codegen.GenerateSingle(MakeProgram(body, {condition}, debug_info), "a5"); | 846 | + std::string generated = codegen.GenerateSingle(MakeProgram(body, {condition}, debug_info), |
| 847 | + npu::tile_fwk::NPUArch::DAV_3510); | ||
| 844 | 848 | ||
| 845 | EXPECT_EQ(generated.find("selected[2]"), std::string::npos); | 849 | EXPECT_EQ(generated.find("selected[2]"), std::string::npos); |
| 846 | EXPECT_NE(generated.find("int64_t selected__item_0;"), std::string::npos); | 850 | EXPECT_NE(generated.find("int64_t selected__item_0;"), std::string::npos); |
| @@ -865,7 +869,8 @@ TEST(CCECodegenTest, WritesBackWhileCarriedValueBeforeBreak) | |||
| 865 | std::vector<ir::VarPtr>{return_var}, ir::Span::Unknown()); | 869 | std::vector<ir::VarPtr>{return_var}, ir::Span::Unknown()); |
| 866 | 870 | ||
| 867 | CCECodegen codegen(ir::SectionKind::Vector); | 871 | CCECodegen codegen(ir::SectionKind::Vector); |
| 868 | - std::string generated = codegen.GenerateSingle(MakeProgram(while_loop, {condition}), "a5"); | 872 | + std::string generated = codegen.GenerateSingle(MakeProgram(while_loop, {condition}), |
| 873 | + npu::tile_fwk::NPUArch::DAV_3510); | ||
| 869 | 874 | ||
| 870 | EXPECT_NE(generated.find("int64_t acc = 0;"), std::string::npos); | 875 | EXPECT_NE(generated.find("int64_t acc = 0;"), std::string::npos); |
| 871 | EXPECT_NE(generated.find("while (condition"), std::string::npos); | 876 | EXPECT_NE(generated.find("while (condition"), std::string::npos); |
| @@ -895,7 +900,7 @@ TEST(CCECodegenTest, GeneratesTensorDescriptorAndLoadFromAccessShape) | |||
| 895 | ir::Span::Unknown()); | 900 | ir::Span::Unknown()); |
| 896 | 901 | ||
| 897 | CCECodegen codegen(ir::SectionKind::Vector); | 902 | CCECodegen codegen(ir::SectionKind::Vector); |
| 898 | - std::string generated = codegen.GenerateSingle(MakeProgram(body, {input}), "a5"); | 903 | + std::string generated = codegen.GenerateSingle(MakeProgram(body, {input}), npu::tile_fwk::NPUArch::DAV_3510); |
| 899 | 904 | ||
| 900 | // The declaration's dims are DYNAMIC and each access resizes them in place, so the access | 905 | // The declaration's dims are DYNAMIC and each access resizes them in place, so the access |
| 901 | // shape shows up in the load's SetShape rather than in the hoisted type. | 906 | // shape shows up in the load's SetShape rather than in the hoisted type. |
| @@ -933,7 +938,7 @@ TEST(CCECodegenTest, ResolvesTensorAliasAndTransposeLayout) | |||
| 933 | ir::Span::Unknown()); | 938 | ir::Span::Unknown()); |
| 934 | 939 | ||
| 935 | CCECodegen codegen(ir::SectionKind::Vector); | 940 | CCECodegen codegen(ir::SectionKind::Vector); |
| 936 | - std::string generated = codegen.GenerateSingle(MakeProgram(body, {input}), "a5"); | 941 | + std::string generated = codegen.GenerateSingle(MakeProgram(body, {input}), npu::tile_fwk::NPUArch::DAV_3510); |
| 937 | 942 | ||
| 938 | EXPECT_NE(generated.find("inputStrideDim5, Layout::DN"), std::string::npos); | 943 | EXPECT_NE(generated.find("inputStrideDim5, Layout::DN"), std::string::npos); |
| 939 | EXPECT_NE(generated.find("inputStrideDim5(1, 1, 1, 1, 128)"), std::string::npos); | 944 | EXPECT_NE(generated.find("inputStrideDim5(1, 1, 1, 1, 128)"), std::string::npos); |
| @@ -962,7 +967,8 @@ TEST(CCECodegenTest, HoistsAutoDeclaredVFDestinations) | |||
| 962 | auto vf_section = std::make_shared<const ir::SectionStmt>(ir::SectionKind::VF, vf_body, ir::Span::Unknown()); | 967 | auto vf_section = std::make_shared<const ir::SectionStmt>(ir::SectionKind::VF, vf_body, ir::Span::Unknown()); |
| 963 | 968 | ||
| 964 | CCECodegen codegen(ir::SectionKind::Vector); | 969 | CCECodegen codegen(ir::SectionKind::Vector); |
| 965 | - std::string generated = codegen.GenerateSingle(MakeProgram(vf_section, {src0, src1, mask}), "a5"); | 970 | + std::string generated = codegen.GenerateSingle(MakeProgram(vf_section, {src0, src1, mask}), |
| 971 | + npu::tile_fwk::NPUArch::DAV_3510); | ||
| 966 | 972 | ||
| 967 | EXPECT_EQ(CountOccurrences(generated, "RegTensor<float> "), 2); | 973 | EXPECT_EQ(CountOccurrences(generated, "RegTensor<float> "), 2); |
| 968 | size_t first_decl = generated.find("RegTensor<float>"); | 974 | size_t first_decl = generated.find("RegTensor<float>"); |
| @@ -987,7 +993,7 @@ TEST(CCECodegenTest, HoistsDynamicVFLoopBoundAsUint16) | |||
| 987 | auto vf_section = std::make_shared<const ir::SectionStmt>(ir::SectionKind::VF, for_loop, ir::Span::Unknown()); | 993 | auto vf_section = std::make_shared<const ir::SectionStmt>(ir::SectionKind::VF, for_loop, ir::Span::Unknown()); |
| 988 | 994 | ||
| 989 | CCECodegen codegen(ir::SectionKind::Vector); | 995 | CCECodegen codegen(ir::SectionKind::Vector); |
| 990 | - std::string generated = codegen.GenerateSingle(MakeProgram(vf_section, {limit}), "a5"); | 996 | + std::string generated = codegen.GenerateSingle(MakeProgram(vf_section, {limit}), npu::tile_fwk::NPUArch::DAV_3510); |
| 991 | 997 | ||
| 992 | EXPECT_NE(generated.find("const uint16_t i_ub = (uint16_t)(limit)"), std::string::npos); | 998 | EXPECT_NE(generated.find("const uint16_t i_ub = (uint16_t)(limit)"), std::string::npos); |
| 993 | EXPECT_NE(generated.find("for (uint16_t i = 0; i < i_ub; i += 1)"), std::string::npos); | 999 | EXPECT_NE(generated.find("for (uint16_t i = 0; i < i_ub; i += 1)"), std::string::npos); |
| @@ -1015,7 +1021,7 @@ TEST(CCECodegenTest, EmitsKernelTileValidShapeGetters) | |||
| 1015 | }, | 1021 | }, |
| 1016 | ir::Span::Unknown()); | 1022 | ir::Span::Unknown()); |
| 1017 | CCECodegen codegen(ir::SectionKind::Vector); | 1023 | CCECodegen codegen(ir::SectionKind::Vector); |
| 1018 | - std::string generated = codegen.GenerateSingle(MakeProgram(body), "a5"); | 1024 | + std::string generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 1019 | EXPECT_NE(generated.find("(int64_t)(tile.GetValidRow())"), std::string::npos); | 1025 | EXPECT_NE(generated.find("(int64_t)(tile.GetValidRow())"), std::string::npos); |
| 1020 | EXPECT_NE(generated.find("(int64_t)(tile.GetValidCol())"), std::string::npos); | 1026 | EXPECT_NE(generated.find("(int64_t)(tile.GetValidCol())"), std::string::npos); |
| 1021 | } | 1027 | } |
| @@ -1076,7 +1082,7 @@ TEST(CCECodegenTest, AddsExpressionSpanToCodegenErrors) | |||
| 1076 | 1082 | ||
| 1077 | CCECodegen codegen(ir::SectionKind::Vector); | 1083 | CCECodegen codegen(ir::SectionKind::Vector); |
| 1078 | try { | 1084 | try { |
| 1079 | - (void)codegen.GenerateSingle(MakeProgram(body), "a5"); | 1085 | + (void)codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510); |
| 1080 | FAIL() << "Expected an unknown backend operation to fail code generation"; | 1086 | FAIL() << "Expected an unknown backend operation to fail code generation"; |
| 1081 | } catch (const std::exception& error) { | 1087 | } catch (const std::exception& error) { |
| 1082 | std::string message = error.what(); | 1088 | std::string message = error.what(); |
| @@ -1086,5 +1092,13 @@ TEST(CCECodegenTest, AddsExpressionSpanToCodegenErrors) | |||
| 1086 | } | 1092 | } |
| 1087 | } | 1093 | } |
| 1088 | 1094 | ||
| 1095 | +TEST(CCECodegenTest, RejectsUnknownArch) | ||
| 1096 | +{ | ||
| 1097 | + auto body = std::make_shared<const ir::ReturnStmt>(ir::Span::Unknown()); | ||
| 1098 | + CCECodegen codegen(ir::SectionKind::Vector); | ||
| 1099 | + EXPECT_THROW((void)codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_UNKNOWN), | ||
| 1100 | + npu::tile_fwk::Error); | ||
| 1101 | +} | ||
| 1102 | + | ||
| 1089 | } // namespace codegen | 1103 | } // namespace codegen |
| 1090 | } // namespace pypto | 1104 | } // namespace pypto |
| @@ -431,7 +431,7 @@ ir::ProgramPtr MakeSimtAtomicOpsProgram() | |||
| 431 | TEST(CCESimtCodegenTest, GeneratesContextCalleesMemoryAccessAndLaunch) | 431 | TEST(CCESimtCodegenTest, GeneratesContextCalleesMemoryAccessAndLaunch) |
| 432 | { | 432 | { |
| 433 | CCECodegen codegen(ir::SectionKind::Vector); | 433 | CCECodegen codegen(ir::SectionKind::Vector); |
| 434 | - std::string generated = codegen.GenerateSingle(MakeSimtProgram(), "a5"); | 434 | + std::string generated = codegen.GenerateSingle(MakeSimtProgram(), npu::tile_fwk::NPUArch::DAV_3510); |
| 435 | 435 | ||
| 436 | auto add_pos = generated.find("__simt_callee__ inline float add_scalar("); | 436 | auto add_pos = generated.find("__simt_callee__ inline float add_scalar("); |
| 437 | auto store_pos = generated.find("__simt_callee__ inline void store_scalar("); | 437 | auto store_pos = generated.find("__simt_callee__ inline void store_scalar("); |
| @@ -492,16 +492,19 @@ TEST(CCESimtCodegenTest, GeneratesContextCalleesMemoryAccessAndLaunch) | |||
| 492 | TEST(CCESimtCodegenTest, RejectsUnsupportedTargetAndArchitecture) | 492 | TEST(CCESimtCodegenTest, RejectsUnsupportedTargetAndArchitecture) |
| 493 | { | 493 | { |
| 494 | CCECodegen cube_codegen(ir::SectionKind::Cube); | 494 | CCECodegen cube_codegen(ir::SectionKind::Cube); |
| 495 | - EXPECT_THROW((void)cube_codegen.GenerateSingle(MakeSimtProgram(), "a5"), npu::tile_fwk::Error); | 495 | + EXPECT_THROW((void)cube_codegen.GenerateSingle(MakeSimtProgram(), npu::tile_fwk::NPUArch::DAV_3510), |
| 496 | + npu::tile_fwk::Error); | ||
| 496 | 497 | ||
| 497 | CCECodegen vector_codegen(ir::SectionKind::Vector); | 498 | CCECodegen vector_codegen(ir::SectionKind::Vector); |
| 498 | - EXPECT_THROW((void)vector_codegen.GenerateSingle(MakeSimtProgram(), "a3"), npu::tile_fwk::Error); | 499 | + EXPECT_THROW((void)vector_codegen.GenerateSingle(MakeSimtProgram(), npu::tile_fwk::NPUArch::DAV_2201), |
| 500 | + npu::tile_fwk::Error); | ||
| 499 | } | 501 | } |
| 500 | 502 | ||
| 501 | TEST(CCESimtCodegenTest, DoesNotInterceptOrdinaryKernelCallsWithMatchingCalleeName) | 503 | TEST(CCESimtCodegenTest, DoesNotInterceptOrdinaryKernelCallsWithMatchingCalleeName) |
| 502 | { | 504 | { |
| 503 | CCECodegen codegen(ir::SectionKind::Vector); | 505 | CCECodegen codegen(ir::SectionKind::Vector); |
| 504 | - std::string generated = codegen.GenerateSingle(MakeSimtCalleeNameCollisionProgram(), "a5"); | 506 | + std::string generated = codegen.GenerateSingle(MakeSimtCalleeNameCollisionProgram(), |
| 507 | + npu::tile_fwk::NPUArch::DAV_3510); | ||
| 505 | 508 | ||
| 506 | auto entry_pos = generated.find("__simt_vf__ __launch_bounds__(32) inline void collision_entry("); | 509 | auto entry_pos = generated.find("__simt_vf__ __launch_bounds__(32) inline void collision_entry("); |
| 507 | auto kernel_pos = generated.find("__aicore__ inline void kernel_impl_vector("); | 510 | auto kernel_pos = generated.find("__aicore__ inline void kernel_impl_vector("); |
| @@ -517,7 +520,7 @@ TEST(CCESimtCodegenTest, DoesNotInterceptOrdinaryKernelCallsWithMatchingCalleeNa | |||
| 517 | TEST(CCESimtCodegenTest, GeneratesRegisteredSynchronizationScalarCastAndMathOperations) | 520 | TEST(CCESimtCodegenTest, GeneratesRegisteredSynchronizationScalarCastAndMathOperations) |
| 518 | { | 521 | { |
| 519 | CCECodegen codegen(ir::SectionKind::Vector); | 522 | CCECodegen codegen(ir::SectionKind::Vector); |
| 520 | - std::string generated = codegen.GenerateSingle(MakeSimtScalarOpsProgram(), "a5"); | 523 | + std::string generated = codegen.GenerateSingle(MakeSimtScalarOpsProgram(), npu::tile_fwk::NPUArch::DAV_3510); |
| 521 | 524 | ||
| 522 | const std::vector<std::string> scalar_intrinsics = { | 525 | const std::vector<std::string> scalar_intrinsics = { |
| 523 | "__sync_workitems();", | 526 | "__sync_workitems();", |
| @@ -590,7 +593,7 @@ TEST(CCESimtCodegenTest, GeneratesRegisteredSynchronizationScalarCastAndMathOper | |||
| 590 | TEST(CCESimtCodegenTest, GeneratesRegisteredAtomicOperationsForTileAndTensor) | 593 | TEST(CCESimtCodegenTest, GeneratesRegisteredAtomicOperationsForTileAndTensor) |
| 591 | { | 594 | { |
| 592 | CCECodegen codegen(ir::SectionKind::Vector); | 595 | CCECodegen codegen(ir::SectionKind::Vector); |
| 593 | - std::string generated = codegen.GenerateSingle(MakeSimtAtomicOpsProgram(), "a5"); | 596 | + std::string generated = codegen.GenerateSingle(MakeSimtAtomicOpsProgram(), npu::tile_fwk::NPUArch::DAV_3510); |
| 594 | 597 | ||
| 595 | for (const auto& intrinsic : {"atomicAdd(", "atomicSub(", "atomicExch(", "atomicMax(", "atomicMin(", "atomicInc(", | 598 | for (const auto& intrinsic : {"atomicAdd(", "atomicSub(", "atomicExch(", "atomicMax(", "atomicMin(", "atomicInc(", |
| 596 | "atomicDec(", "atomicCAS(", "atomicAnd(", "atomicOr(", "atomicXOr("}) { | 599 | "atomicDec(", "atomicCAS(", "atomicAnd(", "atomicOr(", "atomicXOr("}) { |
| @@ -23,6 +23,7 @@ import enum | |||
| 23 | import struct | 23 | import struct |
| 24 | from typing import Any, Optional | 24 | from typing import Any, Optional |
| 25 | 25 | ||
| 26 | +from pypto.pypto_impl import NpuArch | ||
| 26 | from pypto.pypto_impl import ir as _ir_core | 27 | from pypto.pypto_impl import ir as _ir_core |
| 27 | from pypto.pypto_impl.ir import ( | 28 | from pypto.pypto_impl.ir import ( |
| 28 | AccPhase, | 29 | AccPhase, |
| @@ -1490,12 +1491,12 @@ def _apply_default_layout(tt: "TileType") -> None: | |||
| 1490 | from pypto_pro.runtime.jit import get_current_arch | 1491 | from pypto_pro.runtime.jit import get_current_arch |
| 1491 | 1492 | ||
| 1492 | arch = get_current_arch() | 1493 | arch = get_current_arch() |
| 1493 | - layout_dict = _DEFAULT_LAYOUTS_A5 if arch == "a5" else _DEFAULT_LAYOUTS_A3 | 1494 | + layout_dict = _DEFAULT_LAYOUTS_A5 if arch == NpuArch.DAV_3510 else _DEFAULT_LAYOUTS_A3 |
| 1494 | default_layout = layout_dict.get(tt.target_memory) | 1495 | default_layout = layout_dict.get(tt.target_memory) |
| 1495 | 1496 | ||
| 1496 | if tt.target_memory in (MemorySpace.ScaleLeft, MemorySpace.ScaleRight): | 1497 | if tt.target_memory in (MemorySpace.ScaleLeft, MemorySpace.ScaleRight): |
| 1497 | if default_layout is None: | 1498 | if default_layout is None: |
| 1498 | - raise InvalidVal(f"{tt.target_memory.name} is only supported on A5, got architecture '{arch}'") | 1499 | + raise InvalidVal(f"{tt.target_memory.name} is only supported on 3510, got architecture '{arch}'") |
| 1499 | 1500 | ||
| 1500 | if default_layout is None: | 1501 | if default_layout is None: |
| 1501 | return | 1502 | return |
| @@ -1525,7 +1526,7 @@ def _apply_default_layout(tt: "TileType") -> None: | |||
| 1525 | allowed_layouts.update({TensorLayout.ZZ, TensorLayout.NN}) | 1526 | allowed_layouts.update({TensorLayout.ZZ, TensorLayout.NN}) |
| 1526 | 1527 | ||
| 1527 | if ( | 1528 | if ( |
| 1528 | - arch == "a5" | 1529 | + arch == NpuArch.DAV_3510 |
| 1529 | and tt.target_memory in (MemorySpace.Left, MemorySpace.Right, MemorySpace.Acc) | 1530 | and tt.target_memory in (MemorySpace.Left, MemorySpace.Right, MemorySpace.Acc) |
| 1530 | and tt.layout in _REJECTED_LAYOUTS_ON_A5 | 1531 | and tt.layout in _REJECTED_LAYOUTS_ON_A5 |
| 1531 | ): | 1532 | ): |
| @@ -1913,7 +1914,7 @@ _A5_MATMUL_DTYPE_COMBOS = ( | |||
| 1913 | 1914 | ||
| 1914 | 1915 | ||
| 1915 | _MATMUL_DTYPE_COMBOS = { | 1916 | _MATMUL_DTYPE_COMBOS = { |
| 1916 | - "a5": _A5_MATMUL_DTYPE_COMBOS, | 1917 | + NpuArch.DAV_3510: _A5_MATMUL_DTYPE_COMBOS, |
| 1917 | } | 1918 | } |
| 1918 | 1919 | ||
| 1919 | 1920 | ||
| @@ -2817,12 +2818,12 @@ _A5_STORE_QUANT_COMBOS = ( | |||
| 2817 | ) | 2818 | ) |
| 2818 | 2819 | ||
| 2819 | _LAYOUT_DTYPE_COMBOS = { | 2820 | _LAYOUT_DTYPE_COMBOS = { |
| 2820 | - "load": {"a5": _A5_LOAD_COMBOS}, | 2821 | + "load": {NpuArch.DAV_3510: (_A5_LOAD_COMBOS, None)}, |
| 2821 | - "load_tile": {"a5": _A5_LOAD_COMBOS}, | 2822 | + "load_tile": {NpuArch.DAV_3510: (_A5_LOAD_COMBOS, None)}, |
| 2822 | - "store": {"a5": _A5_STORE_COMBOS, "a5_quant": _A5_STORE_QUANT_COMBOS}, | 2823 | + "store": {NpuArch.DAV_3510: (_A5_STORE_COMBOS, _A5_STORE_QUANT_COMBOS)}, |
| 2823 | - "store_tile": {"a5": _A5_STORE_COMBOS, "a5_quant": _A5_STORE_QUANT_COMBOS}, | 2824 | + "store_tile": {NpuArch.DAV_3510: (_A5_STORE_COMBOS, _A5_STORE_QUANT_COMBOS)}, |
| 2824 | - "move": {"a5": _A5_MOVE_COMBOS, "a5_quant": _A5_MOVE_QUANT_COMBOS}, | 2825 | + "move": {NpuArch.DAV_3510: (_A5_MOVE_COMBOS, _A5_MOVE_QUANT_COMBOS)}, |
| 2825 | - "insert": {"a5": _A5_INSERT_COMBOS}, | 2826 | + "insert": {NpuArch.DAV_3510: (_A5_INSERT_COMBOS, None)}, |
| 2826 | } | 2827 | } |
| 2827 | 2828 | ||
| 2828 | 2829 | ||
| @@ -2861,8 +2862,7 @@ def _check_layout_dtype( | |||
| 2861 | dst: destination operand —— tile 或 tensor。 | 2862 | dst: destination operand —— tile 或 tensor。 |
| 2862 | is_transpose: load 专用——降序 order 时 GM 有效排布为 DN(仅 load 传入); | 2863 | is_transpose: load 专用——降序 order 时 GM 有效排布为 DN(仅 load 传入); |
| 2863 | 为 None 时 GM 排布取 tensor 声明值(store 场景)。 | 2864 | 为 None 时 GM 排布取 tensor 声明值(store 场景)。 |
| 2864 | - quant: 量化路径时查 `a5_quant` 子表(store 带 scale), | 2865 | + quant: 量化路径时查量化组合表,非量化时查主组合表(按 NpuArch 索引)。 |
| 2865 | - 非量化时查 `a5` 主表;量化组合仅 Acc→GM 有效,不与其他路径混检。 | ||
| 2866 | """ | 2866 | """ |
| 2867 | from pypto_pro.runtime.jit import get_current_arch | 2867 | from pypto_pro.runtime.jit import get_current_arch |
| 2868 | 2868 | ||
| @@ -2870,11 +2870,13 @@ def _check_layout_dtype( | |||
| 2870 | combos_by_arch = _LAYOUT_DTYPE_COMBOS.get(op) | 2870 | combos_by_arch = _LAYOUT_DTYPE_COMBOS.get(op) |
| 2871 | if combos_by_arch is None: | 2871 | if combos_by_arch is None: |
| 2872 | return | 2872 | return |
| 2873 | - key = f"{arch}_quant" if quant else arch | 2873 | + combos_entry = combos_by_arch.get(arch) |
| 2874 | - combos = combos_by_arch.get(key) | 2874 | + if combos_entry is None: |
| 2875 | - if combos is None: | ||
| 2876 | # 该平台暂未配置支持表(如 a3)——不做硬拦截,后续按平台补表后自动生效。 | 2875 | # 该平台暂未配置支持表(如 a3)——不做硬拦截,后续按平台补表后自动生效。 |
| 2877 | return | 2876 | return |
| 2877 | + combos = combos_entry[1] if quant else combos_entry[0] | ||
| 2878 | + if combos is None: | ||
| 2879 | + return | ||
| 2878 | 2880 | ||
| 2879 | src_loc = _loc_name(src.type) | 2881 | src_loc = _loc_name(src.type) |
| 2880 | dst_loc = _loc_name(dst.type) | 2882 | dst_loc = _loc_name(dst.type) |
| @@ -3012,7 +3014,7 @@ def _get_memory_capacity(target_memory: MemorySpace) -> int: | |||
| 3012 | import logging | 3014 | import logging |
| 3013 | 3015 | ||
| 3014 | logging.getLogger(__name__).warning( | 3016 | logging.getLogger(__name__).warning( |
| 3015 | - "Cannot determine %s capacity for arch %r; skipping tile capacity validation. " | 3017 | + "Cannot determine %s capacity for arch %s; skipping tile capacity validation. " |
| 3016 | "Check that pypto_impl is loaded and the arch maps to an installed platform ini.", | 3018 | "Check that pypto_impl is loaded and the arch maps to an installed platform ini.", |
| 3017 | target_memory, | 3019 | target_memory, |
| 3018 | arch, | 3020 | arch, |
| @@ -137,7 +137,7 @@ def _validate_sync_pipes( | |||
| 137 | if wait_pipe not in supported_wait_pipes: | 137 | if wait_pipe not in supported_wait_pipes: |
| 138 | supported = ", ".join(str(pipe) for pipe in supported_wait_pipes) | 138 | supported = ", ".join(str(pipe) for pipe in supported_wait_pipes) |
| 139 | raise NotSupported( | 139 | raise NotSupported( |
| 140 | - f"unsupported A5 synchronization path{side}: {set_pipe} -> {wait_pipe}; " | 140 | + f"unsupported 3510 synchronization path{side}: {set_pipe} -> {wait_pipe}; " |
| 141 | f"supported wait_pipe values for {set_pipe}: {supported}" | 141 | f"supported wait_pipe values for {set_pipe}: {supported}" |
| 142 | ) | 142 | ) |
| 143 | 143 | ||
| @@ -18,6 +18,7 @@ from dataclasses import dataclass | |||
| 18 | import os | 18 | import os |
| 19 | 19 | ||
| 20 | from .._errors import InvalidArgument, InvalidVal, NotSupported, RuntimeFailure | 20 | from .._errors import InvalidArgument, InvalidVal, NotSupported, RuntimeFailure |
| 21 | +from .platform import NpuArch | ||
| 21 | 22 | ||
| 22 | CCE_BACKEND = "cce" | 23 | CCE_BACKEND = "cce" |
| 23 | 24 | ||
| @@ -56,14 +57,14 @@ class JitCompileConfig: | |||
| 56 | """Compile settings owned by one PyPTO Pro JIT backend.""" | 57 | """Compile settings owned by one PyPTO Pro JIT backend.""" |
| 57 | 58 | ||
| 58 | backend: str | 59 | backend: str |
| 59 | - kernel_targets: Mapping[str, Mapping[str, KernelTarget]] | 60 | + kernel_targets: Mapping[NpuArch, Mapping[str, KernelTarget]] |
| 60 | - memory_arch_flags: Mapping[str, str] | 61 | + memory_arch_flags: Mapping[NpuArch, str] |
| 61 | arch_flags: tuple[str, ...] | 62 | arch_flags: tuple[str, ...] |
| 62 | fatobj_flags: tuple[str, ...] | 63 | fatobj_flags: tuple[str, ...] |
| 63 | common_flags: tuple[str, ...] | 64 | common_flags: tuple[str, ...] |
| 64 | print_debug_flags: tuple[str, ...] | 65 | print_debug_flags: tuple[str, ...] |
| 65 | llvm_common_args: tuple[str, ...] | 66 | llvm_common_args: tuple[str, ...] |
| 66 | - llvm_arch_args: Mapping[str, tuple[str, ...]] | 67 | + llvm_arch_args: Mapping[NpuArch, tuple[str, ...]] |
| 67 | runtime_include_dirs: tuple[str, ...] | 68 | runtime_include_dirs: tuple[str, ...] |
| 68 | link_dirs: tuple[str, ...] | 69 | link_dirs: tuple[str, ...] |
| 69 | link_libraries: tuple[str, ...] | 70 | link_libraries: tuple[str, ...] |
| @@ -79,14 +80,13 @@ class JitCompileConfig: | |||
| 79 | self, | 80 | self, |
| 80 | *, | 81 | *, |
| 81 | toolkit_home: str, | 82 | toolkit_home: str, |
| 82 | - arch: str, | 83 | + arch: NpuArch, |
| 83 | target: KernelTarget, | 84 | target: KernelTarget, |
| 84 | enable_print_debug: bool, | 85 | enable_print_debug: bool, |
| 85 | ) -> list[str]: | 86 | ) -> list[str]: |
| 86 | - arch = arch.strip().lower() | ||
| 87 | variables = { | 87 | variables = { |
| 88 | "toolkit_home": toolkit_home, | 88 | "toolkit_home": toolkit_home, |
| 89 | - "mem_arch": self._resolve_memory_arch_flag(arch), | 89 | + "mem_arch": self._memory_arch_flag(arch), |
| 90 | "npu_arch": target.npu_arch, | 90 | "npu_arch": target.npu_arch, |
| 91 | } | 91 | } |
| 92 | common = self._format_values(self.common_flags, variables) | 92 | common = self._format_values(self.common_flags, variables) |
| @@ -97,12 +97,10 @@ class JitCompileConfig: | |||
| 97 | flags.extend(self._format_values(self.fatobj_flags, variables)) | 97 | flags.extend(self._format_values(self.fatobj_flags, variables)) |
| 98 | return [*flags, *common] | 98 | return [*flags, *common] |
| 99 | 99 | ||
| 100 | - def build_llvm_args(self, arch: str) -> list[str]: | 100 | + def build_llvm_args(self, arch: NpuArch) -> list[str]: |
| 101 | - arch = arch.strip().lower() | 101 | + arch_args = self.llvm_arch_args.get(arch) |
| 102 | - arch_key = self._resolve_arch_key(arch) | ||
| 103 | - arch_args = self.llvm_arch_args.get(arch_key) | ||
| 104 | if arch_args is None: | 102 | if arch_args is None: |
| 105 | - raise InvalidVal(f"JIT compile config does not define llvm_arch_args.{arch_key}") | 103 | + raise InvalidVal(f"JIT compile config does not define llvm_arch_args for arch '{arch}'") |
| 106 | return [*self.llvm_common_args, *arch_args] | 104 | return [*self.llvm_common_args, *arch_args] |
| 107 | 105 | ||
| 108 | def runtime_include_flags(self, ascend_home_path: str) -> list[str]: | 106 | def runtime_include_flags(self, ascend_home_path: str) -> list[str]: |
| @@ -123,49 +121,49 @@ class JitCompileConfig: | |||
| 123 | link_args.append(library if library.startswith("-l") else f"-l{library}") | 121 | link_args.append(library if library.startswith("-l") else f"-l{library}") |
| 124 | return link_args | 122 | return link_args |
| 125 | 123 | ||
| 126 | - def resolve_kernel_target(self, arch: str, *, has_cube: bool, has_vector: bool) -> KernelTarget: | 124 | + def resolve_kernel_target(self, arch: NpuArch, *, has_cube: bool, has_vector: bool) -> KernelTarget: |
| 127 | """Resolve once so compiler flags and launch geometry consume the same ABI.""" | 125 | """Resolve once so compiler flags and launch geometry consume the same ABI.""" |
| 128 | if not (has_cube or has_vector): | 126 | if not (has_cube or has_vector): |
| 129 | raise RuntimeFailure("Cannot compile a kernel without cube or vector code; add a target section") | 127 | raise RuntimeFailure("Cannot compile a kernel without cube or vector code; add a target section") |
| 130 | - arch_key = self._resolve_arch_key(arch.strip().lower()) | 128 | + arch_config = self.kernel_targets.get(arch) |
| 131 | - arch_config = self.kernel_targets.get(arch_key) | ||
| 132 | if arch_config is None: | 129 | if arch_config is None: |
| 133 | raise InvalidVal(f"JIT compile config does not define kernel_targets for arch '{arch}'") | 130 | raise InvalidVal(f"JIT compile config does not define kernel_targets for arch '{arch}'") |
| 134 | variant = "cube_vec" if has_cube and has_vector else "cube" if has_cube else "vec" | 131 | variant = "cube_vec" if has_cube and has_vector else "cube" if has_cube else "vec" |
| 135 | target = arch_config.get(variant) | 132 | target = arch_config.get(variant) |
| 136 | if target is None: | 133 | if target is None: |
| 137 | - raise InvalidVal(f"JIT compile config does not define kernel_targets.{arch_key}.{variant}") | 134 | + raise InvalidVal(f"JIT compile config does not define kernel_targets.{arch}.{variant}") |
| 138 | return target | 135 | return target |
| 139 | 136 | ||
| 140 | - def _resolve_memory_arch_flag(self, arch: str) -> str: | 137 | + def _memory_arch_flag(self, arch: NpuArch) -> str: |
| 141 | - arch_key = self._resolve_arch_key(arch) | 138 | + mem_arch = self.memory_arch_flags.get(arch) |
| 142 | - mem_arch = self.memory_arch_flags.get(arch_key) | ||
| 143 | if mem_arch is None: | 139 | if mem_arch is None: |
| 144 | raise InvalidVal(f"JIT compile config does not define memory_arch_flags for arch '{arch}'") | 140 | raise InvalidVal(f"JIT compile config does not define memory_arch_flags for arch '{arch}'") |
| 145 | return mem_arch | 141 | return mem_arch |
| 146 | 142 | ||
| 147 | - @staticmethod | ||
| 148 | - def _resolve_arch_key(arch: str) -> str: | ||
| 149 | - return {"a2": "a2a3", "a3": "a2a3"}.get(arch, arch) | ||
| 150 | - | ||
| 151 | 143 | ||
| 152 | _DEFAULT_CCE_JIT_COMPILE_CONFIG = JitCompileConfig( | 144 | _DEFAULT_CCE_JIT_COMPILE_CONFIG = JitCompileConfig( |
| 153 | backend=CCE_BACKEND, | 145 | backend=CCE_BACKEND, |
| 154 | kernel_targets={ | 146 | kernel_targets={ |
| 155 | - "a2a3": { | 147 | + NpuArch.DAV_1001:{ |
| 156 | "cube_vec": KernelTarget("dav-2201", aic_per_block=1, aiv_per_block=2, fat_object=True), | 148 | "cube_vec": KernelTarget("dav-2201", aic_per_block=1, aiv_per_block=2, fat_object=True), |
| 157 | "cube": KernelTarget("dav-2201", aic_per_block=1, aiv_per_block=0, fat_object=False), | 149 | "cube": KernelTarget("dav-2201", aic_per_block=1, aiv_per_block=0, fat_object=False), |
| 158 | "vec": KernelTarget("dav-2201", aic_per_block=0, aiv_per_block=1, fat_object=False), | 150 | "vec": KernelTarget("dav-2201", aic_per_block=0, aiv_per_block=1, fat_object=False), |
| 159 | }, | 151 | }, |
| 160 | - "a5": { | 152 | + NpuArch.DAV_2201: { |
| 153 | + "cube_vec": KernelTarget("dav-2201", aic_per_block=1, aiv_per_block=2, fat_object=True), | ||
| 154 | + "cube": KernelTarget("dav-2201", aic_per_block=1, aiv_per_block=0, fat_object=False), | ||
| 155 | + "vec": KernelTarget("dav-2201", aic_per_block=0, aiv_per_block=1, fat_object=False), | ||
| 156 | + }, | ||
| 157 | + NpuArch.DAV_3510: { | ||
| 161 | "cube_vec": KernelTarget("dav-3510", aic_per_block=1, aiv_per_block=2, fat_object=True), | 158 | "cube_vec": KernelTarget("dav-3510", aic_per_block=1, aiv_per_block=2, fat_object=True), |
| 162 | "cube": KernelTarget("dav-3510", aic_per_block=1, aiv_per_block=0, fat_object=False), | 159 | "cube": KernelTarget("dav-3510", aic_per_block=1, aiv_per_block=0, fat_object=False), |
| 163 | "vec": KernelTarget("dav-3510", aic_per_block=0, aiv_per_block=1, fat_object=False), | 160 | "vec": KernelTarget("dav-3510", aic_per_block=0, aiv_per_block=1, fat_object=False), |
| 164 | }, | 161 | }, |
| 165 | }, | 162 | }, |
| 166 | memory_arch_flags={ | 163 | memory_arch_flags={ |
| 167 | - "a2a3": "-DMEMORY_BASE", | 164 | + NpuArch.DAV_1001: "-DMEMORY_BASE", |
| 168 | - "a5": "-DREGISTER_BASE", | 165 | + NpuArch.DAV_2201: "-DMEMORY_BASE", |
| 166 | + NpuArch.DAV_3510: "-DREGISTER_BASE", | ||
| 169 | }, | 167 | }, |
| 170 | arch_flags=("--npu-arch={npu_arch}",), | 168 | arch_flags=("--npu-arch={npu_arch}",), |
| 171 | # ASC derives fat objects from the explicit __mix__ entry qualifier. | 169 | # ASC derives fat objects from the explicit __mix__ entry qualifier. |
| @@ -201,7 +199,7 @@ _DEFAULT_CCE_JIT_COMPILE_CONFIG = JitCompileConfig( | |||
| 201 | "--cce-auto-sync=off", | 199 | "--cce-auto-sync=off", |
| 202 | ), | 200 | ), |
| 203 | llvm_arch_args={ | 201 | llvm_arch_args={ |
| 204 | - "a2a3": ( | 202 | + NpuArch.DAV_1001: ( |
| 205 | "-include", | 203 | "-include", |
| 206 | "kernel_operator.h", | 204 | "kernel_operator.h", |
| 207 | "-O3", | 205 | "-O3", |
| @@ -211,7 +209,17 @@ _DEFAULT_CCE_JIT_COMPILE_CONFIG = JitCompileConfig( | |||
| 211 | "-Werror", | 209 | "-Werror", |
| 212 | "-Wno-cce-compat", | 210 | "-Wno-cce-compat", |
| 213 | ), | 211 | ), |
| 214 | - "a5": ( | 212 | + NpuArch.DAV_2201: ( |
| 213 | + "-include", | ||
| 214 | + "kernel_operator.h", | ||
| 215 | + "-O3", | ||
| 216 | + "--cce-disable-kernel-global-attr-check", | ||
| 217 | + "-Wno-parentheses-equality", | ||
| 218 | + "-Wno-unused-command-line-argument", | ||
| 219 | + "-Werror", | ||
| 220 | + "-Wno-cce-compat", | ||
| 221 | + ), | ||
| 222 | + NpuArch.DAV_3510: ( | ||
| 215 | "-mllvm", | 223 | "-mllvm", |
| 216 | "-tile-fusion-skip-reduceop-fusion=true", | 224 | "-tile-fusion-skip-reduceop-fusion=true", |
| 217 | "-mllvm", | 225 | "-mllvm", |
| @@ -37,6 +37,7 @@ from pypto.pypto_impl.ir import ConstInt, PtrType, ScalarType, TensorType, Tuple | |||
| 37 | from pypto_pro import DataType | 37 | from pypto_pro import DataType |
| 38 | from pypto_pro.language.typing.direction import TensorDirection | 38 | from pypto_pro.language.typing.direction import TensorDirection |
| 39 | from pypto_pro.runtime.compile_config import KernelTarget, get_jit_compile_config | 39 | from pypto_pro.runtime.compile_config import KernelTarget, get_jit_compile_config |
| 40 | +from pypto_pro.runtime.platform import NpuArch, normalize_arch | ||
| 40 | 41 | ||
| 41 | from .._errors import ( | 42 | from .._errors import ( |
| 42 | CommonInner, | 43 | CommonInner, |
| @@ -311,7 +312,9 @@ def _process_identity_tag() -> str: | |||
| 311 | return f"__{'_'.join(parts)}" if parts else "" | 312 | return f"__{'_'.join(parts)}" if parts else "" |
| 312 | 313 | ||
| 313 | 314 | ||
| 314 | -def _make_artifact_build_dir(prog, arch: str, test_prefix: str | None = None, tilingkey_suffix: str = "") -> str: | 315 | +def _make_artifact_build_dir( |
| 316 | + prog, arch: NpuArch, test_prefix: str | None = None, tilingkey_suffix: str = "" | ||
| 317 | +) -> str: | ||
| 315 | """The per-kernel build dir. All tilingkeys of one kernel share this dir; each concrete | 318 | """The per-kernel build dir. All tilingkeys of one kernel share this dir; each concrete |
| 316 | key gets a ``tk_<packed>`` subdir under it (see :func:`_make_tilingkey_dir`).""" | 319 | key gets a ``tk_<packed>`` subdir under it (see :func:`_make_tilingkey_dir`).""" |
| 317 | prog_name = getattr(prog, "name", None) or getattr(prog, "_name", None) | 320 | prog_name = getattr(prog, "name", None) or getattr(prog, "_name", None) |
| @@ -1140,7 +1143,7 @@ def _detect_print_debug_from_cpp(content: str) -> bool: | |||
| 1140 | 1143 | ||
| 1141 | def _build_bisheng_flags( | 1144 | def _build_bisheng_flags( |
| 1142 | toolkit_home: str, | 1145 | toolkit_home: str, |
| 1143 | - arch: str, | 1146 | + arch: NpuArch, |
| 1144 | target: KernelTarget, | 1147 | target: KernelTarget, |
| 1145 | has_cross_sync: bool, | 1148 | has_cross_sync: bool, |
| 1146 | enable_print_debug: bool, | 1149 | enable_print_debug: bool, |
| @@ -1159,7 +1162,7 @@ def _build_bisheng_flags( | |||
| 1159 | ) | 1162 | ) |
| 1160 | 1163 | ||
| 1161 | 1164 | ||
| 1162 | -def _build_llvm_args(arch: str) -> list[str]: | 1165 | +def _build_llvm_args(arch: NpuArch) -> list[str]: |
| 1163 | """Build architecture-specific LLVM/CCE arguments for C++ compilation.""" | 1166 | """Build architecture-specific LLVM/CCE arguments for C++ compilation.""" |
| 1164 | return get_jit_compile_config().build_llvm_args(arch) | 1167 | return get_jit_compile_config().build_llvm_args(arch) |
| 1165 | 1168 | ||
| @@ -1173,7 +1176,7 @@ def _static_signature_suffix(static_signature: tuple[tuple[int, int, int], ...]) | |||
| 1173 | 1176 | ||
| 1174 | def _prepare_codegen_inputs( | 1177 | def _prepare_codegen_inputs( |
| 1175 | kernel_def, | 1178 | kernel_def, |
| 1176 | - arch: str, | 1179 | + arch: NpuArch, |
| 1177 | tilingkey_packed: int | None = None, | 1180 | tilingkey_packed: int | None = None, |
| 1178 | out_dir: str | None = None, | 1181 | out_dir: str | None = None, |
| 1179 | datatype_hash: str | None = None, | 1182 | datatype_hash: str | None = None, |
| @@ -1290,7 +1293,7 @@ def _make_global_entry( | |||
| 1290 | 1293 | ||
| 1291 | def _codegen_target_cce( | 1294 | def _codegen_target_cce( |
| 1292 | prog, | 1295 | prog, |
| 1293 | - arch: str, | 1296 | + arch: NpuArch, |
| 1294 | build_dir: str, | 1297 | build_dir: str, |
| 1295 | target: ir.SectionKind, | 1298 | target: ir.SectionKind, |
| 1296 | declared_directions: dict[int, TensorDirection] | None = None, | 1299 | declared_directions: dict[int, TensorDirection] | None = None, |
| @@ -1312,7 +1315,7 @@ def _codegen_target_cce( | |||
| 1312 | if wrapper is None: | 1315 | if wrapper is None: |
| 1313 | raise | 1316 | raise |
| 1314 | raise wrapper(str(exc), span=span_of_spec_message(str(exc))) from None | 1317 | raise wrapper(str(exc), span=span_of_spec_message(str(exc))) from None |
| 1315 | - if "ffts_cross_core_sync" in cpp_code and arch == "a5": | 1318 | + if "ffts_cross_core_sync" in cpp_code and arch == NpuArch.DAV_3510: |
| 1316 | extra_headers = "#include <pto/npu/a5/custom/TSyncCVID.hpp>" | 1319 | extra_headers = "#include <pto/npu/a5/custom/TSyncCVID.hpp>" |
| 1317 | guard = { | 1320 | guard = { |
| 1318 | ir.SectionKind.Cube: "#if defined(__DAV_CUBE__)", | 1321 | ir.SectionKind.Cube: "#if defined(__DAV_CUBE__)", |
| @@ -1434,7 +1437,7 @@ def _assemble_cv_source( | |||
| 1434 | 1437 | ||
| 1435 | def _parse_and_codegen_targets( | 1438 | def _parse_and_codegen_targets( |
| 1436 | kernel_def, | 1439 | kernel_def, |
| 1437 | - arch: str, | 1440 | + arch: NpuArch, |
| 1438 | build_dir: str, | 1441 | build_dir: str, |
| 1439 | bound_signature=None, | 1442 | bound_signature=None, |
| 1440 | sanitizer: bool = False, | 1443 | sanitizer: bool = False, |
| @@ -1444,7 +1447,7 @@ def _parse_and_codegen_targets( | |||
| 1444 | With ``sanitizer`` enabled, each parsed target program is instrumented | 1447 | With ``sanitizer`` enabled, each parsed target program is instrumented |
| 1445 | (block.sanitizer_log records injected, one per detection type and | 1448 | (block.sanitizer_log records injected, one per detection type and |
| 1446 | sanitizer_log pointer + capacity scalar appended to the kernel signature); | 1449 | sanitizer_log pointer + capacity scalar appended to the kernel signature); |
| 1447 | - the flag is carried on the returned CodegenResults.""" | 1450 | + the flag is carried on the returned CodegenResults.""" |
| 1448 | programs = {} | 1451 | programs = {} |
| 1449 | matched = {} | 1452 | matched = {} |
| 1450 | requires_simt = False | 1453 | requires_simt = False |
| @@ -1543,7 +1546,7 @@ def _runtime_link_args(ascend_home_path: str) -> list[str]: | |||
| 1543 | def _run_bisheng( | 1546 | def _run_bisheng( |
| 1544 | bisheng_path: str, | 1547 | bisheng_path: str, |
| 1545 | flags: list[str], | 1548 | flags: list[str], |
| 1546 | - arch: str, | 1549 | + arch: NpuArch, |
| 1547 | paths: CompilePaths, | 1550 | paths: CompilePaths, |
| 1548 | link_args: list[str], | 1551 | link_args: list[str], |
| 1549 | compile_timeout: int, | 1552 | compile_timeout: int, |
| @@ -1574,7 +1577,7 @@ def _run_bisheng( | |||
| 1574 | 1577 | ||
| 1575 | def _compile_shared_library( | 1578 | def _compile_shared_library( |
| 1576 | paths: CompilePaths, | 1579 | paths: CompilePaths, |
| 1577 | - arch: str, | 1580 | + arch: NpuArch, |
| 1578 | generated: GeneratedKernel, | 1581 | generated: GeneratedKernel, |
| 1579 | clean_up: bool, | 1582 | clean_up: bool, |
| 1580 | compile_timeout: int, | 1583 | compile_timeout: int, |
| @@ -1635,7 +1638,7 @@ def _compile_shared_library( | |||
| 1635 | 1638 | ||
| 1636 | def _codegen( | 1639 | def _codegen( |
| 1637 | prog, | 1640 | prog, |
| 1638 | - arch: str, | 1641 | + arch: NpuArch, |
| 1639 | clean_up: bool, | 1642 | clean_up: bool, |
| 1640 | tilingkey_packed: int | None = None, | 1643 | tilingkey_packed: int | None = None, |
| 1641 | out_dir: str | None = None, | 1644 | out_dir: str | None = None, |
| @@ -1720,19 +1723,19 @@ def _build_jit_so( | |||
| 1720 | return _compile_shared_library(paths, arch, generated, clean_up, compile_timeout) | 1723 | return _compile_shared_library(paths, arch, generated, clean_up, compile_timeout) |
| 1721 | 1724 | ||
| 1722 | 1725 | ||
| 1723 | -def get_current_arch() -> str: | 1726 | +def get_current_arch() -> NpuArch: |
| 1724 | """Return the arch configured in the current process environment.""" | 1727 | """Return the arch configured in the current process environment.""" |
| 1725 | - return os.environ.get("PYPTOPRO_JIT_ARCH", "a5") | 1728 | + raw = os.environ.get("PYPTOPRO_JIT_ARCH") |
| 1729 | + return normalize_arch(raw) if raw else NpuArch.DAV_3510 | ||
| 1726 | 1730 | ||
| 1727 | 1731 | ||
| 1728 | -def _setup_arch_env(arch: str) -> str: | 1732 | +def _setup_arch_env(arch: NpuArch) -> NpuArch: |
| 1729 | """Validate *arch* and export the env vars used by compilation.""" | 1733 | """Validate *arch* and export the env vars used by compilation.""" |
| 1730 | if not arch: | 1734 | if not arch: |
| 1731 | raise InvalidVal("arch must not be empty") | 1735 | raise InvalidVal("arch must not be empty") |
| 1732 | - arch = arch.strip().lower() | 1736 | + if arch != NpuArch.DAV_3510: |
| 1733 | - if arch != "a5": | 1737 | + raise NotSupported(f"PyPTO Pro only supports arch '3510', got '{arch}'") |
| 1734 | - raise NotSupported(f"PyPTO Pro only supports arch 'a5', got {arch!r}") | 1738 | + os.environ["PYPTOPRO_JIT_ARCH"] = str(arch) |
| 1735 | - os.environ["PYPTOPRO_JIT_ARCH"] = arch | ||
| 1736 | return arch | 1739 | return arch |
| 1737 | 1740 | ||
| 1738 | 1741 | ||
| @@ -1960,7 +1963,8 @@ def jit( | |||
| 1960 | performs lazy compilation on first call and supports bracket-launch syntax. | 1963 | performs lazy compilation on first call and supports bracket-launch syntax. |
| 1961 | 1964 | ||
| 1962 | Args: | 1965 | Args: |
| 1963 | - arch: Target architecture ("a5", or None for auto-detect). | 1966 | + arch: Target architecture ("3510" -- the __NPU_ARCH__ version; "a5" is a |
| 1967 | + deprecated alias; or None for auto-detect). | ||
| 1964 | auto_mutex: Boolean flag to enable automatic mutex lock/unlock insertion. | 1968 | auto_mutex: Boolean flag to enable automatic mutex lock/unlock insertion. |
| 1965 | name: Custom kernel name for build artifact path isolation. | 1969 | name: Custom kernel name for build artifact path isolation. |
| 1966 | pipeline: PipelineConfig for automatic preload pipeline transformation. | 1970 | pipeline: PipelineConfig for automatic preload pipeline transformation. |
| @@ -1968,7 +1972,7 @@ def jit( | |||
| 1968 | 1972 | ||
| 1969 | Usage (Tile-programming kernel with bracket-launch):: | 1973 | Usage (Tile-programming kernel with bracket-launch):: |
| 1970 | 1974 | ||
| 1971 | - @pl.jit(arch="a5") | 1975 | + @pl.jit(arch="3510") |
| 1972 | def add_kernel( | 1976 | def add_kernel( |
| 1973 | x: pl.Tensor[[64, 128], pl.DT_FP16], | 1977 | x: pl.Tensor[[64, 128], pl.DT_FP16], |
| 1974 | y: pl.Tensor[[64, 128], pl.DT_FP16], | 1978 | y: pl.Tensor[[64, 128], pl.DT_FP16], |
| @@ -1982,6 +1986,9 @@ def jit( | |||
| 1982 | if not isinstance(auto_mutex, bool): | 1986 | if not isinstance(auto_mutex, bool): |
| 1983 | raise TypeError(f"auto_mutex must be a bool, got {type(auto_mutex).__name__}") | 1987 | raise TypeError(f"auto_mutex must be a bool, got {type(auto_mutex).__name__}") |
| 1984 | 1988 | ||
| 1989 | + if arch is not None: | ||
| 1990 | + arch = normalize_arch(arch) | ||
| 1991 | + | ||
| 1985 | # Build the tilingkey schema eagerly so malformed schemas fail at decoration time. | 1992 | # Build the tilingkey schema eagerly so malformed schemas fail at decoration time. |
| 1986 | tilingkey_schema = None | 1993 | tilingkey_schema = None |
| 1987 | if tiling_key is not None: | 1994 | if tiling_key is not None: |
| @@ -2237,10 +2244,9 @@ class _TileJitKernel: | |||
| 2237 | platform_arch = get_platform_info().arch | 2244 | platform_arch = get_platform_info().arch |
| 2238 | if self._arch is None: | 2245 | if self._arch is None: |
| 2239 | self._arch = platform_arch | 2246 | self._arch = platform_arch |
| 2240 | - elif self._arch.strip().lower() != platform_arch: | 2247 | + elif self._arch != platform_arch: |
| 2241 | - raise NotSupported( | 2248 | + plat = f"'{platform_arch}'" if platform_arch is not None else "unknown" |
| 2242 | - f"JIT arch {self._arch!r} does not match current platform arch {platform_arch!r}" | 2249 | + raise NotSupported(f"JIT arch '{self._arch}' does not match current platform arch {plat}") |
| 2243 | - ) | ||
| 2244 | 2250 | ||
| 2245 | @property | 2251 | @property |
| 2246 | def arch(self): | 2252 | def arch(self): |
| @@ -302,7 +302,7 @@ def _prepare_infer_cpp( | |||
| 302 | return infer_cpp_path | 302 | return infer_cpp_path |
| 303 | 303 | ||
| 304 | 304 | ||
| 305 | -def generate_binary_headers(kernel, arch="a5") -> str: | 305 | +def generate_binary_headers(kernel, arch: str = "3510") -> str: |
| 306 | """Generate the TilingData and TilingKey headers required by binary delivery.""" | 306 | """Generate the TilingData and TilingKey headers required by binary delivery.""" |
| 307 | from pypto_pro.runtime.jit import ( | 307 | from pypto_pro.runtime.jit import ( |
| 308 | _artifact_prefix_from_filename, | 308 | _artifact_prefix_from_filename, |
| @@ -310,6 +310,7 @@ def generate_binary_headers(kernel, arch="a5") -> str: | |||
| 310 | _setup_arch_env, | 310 | _setup_arch_env, |
| 311 | _TileJitKernel, | 311 | _TileJitKernel, |
| 312 | ) | 312 | ) |
| 313 | + from pypto_pro.runtime.platform import normalize_arch | ||
| 313 | 314 | ||
| 314 | if not isinstance(kernel, _TileJitKernel): | 315 | if not isinstance(kernel, _TileJitKernel): |
| 315 | raise InvalidType("generate_binary_headers() expects a @pl.jit kernel") | 316 | raise InvalidType("generate_binary_headers() expects a @pl.jit kernel") |
| @@ -319,7 +320,7 @@ def generate_binary_headers(kernel, arch="a5") -> str: | |||
| 319 | f"'{kernel.__name__}' has none; binary delivery needs a tilingkey header" | 320 | f"'{kernel.__name__}' has none; binary delivery needs a tilingkey header" |
| 320 | ) | 321 | ) |
| 321 | 322 | ||
| 322 | - arch = _setup_arch_env(arch) | 323 | + arch = _setup_arch_env(normalize_arch(arch)) |
| 323 | schema = kernel.tilingkey_schema | 324 | schema = kernel.tilingkey_schema |
| 324 | valid_combos = schema.enumerate_valid() | 325 | valid_combos = schema.enumerate_valid() |
| 325 | if not valid_combos: | 326 | if not valid_combos: |
| @@ -338,7 +339,7 @@ def generate_binary_headers(kernel, arch="a5") -> str: | |||
| 338 | return binary_dir | 339 | return binary_dir |
| 339 | 340 | ||
| 340 | 341 | ||
| 341 | -def prepare_binary_headers(op_path: str, arch="a5") -> str: | 342 | +def prepare_binary_headers(op_path: str, arch: str = "3510") -> str: |
| 342 | """Load the sole ``@pl.jit`` kernel in ``op_path`` and prepare its binary-delivery headers.""" | 343 | """Load the sole ``@pl.jit`` kernel in ``op_path`` and prepare its binary-delivery headers.""" |
| 343 | return generate_binary_headers(_load_kernel(op_path), arch) | 344 | return generate_binary_headers(_load_kernel(op_path), arch) |
| 344 | 345 | ||
| @@ -579,7 +580,7 @@ def pypto_compile_op( | |||
| 579 | code_channel=-1, | 580 | code_channel=-1, |
| 580 | op_compile_option="{}", | 581 | op_compile_option="{}", |
| 581 | extend_options=None, | 582 | extend_options=None, |
| 582 | - arch="a5", | 583 | + arch: str = "3510", |
| 583 | ): | 584 | ): |
| 584 | """PyPTO leaf replacing ``asc_op_compiler.compile_op``. Signature-compatible; ``cce_file`` is the PyPTO | 585 | """PyPTO leaf replacing ``asc_op_compiler.compile_op``. Signature-compatible; ``cce_file`` is the PyPTO |
| 585 | DSL ``.py``. Writes the flat ``kernel_meta`` artifacts + ``<kernel>.o``/``.json`` and records the json | 586 | DSL ``.py``. Writes the flat ``kernel_meta`` artifacts + ``<kernel>.o``/``.json`` and records the json |
| @@ -594,7 +595,9 @@ def pypto_compile_op( | |||
| 594 | 595 | ||
| 595 | extend_options = extend_options or {} | 596 | extend_options = extend_options or {} |
| 596 | kernel_name = _op_info_get(op_info, "kernel_name") | 597 | kernel_name = _op_info_get(op_info, "kernel_name") |
| 597 | - arch = _setup_arch_env(arch) | 598 | + from pypto_pro.runtime.platform import normalize_arch |
| 599 | + | ||
| 600 | + arch = _setup_arch_env(normalize_arch(arch)) | ||
| 598 | opt = _setup_options(op_info, compile_options, op_compile_option, extend_options) | 601 | opt = _setup_options(op_info, compile_options, op_compile_option, extend_options) |
| 599 | 602 | ||
| 600 | kernel = _load_kernel(cce_file) | 603 | kernel = _load_kernel(cce_file) |
| @@ -30,16 +30,47 @@ from __future__ import annotations | |||
| 30 | from dataclasses import dataclass | 30 | from dataclasses import dataclass |
| 31 | import logging | 31 | import logging |
| 32 | from typing import Optional | 32 | from typing import Optional |
| 33 | +import warnings | ||
| 34 | + | ||
| 35 | +from pypto.pypto_impl import NpuArch | ||
| 36 | + | ||
| 37 | +from .._errors import InvalidVal | ||
| 33 | 38 | ||
| 34 | logger = logging.getLogger(__name__) | 39 | logger = logging.getLogger(__name__) |
| 35 | 40 | ||
| 36 | # NPUArch string → compilation arch mapping | 41 | # NPUArch string → compilation arch mapping |
| 37 | _ARCH_MAP = { | 42 | _ARCH_MAP = { |
| 38 | - "DAV_1001": "a3", # 910 | 43 | + "DAV_1001": NpuArch.DAV_1001, |
| 39 | - "DAV_2201": "a3", # 910B/910C | 44 | + "DAV_2201": NpuArch.DAV_2201, |
| 40 | - "DAV_3510": "a5", # 950 | 45 | + "DAV_3510": NpuArch.DAV_3510, |
| 41 | } | 46 | } |
| 42 | 47 | ||
| 48 | +_ARCH_INPUT_TO_ENUM = {str(member): member for member in NpuArch.__members__.values() if member != NpuArch.DAV_UNKNOWN} | ||
| 49 | +_LEGACY_TO_CANONICAL = {"a5": "3510", "a2": "2201", "a3": "2201"} | ||
| 50 | +_DEPRECATED_INPUTS = {"a5"} | ||
| 51 | + | ||
| 52 | + | ||
| 53 | +def normalize_arch(value: str | NpuArch) -> NpuArch: | ||
| 54 | + """Resolve any accepted arch input to its canonical NpuArch. | ||
| 55 | + | ||
| 56 | + Accepts the __NPU_ARCH__ version number ("3510"), NpuArch values, and | ||
| 57 | + legacy internal names; "a5" emits a DeprecationWarning and resolves | ||
| 58 | + to DAV_3510. Unregistered NpuArch values collapse to DAV_UNKNOWN, | ||
| 59 | + which downstream checks reject. | ||
| 60 | + """ | ||
| 61 | + if isinstance(value, NpuArch): | ||
| 62 | + return _ARCH_INPUT_TO_ENUM.get(str(value), NpuArch.DAV_UNKNOWN) | ||
| 63 | + text = value.strip().lower() | ||
| 64 | + canonical = _LEGACY_TO_CANONICAL.get(text) | ||
| 65 | + if canonical is not None: | ||
| 66 | + if text in _DEPRECATED_INPUTS: | ||
| 67 | + warnings.warn(f"arch {value!r} is deprecated; use arch {canonical!r}", DeprecationWarning, stacklevel=2) | ||
| 68 | + text = canonical | ||
| 69 | + arch = _ARCH_INPUT_TO_ENUM.get(text) | ||
| 70 | + if arch is None: | ||
| 71 | + raise InvalidVal(f"unknown arch {value!r}; expected an __NPU_ARCH__ version name such as '3510'") | ||
| 72 | + return arch | ||
| 73 | + | ||
| 43 | 74 | ||
| 44 | @dataclass | 75 | @dataclass |
| 45 | class PlatformInfo: | 76 | class PlatformInfo: |
| @@ -54,15 +85,16 @@ class PlatformInfo: | |||
| 54 | vector_core_num: int = 0 | 85 | vector_core_num: int = 0 |
| 55 | 86 | ||
| 56 | @property | 87 | @property |
| 57 | - def arch(self) -> str: | 88 | + def arch(self) -> Optional[NpuArch]: |
| 58 | """Infer compilation arch from SOC version string. | 89 | """Infer compilation arch from SOC version string. |
| 59 | 90 | ||
| 60 | Returns: | 91 | Returns: |
| 61 | - "a5" for DAV_3510 (950 series), "a3" for DAV_2201/DAV_1001, "" if unknown. | 92 | + NpuArch.DAV_3510 for DAV_3510 (950 series), NpuArch.DAV_2201 for DAV_2201, |
| 93 | + NpuArch.DAV_1001 for DAV_1001, None if unknown. | ||
| 62 | """ | 94 | """ |
| 63 | if not self.soc_version: | 95 | if not self.soc_version: |
| 64 | - return "" | 96 | + return None |
| 65 | - return _ARCH_MAP.get(self.soc_version, "a3") | 97 | + return _ARCH_MAP.get(self.soc_version, NpuArch.DAV_2201) |
| 66 | 98 | ||
| 67 | 99 | ||
| 68 | _cached_info: Optional[PlatformInfo] = None | 100 | _cached_info: Optional[PlatformInfo] = None |
| @@ -128,11 +160,11 @@ def _get_aiv_core_num() -> int: | |||
| 128 | return 0 | 160 | return 0 |
| 129 | 161 | ||
| 130 | 162 | ||
| 131 | -def get_memory_limit(arch: str, memory_space: str) -> int: | 163 | +def get_memory_limit(arch: NpuArch, memory_space: str) -> int: |
| 132 | """Query on-chip buffer capacity (bytes) for the target arch. | 164 | """Query on-chip buffer capacity (bytes) for the target arch. |
| 133 | 165 | ||
| 134 | Args: | 166 | Args: |
| 135 | - arch: Compilation arch ("a5", from PYPTOPRO_JIT_ARCH). | 167 | + arch: Compilation arch (NpuArch, from get_current_arch). |
| 136 | memory_space: pypto_pro MemorySpace name (e.g. "Vec"/"Mat"/"Left"/ | 168 | memory_space: pypto_pro MemorySpace name (e.g. "Vec"/"Mat"/"Left"/ |
| 137 | "Right"/"Acc") of the buffer to query. | 169 | "Right"/"Acc") of the buffer to query. |
| 138 | 170 | ||
| @@ -179,7 +211,7 @@ def get_platform_info(force_refresh: bool = False) -> PlatformInfo: | |||
| 179 | logger.info( | 211 | logger.info( |
| 180 | "Platform: %s (arch=%s), core_num=%d, cube_core_num=%d, vector_core_num=%d", | 212 | "Platform: %s (arch=%s), core_num=%d, cube_core_num=%d, vector_core_num=%d", |
| 181 | info.soc_version, | 213 | info.soc_version, |
| 182 | - info.arch, | 214 | + info.arch if info.arch is not None else "unknown", |
| 183 | info.core_num, | 215 | info.core_num, |
| 184 | info.cube_core_num, | 216 | info.cube_core_num, |
| 185 | info.vector_core_num, | 217 | info.vector_core_num, |
| @@ -22,6 +22,18 @@ using namespace npu::tile_fwk; | |||
| 22 | namespace pypto { | 22 | namespace pypto { |
| 23 | void BindPlatform(py::module_& m) | 23 | void BindPlatform(py::module_& m) |
| 24 | { | 24 | { |
| 25 | + auto arch_enum = py::enum_<NPUArch>(m, "NpuArch", py::arithmetic()); | ||
| 26 | + arch_enum.value("DAV_1001", NPUArch::DAV_1001); | ||
| 27 | + arch_enum.value("DAV_2201", NPUArch::DAV_2201); | ||
| 28 | + arch_enum.value("DAV_3510", NPUArch::DAV_3510); | ||
| 29 | + arch_enum.value("DAV_3003", NPUArch::DAV_3003); | ||
| 30 | + arch_enum.value("DAV_3113", NPUArch::DAV_3113); | ||
| 31 | + arch_enum.value("DAV_UNKNOWN", NPUArch::DAV_UNKNOWN); | ||
| 32 | + // str() must yield the canonical __NPU_ARCH__ number ("3510"): the string form crosses | ||
| 33 | + // the std::string pybind boundaries (env var, bisheng flags, generated paths). | ||
| 34 | + arch_enum.attr("__str__") = py::cpp_function([](NPUArch self) { return std::to_string(static_cast<int>(self)); }, | ||
| 35 | + py::is_method(arch_enum), py::name("__str__")); | ||
| 36 | + | ||
| 25 | m.def("GetNPUArch", []() -> std::string { | 37 | m.def("GetNPUArch", []() -> std::string { |
| 26 | auto npuArch = Platform::Instance().GetSoc().GetNPUArch(); | 38 | auto npuArch = Platform::Instance().GetSoc().GetNPUArch(); |
| 27 | return NPUArchToString(npuArch); | 39 | return NPUArchToString(npuArch); |
| @@ -33,8 +45,7 @@ void BindPlatform(py::module_& m) | |||
| 33 | 45 | ||
| 34 | m.def("GetAIVCoreNum", []() -> size_t { return Platform::Instance().GetSoc().GetAIVCoreNum(); }); | 46 | m.def("GetAIVCoreNum", []() -> size_t { return Platform::Instance().GetSoc().GetAIVCoreNum(); }); |
| 35 | 47 | ||
| 36 | - m.def("GetMemoryLimitForArch", [](const std::string& arch, const std::string& space) -> size_t { | 48 | + m.def("GetMemoryLimitForArch", |
| 37 | - return GetMemoryLimitForArch(arch, space); | 49 | + [](NPUArch arch, const std::string& space) -> size_t { return GetMemoryLimitForArch(arch, space); }); |
| 38 | - }); | ||
| 39 | } | 50 | } |
| 40 | } // namespace pypto | 51 | } // namespace pypto |
| @@ -63,7 +63,7 @@ void BindCodegen(py::module_& m) | |||
| 63 | "Create a CCE code generator for one fixed Cube or Vector target") | 63 | "Create a CCE code generator for one fixed Cube or Vector target") |
| 64 | .def( | 64 | .def( |
| 65 | "generate_single", | 65 | "generate_single", |
| 66 | - [](CCECodegen& self, const ProgramPtr& program, const std::string& arch) { | 66 | + [](CCECodegen& self, const ProgramPtr& program, npu::tile_fwk::NPUArch arch) { |
| 67 | return self.GenerateSingle(program, arch); | 67 | return self.GenerateSingle(program, arch); |
| 68 | }, | 68 | }, |
| 69 | py::arg("program"), py::arg("arch"), | 69 | py::arg("program"), py::arg("arch"), |
| @@ -133,7 +133,7 @@ def b_use_hi(k, sh, leftg): | |||
| 133 | pl.move(left, shared) | 133 | pl.move(left, shared) |
| 134 | 134 | ||
| 135 | 135 | ||
| 136 | -@pl.jit(arch="a5", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=[1, 2])) | 136 | +@pl.jit(arch="3510", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=[1, 2])) |
| 137 | def four_stage_kernel( | 137 | def four_stage_kernel( |
| 138 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], | 138 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], |
| 139 | out: pl.Tensor[[FULL_M, TN], pl.DT_FP16], | 139 | out: pl.Tensor[[FULL_M, TN], pl.DT_FP16], |
| @@ -200,7 +200,7 @@ def four_stage_kernel( | |||
| 200 | b_use_hi(j, b_hi, b_left) | 200 | b_use_hi(j, b_hi, b_left) |
| 201 | 201 | ||
| 202 | 202 | ||
| 203 | -@pl.jit(arch="a5", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=[0, 2])) | 203 | +@pl.jit(arch="3510", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=[0, 2])) |
| 204 | def mixed_preload_kernel( | 204 | def mixed_preload_kernel( |
| 205 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], | 205 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], |
| 206 | out: pl.Tensor[[FULL_M, TN], pl.DT_FP16], | 206 | out: pl.Tensor[[FULL_M, TN], pl.DT_FP16], |
| @@ -121,7 +121,7 @@ def hand_back_slot(g): | |||
| 121 | # --------------------------------------------------------------------------- | 121 | # --------------------------------------------------------------------------- |
| 122 | 122 | ||
| 123 | 123 | ||
| 124 | -@pl.jit(arch="a5", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) | 124 | +@pl.jit(arch="3510", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) |
| 125 | def loop_body_shapes( | 125 | def loop_body_shapes( |
| 126 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] | 126 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] |
| 127 | ): | 127 | ): |
| @@ -202,7 +202,7 @@ def test_allowed_shapes_are_placed_correctly(): | |||
| 202 | assert at("consume(") < at("tick = tick + 1") | 202 | assert at("consume(") < at("tick = tick + 1") |
| 203 | 203 | ||
| 204 | 204 | ||
| 205 | -@pl.jit(arch="a5", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) | 205 | +@pl.jit(arch="3510", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) |
| 206 | def struct_filled_in_by_helper( | 206 | def struct_filled_in_by_helper( |
| 207 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] | 207 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] |
| 208 | ): | 208 | ): |
| @@ -242,7 +242,7 @@ def test_zone1_call_runs_before_the_snapshot(): | |||
| 242 | # --------------------------------------------------------------------------- | 242 | # --------------------------------------------------------------------------- |
| 243 | 243 | ||
| 244 | 244 | ||
| 245 | -@pl.jit(arch="a5", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) | 245 | +@pl.jit(arch="3510", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) |
| 246 | def stmt_between_stages( | 246 | def stmt_between_stages( |
| 247 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] | 247 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] |
| 248 | ): | 248 | ): |
| @@ -266,7 +266,7 @@ def stmt_between_stages( | |||
| 266 | consume(ki, sh, leftg) | 266 | consume(ki, sh, leftg) |
| 267 | 267 | ||
| 268 | 268 | ||
| 269 | -@pl.jit(arch="a5", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) | 269 | +@pl.jit(arch="3510", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) |
| 270 | def section_without_stage_between_stages( | 270 | def section_without_stage_between_stages( |
| 271 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] | 271 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] |
| 272 | ): | 272 | ): |
| @@ -294,7 +294,7 @@ def section_without_stage_between_stages( | |||
| 294 | consume(ki, sh, leftg) | 294 | consume(ki, sh, leftg) |
| 295 | 295 | ||
| 296 | 296 | ||
| 297 | -@pl.jit(arch="a5", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) | 297 | +@pl.jit(arch="3510", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) |
| 298 | def stmt_beside_stage_in_section( | 298 | def stmt_beside_stage_in_section( |
| 299 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] | 299 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] |
| 300 | ): | 300 | ): |
| @@ -317,7 +317,7 @@ def stmt_beside_stage_in_section( | |||
| 317 | consume(ki, sh, leftg) | 317 | consume(ki, sh, leftg) |
| 318 | 318 | ||
| 319 | 319 | ||
| 320 | -@pl.jit(arch="a5", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) | 320 | +@pl.jit(arch="3510", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) |
| 321 | def slot_taken_in_loop_body( | 321 | def slot_taken_in_loop_body( |
| 322 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] | 322 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] |
| 323 | ): | 323 | ): |
| @@ -340,7 +340,7 @@ def slot_taken_in_loop_body( | |||
| 340 | consume(ki, sh, leftg) | 340 | consume(ki, sh, leftg) |
| 341 | 341 | ||
| 342 | 342 | ||
| 343 | -@pl.jit(arch="a5", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) | 343 | +@pl.jit(arch="3510", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) |
| 344 | def slot_taken_inside_a_helper( | 344 | def slot_taken_inside_a_helper( |
| 345 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] | 345 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] |
| 346 | ): | 346 | ): |
| @@ -364,7 +364,7 @@ def slot_taken_inside_a_helper( | |||
| 364 | consume(ki, sh, leftg) | 364 | consume(ki, sh, leftg) |
| 365 | 365 | ||
| 366 | 366 | ||
| 367 | -@pl.jit(arch="a5", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) | 367 | +@pl.jit(arch="3510", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) |
| 368 | def cross_core_touched_outside_stage( | 368 | def cross_core_touched_outside_stage( |
| 369 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] | 369 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] |
| 370 | ): | 370 | ): |
| @@ -397,7 +397,7 @@ def take_slot(k, sh, leftg): | |||
| 397 | pl.move(left, shared) | 397 | pl.move(left, shared) |
| 398 | 398 | ||
| 399 | 399 | ||
| 400 | -@pl.jit(arch="a5", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) | 400 | +@pl.jit(arch="3510", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) |
| 401 | def helper_returns_a_slot( | 401 | def helper_returns_a_slot( |
| 402 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] | 402 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] |
| 403 | ): | 403 | ): |
| @@ -419,7 +419,7 @@ def helper_returns_a_slot( | |||
| 419 | take_slot(ki, sh, leftg) | 419 | take_slot(ki, sh, leftg) |
| 420 | 420 | ||
| 421 | 421 | ||
| 422 | -@pl.jit(arch="a5", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) | 422 | +@pl.jit(arch="3510", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) |
| 423 | def stage_call_without_a_section( | 423 | def stage_call_without_a_section( |
| 424 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] | 424 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] |
| 425 | ): | 425 | ): |
| @@ -441,7 +441,7 @@ def stage_call_without_a_section( | |||
| 441 | consume(ki, sh, leftg) | 441 | consume(ki, sh, leftg) |
| 442 | 442 | ||
| 443 | 443 | ||
| 444 | -@pl.jit(arch="a5", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) | 444 | +@pl.jit(arch="3510", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) |
| 445 | def one_stage_called_twice( | 445 | def one_stage_called_twice( |
| 446 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] | 446 | src: pl.Tensor[[FULL_M, TN], pl.DT_FP16], out: pl.Tensor[[FULL_M, TN], pl.DT_FP16] |
| 447 | ): | 447 | ): |
| @@ -43,7 +43,7 @@ def _require_a5(device): | |||
| 43 | pytest.skip(f"Current device is {name}, not A5 (Ascend950). Skip.") | 43 | pytest.skip(f"Current device is {name}, not A5 (Ascend950). Skip.") |
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | -@pl.jit(arch="a5", auto_mutex=True) | 46 | +@pl.jit(arch="3510", auto_mutex=True) |
| 47 | def getval_setval_am_kernel(a: pl.Tensor[[64, 128], pl.DT_FP16]): | 47 | def getval_setval_am_kernel(a: pl.Tensor[[64, 128], pl.DT_FP16]): |
| 48 | tt = pl.TileType(shape=[64, 128], dtype=pl.DT_FP16, target_memory=pl.MemorySpace.Vec) | 48 | tt = pl.TileType(shape=[64, 128], dtype=pl.DT_FP16, target_memory=pl.MemorySpace.Vec) |
| 49 | a_db = pl.make_tile_group(type=tt, addrs=[0x00000], mutex_ids=[20]) | 49 | a_db = pl.make_tile_group(type=tt, addrs=[0x00000], mutex_ids=[20]) |
| @@ -58,7 +58,7 @@ def getval_setval_am_kernel(a: pl.Tensor[[64, 128], pl.DT_FP16]): | |||
| 58 | pl.store(a, t, [0, 0]) # MTE3 consumer | 58 | pl.store(a, t, [0, 0]) # MTE3 consumer |
| 59 | 59 | ||
| 60 | 60 | ||
| 61 | -@pl.jit(arch="a5", auto_mutex=True) | 61 | +@pl.jit(arch="3510", auto_mutex=True) |
| 62 | def getval_while_condition_am_kernel( | 62 | def getval_while_condition_am_kernel( |
| 63 | a: pl.Tensor[[64, 128], pl.DT_FP16], | 63 | a: pl.Tensor[[64, 128], pl.DT_FP16], |
| 64 | out: pl.Tensor[[1], pl.DT_INT64], | 64 | out: pl.Tensor[[1], pl.DT_INT64], |
| @@ -75,7 +75,7 @@ def _make_fp16_pattern(shape, modulus, device=ST_DEVICE): | |||
| 75 | # ============================================================================= | 75 | # ============================================================================= |
| 76 | # Pure Cube: move(tile, tile_group) | 76 | # Pure Cube: move(tile, tile_group) |
| 77 | # ============================================================================= | 77 | # ============================================================================= |
| 78 | -@pl.jit(arch="a5", auto_mutex=True) | 78 | +@pl.jit(arch="3510", auto_mutex=True) |
| 79 | def cube_move_tile_group_to_tile_kernel( | 79 | def cube_move_tile_group_to_tile_kernel( |
| 80 | a: pl.Tensor[[CUBE_M, CUBE_K], pl.DT_FP16], | 80 | a: pl.Tensor[[CUBE_M, CUBE_K], pl.DT_FP16], |
| 81 | b: pl.Tensor[[CUBE_K, CUBE_N], pl.DT_FP16], | 81 | b: pl.Tensor[[CUBE_K, CUBE_N], pl.DT_FP16], |
| @@ -137,7 +137,7 @@ def cube_move_tile_group_to_tile_kernel( | |||
| 137 | # ============================================================================= | 137 | # ============================================================================= |
| 138 | # Pure Cube: move(tile_group, tile) | 138 | # Pure Cube: move(tile_group, tile) |
| 139 | # ============================================================================= | 139 | # ============================================================================= |
| 140 | -@pl.jit(arch="a5", auto_mutex=True) | 140 | +@pl.jit(arch="3510", auto_mutex=True) |
| 141 | def cube_move_tile_to_tile_group_kernel( | 141 | def cube_move_tile_to_tile_group_kernel( |
| 142 | a: pl.Tensor[[CUBE_M, CUBE_K], pl.DT_FP16], | 142 | a: pl.Tensor[[CUBE_M, CUBE_K], pl.DT_FP16], |
| 143 | b: pl.Tensor[[CUBE_K, CUBE_N], pl.DT_FP16], | 143 | b: pl.Tensor[[CUBE_K, CUBE_N], pl.DT_FP16], |
| @@ -200,7 +200,7 @@ def cube_move_tile_to_tile_group_kernel( | |||
| 200 | # ============================================================================= | 200 | # ============================================================================= |
| 201 | # Pure Vector: group -> tile -> group | 201 | # Pure Vector: group -> tile -> group |
| 202 | # ============================================================================= | 202 | # ============================================================================= |
| 203 | -@pl.jit(arch="a5", auto_mutex=True) | 203 | +@pl.jit(arch="3510", auto_mutex=True) |
| 204 | def vector_mixed_move_both_directions_kernel( | 204 | def vector_mixed_move_both_directions_kernel( |
| 205 | source: pl.Tensor[[VEC_M, VEC_TILE_N], pl.DT_FP16], | 205 | source: pl.Tensor[[VEC_M, VEC_TILE_N], pl.DT_FP16], |
| 206 | middle_out: pl.Tensor[[VEC_M, VEC_TILE_N], pl.DT_FP16], | 206 | middle_out: pl.Tensor[[VEC_M, VEC_TILE_N], pl.DT_FP16], |
| @@ -238,7 +238,7 @@ def vector_mixed_move_both_directions_kernel( | |||
| 238 | # ============================================================================= | 238 | # ============================================================================= |
| 239 | # Cube/Vector: move(Vec tile, Acc tile_group) | 239 | # Cube/Vector: move(Vec tile, Acc tile_group) |
| 240 | # ============================================================================= | 240 | # ============================================================================= |
| 241 | -@pl.jit(arch="a5", auto_mutex=True) | 241 | +@pl.jit(arch="3510", auto_mutex=True) |
| 242 | def cv_move_acc_group_to_vec_tile_kernel( | 242 | def cv_move_acc_group_to_vec_tile_kernel( |
| 243 | a: pl.Tensor[[CV_M, CV_TILE_K], pl.DT_FP16], | 243 | a: pl.Tensor[[CV_M, CV_TILE_K], pl.DT_FP16], |
| 244 | b: pl.Tensor[[CV_TILE_K, CV_TILE_N], pl.DT_FP16], | 244 | b: pl.Tensor[[CV_TILE_K, CV_TILE_N], pl.DT_FP16], |
| @@ -67,7 +67,7 @@ def _select_tile_with_if_else(true_tile, false_tile, choose_true): | |||
| 67 | return selected_tile | 67 | return selected_tile |
| 68 | 68 | ||
| 69 | 69 | ||
| 70 | -@pl.jit(arch="a5", auto_mutex=True) | 70 | +@pl.jit(arch="3510", auto_mutex=True) |
| 71 | def mixed_width_groups_kernel( | 71 | def mixed_width_groups_kernel( |
| 72 | source: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16], | 72 | source: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16], |
| 73 | output: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16], | 73 | output: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16], |
| @@ -144,7 +144,7 @@ L0B_K_WIDE = 256 | |||
| 144 | L0B_N = 128 | 144 | L0B_N = 128 |
| 145 | 145 | ||
| 146 | 146 | ||
| 147 | -@pl.jit(arch="a5", auto_mutex=True) | 147 | +@pl.jit(arch="3510", auto_mutex=True) |
| 148 | def cube_vector_multi_id_kernel( | 148 | def cube_vector_multi_id_kernel( |
| 149 | a: pl.Tensor[[CUBE_M, CUBE_N], pl.DT_FP32], | 149 | a: pl.Tensor[[CUBE_M, CUBE_N], pl.DT_FP32], |
| 150 | b: pl.Tensor[[CUBE_M, CUBE_K], pl.DT_FP16], | 150 | b: pl.Tensor[[CUBE_M, CUBE_K], pl.DT_FP16], |
| @@ -202,7 +202,7 @@ def cube_vector_multi_id_kernel( | |||
| 202 | pl.store(out, vec_group[3], [row_offset, 0]) | 202 | pl.store(out, vec_group[3], [row_offset, 0]) |
| 203 | 203 | ||
| 204 | 204 | ||
| 205 | -@pl.jit(arch="a5", auto_mutex=True) | 205 | +@pl.jit(arch="3510", auto_mutex=True) |
| 206 | def overlap_groups_add_kernel( | 206 | def overlap_groups_add_kernel( |
| 207 | a: pl.Tensor[[DYN_FULL_ROWS, TILE_COLS], pl.DT_FP16], | 207 | a: pl.Tensor[[DYN_FULL_ROWS, TILE_COLS], pl.DT_FP16], |
| 208 | b: pl.Tensor[[DYN_FULL_ROWS, TILE_COLS], pl.DT_FP16], | 208 | b: pl.Tensor[[DYN_FULL_ROWS, TILE_COLS], pl.DT_FP16], |
| @@ -223,7 +223,7 @@ def overlap_groups_add_kernel( | |||
| 223 | pl.store(out, tile_a, [row, 0]) | 223 | pl.store(out, tile_a, [row, 0]) |
| 224 | 224 | ||
| 225 | 225 | ||
| 226 | -@pl.jit(arch="a5", auto_mutex=True) | 226 | +@pl.jit(arch="3510", auto_mutex=True) |
| 227 | def dynamic_offset_subscript_kernel( | 227 | def dynamic_offset_subscript_kernel( |
| 228 | a: pl.Tensor[[DYN_FULL_ROWS, TILE_COLS], pl.DT_FP16], | 228 | a: pl.Tensor[[DYN_FULL_ROWS, TILE_COLS], pl.DT_FP16], |
| 229 | b: pl.Tensor[[DYN_FULL_ROWS, TILE_COLS], pl.DT_FP16], | 229 | b: pl.Tensor[[DYN_FULL_ROWS, TILE_COLS], pl.DT_FP16], |
| @@ -244,7 +244,7 @@ def dynamic_offset_subscript_kernel( | |||
| 244 | pl.store(out, tile_a, [row, 0]) | 244 | pl.store(out, tile_a, [row, 0]) |
| 245 | 245 | ||
| 246 | 246 | ||
| 247 | -@pl.jit(arch="a5", auto_mutex=True) | 247 | +@pl.jit(arch="3510", auto_mutex=True) |
| 248 | def pure_iterative_subscript_kernel( | 248 | def pure_iterative_subscript_kernel( |
| 249 | a: pl.Tensor[[PURE_FULL_ROWS, TILE_COLS], pl.DT_FP16], | 249 | a: pl.Tensor[[PURE_FULL_ROWS, TILE_COLS], pl.DT_FP16], |
| 250 | out: pl.Tensor[[PURE_FULL_ROWS, TILE_COLS], pl.DT_FP16], | 250 | out: pl.Tensor[[PURE_FULL_ROWS, TILE_COLS], pl.DT_FP16], |
| @@ -261,7 +261,7 @@ def pure_iterative_subscript_kernel( | |||
| 261 | pl.store(out, tile, [row, 0]) | 261 | pl.store(out, tile, [row, 0]) |
| 262 | 262 | ||
| 263 | 263 | ||
| 264 | -@pl.jit(arch="a5", auto_mutex=True) | 264 | +@pl.jit(arch="3510", auto_mutex=True) |
| 265 | def pure_constant_subscript_kernel( | 265 | def pure_constant_subscript_kernel( |
| 266 | a: pl.Tensor[[TILE_ROWS, TILE_COLS], pl.DT_FP16], | 266 | a: pl.Tensor[[TILE_ROWS, TILE_COLS], pl.DT_FP16], |
| 267 | b: pl.Tensor[[TILE_ROWS, TILE_COLS], pl.DT_FP16], | 267 | b: pl.Tensor[[TILE_ROWS, TILE_COLS], pl.DT_FP16], |
| @@ -279,7 +279,7 @@ def pure_constant_subscript_kernel( | |||
| 279 | pl.store(out, tile_a, [0, 0]) | 279 | pl.store(out, tile_a, [0, 0]) |
| 280 | 280 | ||
| 281 | 281 | ||
| 282 | -@pl.jit(arch="a5", auto_mutex=True) | 282 | +@pl.jit(arch="3510", auto_mutex=True) |
| 283 | def same_group_overlapping_slots_kernel( | 283 | def same_group_overlapping_slots_kernel( |
| 284 | a: pl.Tensor[[TILE_ROWS, TILE_COLS], pl.DT_FP16], | 284 | a: pl.Tensor[[TILE_ROWS, TILE_COLS], pl.DT_FP16], |
| 285 | b: pl.Tensor[[TILE_ROWS, TILE_COLS], pl.DT_FP16], | 285 | b: pl.Tensor[[TILE_ROWS, TILE_COLS], pl.DT_FP16], |
| @@ -297,7 +297,7 @@ def same_group_overlapping_slots_kernel( | |||
| 297 | pl.store(out, tile_a, [0, 0]) | 297 | pl.store(out, tile_a, [0, 0]) |
| 298 | 298 | ||
| 299 | 299 | ||
| 300 | -@pl.jit(arch="a5", auto_mutex=True) | 300 | +@pl.jit(arch="3510", auto_mutex=True) |
| 301 | def control_flow_multi_id_groups_kernel( | 301 | def control_flow_multi_id_groups_kernel( |
| 302 | a: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16], | 302 | a: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16], |
| 303 | out: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16], | 303 | out: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16], |
| @@ -318,7 +318,7 @@ def control_flow_multi_id_groups_kernel( | |||
| 318 | pl.store(out, tile, [row, 0]) | 318 | pl.store(out, tile, [row, 0]) |
| 319 | 319 | ||
| 320 | 320 | ||
| 321 | -@pl.jit(arch="a5", auto_mutex=True) | 321 | +@pl.jit(arch="3510", auto_mutex=True) |
| 322 | def subfunction_tile_if_else_kernel( | 322 | def subfunction_tile_if_else_kernel( |
| 323 | true_source: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16], | 323 | true_source: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16], |
| 324 | false_source: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16], | 324 | false_source: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16], |
| @@ -343,7 +343,7 @@ def subfunction_tile_if_else_kernel( | |||
| 343 | pl.store(out, output_tile, [row, 0]) | 343 | pl.store(out, output_tile, [row, 0]) |
| 344 | 344 | ||
| 345 | 345 | ||
| 346 | -@pl.jit(arch="a5", auto_mutex=True) | 346 | +@pl.jit(arch="3510", auto_mutex=True) |
| 347 | def tuple_mutex_ids_kernel( | 347 | def tuple_mutex_ids_kernel( |
| 348 | a: pl.Tensor[[TILE_ROWS, TILE_COLS], pl.DT_FP16], | 348 | a: pl.Tensor[[TILE_ROWS, TILE_COLS], pl.DT_FP16], |
| 349 | b: pl.Tensor[[TILE_ROWS, TILE_COLS], pl.DT_FP16], | 349 | b: pl.Tensor[[TILE_ROWS, TILE_COLS], pl.DT_FP16], |
| @@ -361,7 +361,7 @@ def tuple_mutex_ids_kernel( | |||
| 361 | pl.store(out, tile_a, [0, 0]) | 361 | pl.store(out, tile_a, [0, 0]) |
| 362 | 362 | ||
| 363 | 363 | ||
| 364 | -@pl.jit(arch="a5", auto_mutex=True) | 364 | +@pl.jit(arch="3510", auto_mutex=True) |
| 365 | def explicit_depth_discrete_addrs_kernel( | 365 | def explicit_depth_discrete_addrs_kernel( |
| 366 | a: pl.Tensor[[EXPLICIT_FULL_ROWS, TILE_COLS], pl.DT_FP16], | 366 | a: pl.Tensor[[EXPLICIT_FULL_ROWS, TILE_COLS], pl.DT_FP16], |
| 367 | out: pl.Tensor[[EXPLICIT_FULL_ROWS, TILE_COLS], pl.DT_FP16], | 367 | out: pl.Tensor[[EXPLICIT_FULL_ROWS, TILE_COLS], pl.DT_FP16], |
| @@ -383,7 +383,7 @@ def explicit_depth_discrete_addrs_kernel( | |||
| 383 | pl.store(out, tile, [row, 0]) | 383 | pl.store(out, tile, [row, 0]) |
| 384 | 384 | ||
| 385 | 385 | ||
| 386 | -@pl.jit(arch="a5", auto_mutex=True) | 386 | +@pl.jit(arch="3510", auto_mutex=True) |
| 387 | def next_and_subscript_mixed_kernel( | 387 | def next_and_subscript_mixed_kernel( |
| 388 | a: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16], | 388 | a: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16], |
| 389 | out: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16], | 389 | out: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16], |
| @@ -550,7 +550,7 @@ def test_next_and_subscript_mixed(): | |||
| 550 | torch.testing.assert_close(out.cpu().float(), golden, rtol=3e-3, atol=3e-3) | 550 | torch.testing.assert_close(out.cpu().float(), golden, rtol=3e-3, atol=3e-3) |
| 551 | 551 | ||
| 552 | 552 | ||
| 553 | -@pl.jit(arch="a5", auto_mutex=True) | 553 | +@pl.jit(arch="3510", auto_mutex=True) |
| 554 | def l0a_l0b_overlap_multi_id_kernel( | 554 | def l0a_l0b_overlap_multi_id_kernel( |
| 555 | a: pl.Tensor[[L0A_M, L0A_K_WIDE], pl.DT_FP16], | 555 | a: pl.Tensor[[L0A_M, L0A_K_WIDE], pl.DT_FP16], |
| 556 | b: pl.Tensor[[L0B_K_WIDE, L0B_N], pl.DT_FP16], | 556 | b: pl.Tensor[[L0B_K_WIDE, L0B_N], pl.DT_FP16], |
| @@ -91,7 +91,7 @@ def const_index_kernel( | |||
| 91 | # Test 2: TileGroup 动态下标访问 | 91 | # Test 2: TileGroup 动态下标访问 |
| 92 | # TileGroup dynamic subscript | 92 | # TileGroup dynamic subscript |
| 93 | # ============================================================================= | 93 | # ============================================================================= |
| 94 | -@pl.jit(arch="a5", auto_mutex=True) | 94 | +@pl.jit(arch="3510", auto_mutex=True) |
| 95 | def dynamic_index_kernel( | 95 | def dynamic_index_kernel( |
| 96 | a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], | 96 | a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], |
| 97 | out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], | 97 | out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], |
| @@ -113,7 +113,7 @@ def dynamic_index_kernel( | |||
| 113 | # Test 3: mutex_ids=None 时通过 depth 创建 TileGroup | 113 | # Test 3: mutex_ids=None 时通过 depth 创建 TileGroup |
| 114 | # TileGroup depth with mutex_ids=None | 114 | # TileGroup depth with mutex_ids=None |
| 115 | # ============================================================================= | 115 | # ============================================================================= |
| 116 | -@pl.jit(arch="a5", auto_mutex=True) | 116 | +@pl.jit(arch="3510", auto_mutex=True) |
| 117 | def no_mutex_none_kernel( | 117 | def no_mutex_none_kernel( |
| 118 | a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], | 118 | a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], |
| 119 | out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], | 119 | out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], |
| @@ -174,7 +174,7 @@ def pipeline_mixed_subscript_stage(k, a, out, g): | |||
| 174 | pl.store(out, tile, [k * TILE_M, 0]) | 174 | pl.store(out, tile, [k * TILE_M, 0]) |
| 175 | 175 | ||
| 176 | 176 | ||
| 177 | -@pl.jit(arch="a5", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) | 177 | +@pl.jit(arch="3510", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1)) |
| 178 | def pipeline_stage_subscript_kernel( | 178 | def pipeline_stage_subscript_kernel( |
| 179 | a: pl.Tensor[[PIPELINE_FULL_M, TILE_N], pl.DT_FP16], | 179 | a: pl.Tensor[[PIPELINE_FULL_M, TILE_N], pl.DT_FP16], |
| 180 | out: pl.Tensor[[PIPELINE_FULL_M, TILE_N], pl.DT_FP16], | 180 | out: pl.Tensor[[PIPELINE_FULL_M, TILE_N], pl.DT_FP16], |
| @@ -189,7 +189,7 @@ def pipeline_stage_subscript_kernel( | |||
| 189 | # Test 6: 重复 mutex ID 的 16 槽轮转访问 | 189 | # Test 6: 重复 mutex ID 的 16 槽轮转访问 |
| 190 | # Round-robin access with repeated mutex IDs | 190 | # Round-robin access with repeated mutex IDs |
| 191 | # ============================================================================= | 191 | # ============================================================================= |
| 192 | -@pl.jit(arch="a5", auto_mutex=True) | 192 | +@pl.jit(arch="3510", auto_mutex=True) |
| 193 | def repeated_mutex_ids_kernel( | 193 | def repeated_mutex_ids_kernel( |
| 194 | a: pl.Tensor[[REPEATED_FULL_M, TILE_N], pl.DT_FP16], | 194 | a: pl.Tensor[[REPEATED_FULL_M, TILE_N], pl.DT_FP16], |
| 195 | out: pl.Tensor[[REPEATED_FULL_M, TILE_N], pl.DT_FP16], | 195 | out: pl.Tensor[[REPEATED_FULL_M, TILE_N], pl.DT_FP16], |
| @@ -241,7 +241,7 @@ def next_reference_kernel( | |||
| 241 | # Test 8: 两个 Tile 槽并行存活的预取场景 | 241 | # Test 8: 两个 Tile 槽并行存活的预取场景 |
| 242 | # Prefetch with two live Tile slots | 242 | # Prefetch with two live Tile slots |
| 243 | # ============================================================================= | 243 | # ============================================================================= |
| 244 | -@pl.jit(arch="a5", auto_mutex=True) | 244 | +@pl.jit(arch="3510", auto_mutex=True) |
| 245 | def prefetch_kernel( | 245 | def prefetch_kernel( |
| 246 | a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], | 246 | a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], |
| 247 | out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], | 247 | out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], |
| @@ -271,7 +271,7 @@ def prefetch_kernel( | |||
| 271 | # Test 9: 同一算子访问两个 Tile 槽 | 271 | # Test 9: 同一算子访问两个 Tile 槽 |
| 272 | # Two Tile slots used by one operation | 272 | # Two Tile slots used by one operation |
| 273 | # ============================================================================= | 273 | # ============================================================================= |
| 274 | -@pl.jit(arch="a5", auto_mutex=True) | 274 | +@pl.jit(arch="3510", auto_mutex=True) |
| 275 | def two_slots_one_op_kernel( | 275 | def two_slots_one_op_kernel( |
| 276 | a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], | 276 | a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], |
| 277 | out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], | 277 | out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], |
| @@ -298,7 +298,7 @@ def two_slots_one_op_kernel( | |||
| 298 | # Test 10: 循环携带 g[0] 和 g[3] 后执行 add | 298 | # Test 10: 循环携带 g[0] 和 g[3] 后执行 add |
| 299 | # Loop-carried g[0] and g[3] add | 299 | # Loop-carried g[0] and g[3] add |
| 300 | # ============================================================================= | 300 | # ============================================================================= |
| 301 | -@pl.jit(arch="a5", auto_mutex=True) | 301 | +@pl.jit(arch="3510", auto_mutex=True) |
| 302 | def four_slots_loop_carried_add_kernel( | 302 | def four_slots_loop_carried_add_kernel( |
| 303 | a: pl.Tensor[[TILE_M, TILE_N], pl.DT_FP16], | 303 | a: pl.Tensor[[TILE_M, TILE_N], pl.DT_FP16], |
| 304 | b: pl.Tensor[[TILE_M, TILE_N], pl.DT_FP16], | 304 | b: pl.Tensor[[TILE_M, TILE_N], pl.DT_FP16], |
| @@ -327,7 +327,7 @@ def four_slots_loop_carried_add_kernel( | |||
| 327 | # Test 11: if/else 合并重叠 mutex 候选 ID | 327 | # Test 11: if/else 合并重叠 mutex 候选 ID |
| 328 | # Merge overlapping mutex candidates across if/else | 328 | # Merge overlapping mutex candidates across if/else |
| 329 | # ============================================================================= | 329 | # ============================================================================= |
| 330 | -@pl.jit(arch="a5", auto_mutex=True) | 330 | +@pl.jit(arch="3510", auto_mutex=True) |
| 331 | def ifelse_overlapping_mutex_ids_kernel( | 331 | def ifelse_overlapping_mutex_ids_kernel( |
| 332 | a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], | 332 | a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], |
| 333 | out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], | 333 | out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], |
| @@ -381,7 +381,7 @@ def single_slot_kernel( | |||
| 381 | # Test 13: TileGroup 边界内常量下标访问 | 381 | # Test 13: TileGroup 边界内常量下标访问 |
| 382 | # TileGroup bounded constant subscripts | 382 | # TileGroup bounded constant subscripts |
| 383 | # ============================================================================= | 383 | # ============================================================================= |
| 384 | -@pl.jit(arch="a5", auto_mutex=True) | 384 | +@pl.jit(arch="3510", auto_mutex=True) |
| 385 | def bounded_constant_index_kernel( | 385 | def bounded_constant_index_kernel( |
| 386 | a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], | 386 | a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], |
| 387 | out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], | 387 | out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], |
| @@ -407,7 +407,7 @@ def bounded_constant_index_kernel( | |||
| 407 | # Test 14: 下标 Tile 的 getval/setval 标量访问 | 407 | # Test 14: 下标 Tile 的 getval/setval 标量访问 |
| 408 | # Scalar getval/setval on a subscript-selected Tile | 408 | # Scalar getval/setval on a subscript-selected Tile |
| 409 | # ============================================================================= | 409 | # ============================================================================= |
| 410 | -@pl.jit(arch="a5", auto_mutex=True) | 410 | +@pl.jit(arch="3510", auto_mutex=True) |
| 411 | def getval_setval_kernel( | 411 | def getval_setval_kernel( |
| 412 | a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], | 412 | a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], |
| 413 | out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], | 413 | out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16], |
| @@ -461,7 +461,7 @@ def mixed_cursor_and_subscript_kernel( | |||
| 461 | # Test 16: Cube 双缓冲矩阵乘 | 461 | # Test 16: Cube 双缓冲矩阵乘 |
| 462 | # Cube double-buffered matmul | 462 | # Cube double-buffered matmul |
| 463 | # ============================================================================= | 463 | # ============================================================================= |
| 464 | -@pl.jit(arch="a5", auto_mutex=True) | 464 | +@pl.jit(arch="3510", auto_mutex=True) |
| 465 | def matmul_subscript_kernel( | 465 | def matmul_subscript_kernel( |
| 466 | a: pl.Tensor[[MM_M, MM_K], pl.DT_FP16], | 466 | a: pl.Tensor[[MM_M, MM_K], pl.DT_FP16], |
| 467 | b: pl.Tensor[[MM_K, MM_N], pl.DT_FP16], | 467 | b: pl.Tensor[[MM_K, MM_N], pl.DT_FP16], |
| @@ -21,7 +21,7 @@ CV_NUM_TILES = 13 | |||
| 21 | CV_M = CV_TILE_M * CV_NUM_TILES | 21 | CV_M = CV_TILE_M * CV_NUM_TILES |
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | -@pl.jit(arch="a5", auto_mutex=True) | 24 | +@pl.jit(arch="3510", auto_mutex=True) |
| 25 | def limited_matmul( | 25 | def limited_matmul( |
| 26 | a: pl.Tensor[[CV_M, CV_TILE_K], pl.DT_FP16], | 26 | a: pl.Tensor[[CV_M, CV_TILE_K], pl.DT_FP16], |
| 27 | b: pl.Tensor[[CV_TILE_K, CV_TILE_N], pl.DT_FP16], | 27 | b: pl.Tensor[[CV_TILE_K, CV_TILE_N], pl.DT_FP16], |
| @@ -33,6 +33,7 @@ import os | |||
| 33 | 33 | ||
| 34 | from pypto_pro._errors import OutOfRange | 34 | from pypto_pro._errors import OutOfRange |
| 35 | import pypto_pro.language as pl | 35 | import pypto_pro.language as pl |
| 36 | +from pypto_pro.runtime.platform import NpuArch | ||
| 36 | import pytest | 37 | import pytest |
| 37 | import torch | 38 | import torch |
| 38 | import torch_npu # noqa: F401 — registers npu backend | 39 | import torch_npu # noqa: F401 — registers npu backend |
| @@ -297,7 +298,7 @@ def kernel_expands_uint64_boundary( | |||
| 297 | def _compile_to_cce(kernel) -> str: | 298 | def _compile_to_cce(kernel) -> str: |
| 298 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets | 299 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets |
| 299 | 300 | ||
| 300 | - cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "") | 301 | + cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "") |
| 301 | return _assemble_cv_source(cube, vector).content | 302 | return _assemble_cv_source(cube, vector).content |
| 302 | 303 | ||
| 303 | 304 | ||
| @@ -908,7 +908,7 @@ def compute_gu(ctx_gu, pv_vec_db, exp_corr_db, global_sum_buf, running_o, o_f16, | |||
| 908 | # ================================================================ | 908 | # ================================================================ |
| 909 | # Kernel with NBuffer + auto_mutex | 909 | # Kernel with NBuffer + auto_mutex |
| 910 | # ================================================================ | 910 | # ================================================================ |
| 911 | -@pl.jit(arch="a5", auto_mutex=True, compile_timeout=200) | 911 | +@pl.jit(arch="3510", auto_mutex=True, compile_timeout=200) |
| 912 | def fa_tnd_with_mask_kernel( | 912 | def fa_tnd_with_mask_kernel( |
| 913 | q: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16], | 913 | q: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16], |
| 914 | k: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16], | 914 | k: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16], |
| @@ -781,7 +781,7 @@ def compute_gu(ctx_gu, pv_vec_db, exp_corr_db, global_sum_buf, running_o, o_f16, | |||
| 781 | # ================================================================ | 781 | # ================================================================ |
| 782 | # Kernel with NBuffer + auto_mutex | 782 | # Kernel with NBuffer + auto_mutex |
| 783 | # ================================================================ | 783 | # ================================================================ |
| 784 | -@pl.jit(arch="a5", auto_mutex=True, compile_timeout=200) | 784 | +@pl.jit(arch="3510", auto_mutex=True, compile_timeout=200) |
| 785 | def flex_attention( | 785 | def flex_attention( |
| 786 | q: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16], | 786 | q: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16], |
| 787 | k: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16], | 787 | k: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16], |
| @@ -836,7 +836,7 @@ def scalar_bound(spans_gm, b_idx, span_num, q_abs): | |||
| 836 | # ================================================================ | 836 | # ================================================================ |
| 837 | # Kernel with NBuffer + auto_mutex | 837 | # Kernel with NBuffer + auto_mutex |
| 838 | # ================================================================ | 838 | # ================================================================ |
| 839 | -@pl.jit(arch="a5", auto_mutex=True, compile_timeout=200) | 839 | +@pl.jit(arch="3510", auto_mutex=True, compile_timeout=200) |
| 840 | def flex_attention_bf16( | 840 | def flex_attention_bf16( |
| 841 | q: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC, pl.DYNAMIC], pl.DT_BF16], | 841 | q: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC, pl.DYNAMIC], pl.DT_BF16], |
| 842 | # PagedAttention NHD, exactly as the operator declares them: | 842 | # PagedAttention NHD, exactly as the operator declares them: |
| @@ -56,7 +56,7 @@ def atomic_add_loaded_gm_value( | |||
| 56 | pl.simt.atomic_add(target[0, 0], value_tensor[0, 0]) | 56 | pl.simt.atomic_add(target[0, 0], value_tensor[0, 0]) |
| 57 | 57 | ||
| 58 | 58 | ||
| 59 | -@pl.jit(auto_mutex=True, arch="a5") | 59 | +@pl.jit(auto_mutex=True, arch="3510") |
| 60 | def simt_atomic_add_loaded_gm_value( | 60 | def simt_atomic_add_loaded_gm_value( |
| 61 | target: pl.Tensor[[1, THREADS], pl.DT_INT32], | 61 | target: pl.Tensor[[1, THREADS], pl.DT_INT32], |
| 62 | value_tensor: pl.Tensor[[1, 1], pl.DT_INT32], | 62 | value_tensor: pl.Tensor[[1, 1], pl.DT_INT32], |
| @@ -23,7 +23,7 @@ def bitcast_loaded_gm_value( | |||
| 23 | dst[0, 0] = pl.simt.bitcast(src[0, 0], pl.DT_FP32) | 23 | dst[0, 0] = pl.simt.bitcast(src[0, 0], pl.DT_FP32) |
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | -@pl.jit(auto_mutex=True, arch="a5") | 26 | +@pl.jit(auto_mutex=True, arch="3510") |
| 27 | def simt_bitcast_loaded_gm_value( | 27 | def simt_bitcast_loaded_gm_value( |
| 28 | src: pl.Tensor[[1, 1], pl.DT_INT32], | 28 | src: pl.Tensor[[1, 1], pl.DT_INT32], |
| 29 | dst: pl.Tensor[[1, 1], pl.DT_FP32], | 29 | dst: pl.Tensor[[1, 1], pl.DT_FP32], |
| @@ -40,7 +40,7 @@ def _require_a5(device): | |||
| 40 | # Chain attribute access: t.a.b (nested make_tuple) | 40 | # Chain attribute access: t.a.b (nested make_tuple) |
| 41 | # ============================================================================= | 41 | # ============================================================================= |
| 42 | 42 | ||
| 43 | -@pl.jit(arch="a5", auto_mutex=True) | 43 | +@pl.jit(arch="3510", auto_mutex=True) |
| 44 | def make_tuple_chain_attr_kernel( | 44 | def make_tuple_chain_attr_kernel( |
| 45 | out: pl.Tensor[[1], pl.DT_INT32], | 45 | out: pl.Tensor[[1], pl.DT_INT32], |
| 46 | ): | 46 | ): |
| @@ -65,7 +65,7 @@ def test_make_tuple_chain_attr(): | |||
| 65 | # Three-level chain: t.a.b.v | 65 | # Three-level chain: t.a.b.v |
| 66 | # ============================================================================= | 66 | # ============================================================================= |
| 67 | 67 | ||
| 68 | -@pl.jit(arch="a5", auto_mutex=True) | 68 | +@pl.jit(arch="3510", auto_mutex=True) |
| 69 | def make_tuple_chain_three_level_kernel( | 69 | def make_tuple_chain_three_level_kernel( |
| 70 | out: pl.Tensor[[1], pl.DT_INT32], | 70 | out: pl.Tensor[[1], pl.DT_INT32], |
| 71 | ): | 71 | ): |
| @@ -90,7 +90,7 @@ def test_make_tuple_chain_three_level(): | |||
| 90 | # make_tuple wrapping tile_group: t.field.next() | 90 | # make_tuple wrapping tile_group: t.field.next() |
| 91 | # ============================================================================= | 91 | # ============================================================================= |
| 92 | 92 | ||
| 93 | -@pl.jit(arch="a5", auto_mutex=True) | 93 | +@pl.jit(arch="3510", auto_mutex=True) |
| 94 | def make_tuple_chain_tile_group_next_kernel( | 94 | def make_tuple_chain_tile_group_next_kernel( |
| 95 | a: pl.Tensor[[64, 128], pl.DT_FP16], | 95 | a: pl.Tensor[[64, 128], pl.DT_FP16], |
| 96 | ): | 96 | ): |
| @@ -118,7 +118,7 @@ def test_make_tuple_chain_tile_group_next(): | |||
| 118 | # make_tuple wrapping tile_group: t.field.current() | 118 | # make_tuple wrapping tile_group: t.field.current() |
| 119 | # ============================================================================= | 119 | # ============================================================================= |
| 120 | 120 | ||
| 121 | -@pl.jit(arch="a5", auto_mutex=True) | 121 | +@pl.jit(arch="3510", auto_mutex=True) |
| 122 | def make_tuple_chain_tile_group_current_kernel( | 122 | def make_tuple_chain_tile_group_current_kernel( |
| 123 | a: pl.Tensor[[64, 128], pl.DT_FP16], | 123 | a: pl.Tensor[[64, 128], pl.DT_FP16], |
| 124 | ): | 124 | ): |
| @@ -147,7 +147,7 @@ def test_make_tuple_chain_tile_group_current(): | |||
| 147 | # Four-level chain: t.a.b.c.d | 147 | # Four-level chain: t.a.b.c.d |
| 148 | # ============================================================================= | 148 | # ============================================================================= |
| 149 | 149 | ||
| 150 | -@pl.jit(arch="a5", auto_mutex=True) | 150 | +@pl.jit(arch="3510", auto_mutex=True) |
| 151 | def make_tuple_chain_four_level_kernel( | 151 | def make_tuple_chain_four_level_kernel( |
| 152 | out: pl.Tensor[[1], pl.DT_INT32], | 152 | out: pl.Tensor[[1], pl.DT_INT32], |
| 153 | ): | 153 | ): |
| @@ -173,7 +173,7 @@ def test_make_tuple_chain_four_level(): | |||
| 173 | # Chain reads in arithmetic: t.a.x * 2 + t.a.y | 173 | # Chain reads in arithmetic: t.a.x * 2 + t.a.y |
| 174 | # ============================================================================= | 174 | # ============================================================================= |
| 175 | 175 | ||
| 176 | -@pl.jit(arch="a5", auto_mutex=True) | 176 | +@pl.jit(arch="3510", auto_mutex=True) |
| 177 | def make_tuple_chain_arithmetic_kernel( | 177 | def make_tuple_chain_arithmetic_kernel( |
| 178 | out: pl.Tensor[[1], pl.DT_INT32], | 178 | out: pl.Tensor[[1], pl.DT_INT32], |
| 179 | ): | 179 | ): |
| @@ -197,7 +197,7 @@ def test_make_tuple_chain_arithmetic(): | |||
| 197 | # make_tuple wrapping a struct_array element: t.s.v | 197 | # make_tuple wrapping a struct_array element: t.s.v |
| 198 | # ============================================================================= | 198 | # ============================================================================= |
| 199 | 199 | ||
| 200 | -@pl.jit(arch="a5", auto_mutex=True) | 200 | +@pl.jit(arch="3510", auto_mutex=True) |
| 201 | def make_tuple_chain_struct_array_elem_kernel( | 201 | def make_tuple_chain_struct_array_elem_kernel( |
| 202 | out: pl.Tensor[[1], pl.DT_INT32], | 202 | out: pl.Tensor[[1], pl.DT_INT32], |
| 203 | ): | 203 | ): |
| @@ -222,7 +222,7 @@ def test_make_tuple_chain_struct_array_elem(): | |||
| 222 | # make_tuple wrapping tile_group: t.field.previous() | 222 | # make_tuple wrapping tile_group: t.field.previous() |
| 223 | # ============================================================================= | 223 | # ============================================================================= |
| 224 | 224 | ||
| 225 | -@pl.jit(arch="a5", auto_mutex=True) | 225 | +@pl.jit(arch="3510", auto_mutex=True) |
| 226 | def make_tuple_chain_tile_group_previous_kernel( | 226 | def make_tuple_chain_tile_group_previous_kernel( |
| 227 | a: pl.Tensor[[64, 128], pl.DT_FP16], | 227 | a: pl.Tensor[[64, 128], pl.DT_FP16], |
| 228 | ): | 228 | ): |
| @@ -250,7 +250,7 @@ def test_make_tuple_chain_tile_group_previous(): | |||
| 250 | # make_tuple wrapping tile_group: double buffer via t.field.next() in a loop | 250 | # make_tuple wrapping tile_group: double buffer via t.field.next() in a loop |
| 251 | # ============================================================================= | 251 | # ============================================================================= |
| 252 | 252 | ||
| 253 | -@pl.jit(arch="a5", auto_mutex=True) | 253 | +@pl.jit(arch="3510", auto_mutex=True) |
| 254 | def make_tuple_chain_double_buffer_loop_kernel( | 254 | def make_tuple_chain_double_buffer_loop_kernel( |
| 255 | a: pl.Tensor[[128, 128], pl.DT_FP16], | 255 | a: pl.Tensor[[128, 128], pl.DT_FP16], |
| 256 | ): | 256 | ): |
| @@ -279,7 +279,7 @@ def test_make_tuple_chain_double_buffer_loop(): | |||
| 279 | # make_tuple wrapping tile_group: ring buffer wraps around 3 slots | 279 | # make_tuple wrapping tile_group: ring buffer wraps around 3 slots |
| 280 | # ============================================================================= | 280 | # ============================================================================= |
| 281 | 281 | ||
| 282 | -@pl.jit(arch="a5", auto_mutex=True) | 282 | +@pl.jit(arch="3510", auto_mutex=True) |
| 283 | def make_tuple_chain_ring_buffer_loop_kernel( | 283 | def make_tuple_chain_ring_buffer_loop_kernel( |
| 284 | a: pl.Tensor[[256, 128], pl.DT_FP16], | 284 | a: pl.Tensor[[256, 128], pl.DT_FP16], |
| 285 | ): | 285 | ): |
| @@ -308,7 +308,7 @@ def test_make_tuple_chain_ring_buffer_loop(): | |||
| 308 | # Chain reads accumulated in a for loop | 308 | # Chain reads accumulated in a for loop |
| 309 | # ============================================================================= | 309 | # ============================================================================= |
| 310 | 310 | ||
| 311 | -@pl.jit(arch="a5", auto_mutex=True) | 311 | +@pl.jit(arch="3510", auto_mutex=True) |
| 312 | def make_tuple_chain_loop_accum_kernel( | 312 | def make_tuple_chain_loop_accum_kernel( |
| 313 | out: pl.Tensor[[1], pl.DT_INT32], | 313 | out: pl.Tensor[[1], pl.DT_INT32], |
| 314 | ): | 314 | ): |
| @@ -335,7 +335,7 @@ def test_make_tuple_chain_loop_accum(): | |||
| 335 | # Chain reads selected by an if/else branch | 335 | # Chain reads selected by an if/else branch |
| 336 | # ============================================================================= | 336 | # ============================================================================= |
| 337 | 337 | ||
| 338 | -@pl.jit(arch="a5", auto_mutex=True) | 338 | +@pl.jit(arch="3510", auto_mutex=True) |
| 339 | def make_tuple_chain_if_branch_kernel( | 339 | def make_tuple_chain_if_branch_kernel( |
| 340 | out: pl.Tensor[[1], pl.DT_INT32], | 340 | out: pl.Tensor[[1], pl.DT_INT32], |
| 341 | ): | 341 | ): |
| @@ -28,6 +28,7 @@ These read the generated C++ directly, so they need no device and no bisheng. | |||
| 28 | import re | 28 | import re |
| 29 | 29 | ||
| 30 | import pypto_pro.language as pl | 30 | import pypto_pro.language as pl |
| 31 | +from pypto_pro.runtime.platform import NpuArch | ||
| 31 | import pytest | 32 | import pytest |
| 32 | 33 | ||
| 33 | ROWS = 64 | 34 | ROWS = 64 |
| @@ -37,7 +38,7 @@ COLS = 64 | |||
| 37 | def _compile_to_cce(kernel) -> str: | 38 | def _compile_to_cce(kernel) -> str: |
| 38 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets | 39 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets |
| 39 | 40 | ||
| 40 | - cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "") | 41 | + cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "") |
| 41 | return _assemble_cv_source(cube, vector).content | 42 | return _assemble_cv_source(cube, vector).content |
| 42 | 43 | ||
| 43 | 44 | ||
| @@ -13,6 +13,7 @@ | |||
| 13 | import subprocess | 13 | import subprocess |
| 14 | 14 | ||
| 15 | import pypto_pro.language as pl | 15 | import pypto_pro.language as pl |
| 16 | +from pypto_pro.runtime.platform import NpuArch | ||
| 16 | import pytest | 17 | import pytest |
| 17 | 18 | ||
| 18 | 19 | ||
| @@ -354,7 +355,7 @@ def control_flow_binary(request, tmp_path_factory): | |||
| 354 | kernel, expected = request.param | 355 | kernel, expected = request.param |
| 355 | build = tmp_path_factory.mktemp(kernel.__name__) | 356 | build = tmp_path_factory.mktemp(kernel.__name__) |
| 356 | (build / "pypto_tprint.h").write_text("") | 357 | (build / "pypto_tprint.h").write_text("") |
| 357 | - cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "") | 358 | + cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "") |
| 358 | source = build / "kernel.cpp" | 359 | source = build / "kernel.cpp" |
| 359 | source.write_text( | 360 | source.write_text( |
| 360 | "#include <cstdint>\n#include <cstdio>\n#include <cstdlib>\n" | 361 | "#include <cstdint>\n#include <cstdio>\n#include <cstdlib>\n" |
| @@ -14,13 +14,14 @@ import re | |||
| 14 | from textwrap import dedent | 14 | from textwrap import dedent |
| 15 | 15 | ||
| 16 | import pypto_pro.language as pl | 16 | import pypto_pro.language as pl |
| 17 | +from pypto_pro.runtime.platform import NpuArch | ||
| 17 | import pytest | 18 | import pytest |
| 18 | 19 | ||
| 19 | 20 | ||
| 20 | def _compile_to_cce(kernel) -> str: | 21 | def _compile_to_cce(kernel) -> str: |
| 21 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets | 22 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets |
| 22 | 23 | ||
| 23 | - cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "") | 24 | + cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "") |
| 24 | return _assemble_cv_source(cube, vector).content | 25 | return _assemble_cv_source(cube, vector).content |
| 25 | 26 | ||
| 26 | 27 | ||
| @@ -11,12 +11,13 @@ | |||
| 11 | """CCE codegen tests for per-tile-aware dynamic mutex deduplication.""" | 11 | """CCE codegen tests for per-tile-aware dynamic mutex deduplication.""" |
| 12 | 12 | ||
| 13 | import pypto_pro.language as pl | 13 | import pypto_pro.language as pl |
| 14 | +from pypto_pro.runtime.platform import NpuArch | ||
| 14 | 15 | ||
| 15 | 16 | ||
| 16 | def _compile_to_cce(kernel) -> str: | 17 | def _compile_to_cce(kernel) -> str: |
| 17 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets | 18 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets |
| 18 | 19 | ||
| 19 | - cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "") | 20 | + cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "") |
| 20 | return _assemble_cv_source(cube, vector).content | 21 | return _assemble_cv_source(cube, vector).content |
| 21 | 22 | ||
| 22 | 23 | ||
| @@ -14,12 +14,13 @@ | |||
| 14 | import re | 14 | import re |
| 15 | 15 | ||
| 16 | import pypto_pro.language as pl | 16 | import pypto_pro.language as pl |
| 17 | +from pypto_pro.runtime.platform import NpuArch | ||
| 17 | 18 | ||
| 18 | 19 | ||
| 19 | def _compile_to_cce(kernel) -> str: | 20 | def _compile_to_cce(kernel) -> str: |
| 20 | from pypto_pro.runtime.jit import _add_kernel_header, _assemble_cv_source, _parse_and_codegen_targets | 21 | from pypto_pro.runtime.jit import _add_kernel_header, _assemble_cv_source, _parse_and_codegen_targets |
| 21 | 22 | ||
| 22 | - cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "") | 23 | + cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "") |
| 23 | return _add_kernel_header(_assemble_cv_source(cube, vector)).content | 24 | return _add_kernel_header(_assemble_cv_source(cube, vector)).content |
| 24 | 25 | ||
| 25 | 26 | ||
| @@ -18,6 +18,7 @@ here, so only the fractional part is dropped. | |||
| 18 | 18 | ||
| 19 | import pypto_pro.language as pl | 19 | import pypto_pro.language as pl |
| 20 | from pypto_pro.language import Vf as vf # noqa: N813 | 20 | from pypto_pro.language import Vf as vf # noqa: N813 |
| 21 | +from pypto_pro.runtime.platform import NpuArch | ||
| 21 | import pytest | 22 | import pytest |
| 22 | 23 | ||
| 23 | _N, _M = 1, 64 | 24 | _N, _M = 1, 64 |
| @@ -26,7 +27,7 @@ _N, _M = 1, 64 | |||
| 26 | def _compile_to_cce(kernel) -> str: | 27 | def _compile_to_cce(kernel) -> str: |
| 27 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets | 28 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets |
| 28 | 29 | ||
| 29 | - cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "") | 30 | + cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "") |
| 30 | return _assemble_cv_source(cube, vector).content | 31 | return _assemble_cv_source(cube, vector).content |
| 31 | 32 | ||
| 32 | 33 | ||
| @@ -12,12 +12,13 @@ | |||
| 12 | """Direct CCE code-generation tests for A5 SIMT scalar math.""" | 12 | """Direct CCE code-generation tests for A5 SIMT scalar math.""" |
| 13 | 13 | ||
| 14 | import pypto_pro.language as pl | 14 | import pypto_pro.language as pl |
| 15 | +from pypto_pro.runtime.platform import NpuArch | ||
| 15 | 16 | ||
| 16 | 17 | ||
| 17 | def _compile_to_cce(kernel) -> str: | 18 | def _compile_to_cce(kernel) -> str: |
| 18 | from pypto_pro.runtime.jit import _add_kernel_header, _assemble_cv_source, _parse_and_codegen_targets | 19 | from pypto_pro.runtime.jit import _add_kernel_header, _assemble_cv_source, _parse_and_codegen_targets |
| 19 | 20 | ||
| 20 | - cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "") | 21 | + cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "") |
| 21 | return _add_kernel_header(_assemble_cv_source(cube, vector)).content | 22 | return _add_kernel_header(_assemble_cv_source(cube, vector)).content |
| 22 | 23 | ||
| 23 | 24 | ||
| @@ -21,12 +21,13 @@ pto.tsels is a different, incompatible op, so it raises a clear error). | |||
| 21 | import logging | 21 | import logging |
| 22 | 22 | ||
| 23 | import pypto_pro.language as pl | 23 | import pypto_pro.language as pl |
| 24 | +from pypto_pro.runtime.platform import NpuArch | ||
| 24 | 25 | ||
| 25 | 26 | ||
| 26 | def _compile_to_cce(kernel) -> str: | 27 | def _compile_to_cce(kernel) -> str: |
| 27 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets | 28 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets |
| 28 | 29 | ||
| 29 | - cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "") | 30 | + cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "") |
| 30 | return _assemble_cv_source(cube, vector).content | 31 | return _assemble_cv_source(cube, vector).content |
| 31 | 32 | ||
| 32 | 33 | ||
| @@ -18,10 +18,11 @@ import pypto_pro.language as pl | |||
| 18 | import pytest | 18 | import pytest |
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | -def _compile_to_cce(kernel, arch: str = "a5") -> str: | 21 | +def _compile_to_cce(kernel, arch: str = "3510") -> str: |
| 22 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets | 22 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets |
| 23 | + from pypto_pro.runtime.platform import normalize_arch | ||
| 23 | 24 | ||
| 24 | - cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), arch, "") | 25 | + cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), normalize_arch(arch), "") |
| 25 | return _assemble_cv_source(cube, vector).content | 26 | return _assemble_cv_source(cube, vector).content |
| 26 | 27 | ||
| 27 | 28 | ||
| @@ -520,5 +521,5 @@ def test_simt_auto_mutex_emits_pipe_v_lock_unlock_around_launch(): | |||
| 520 | 521 | ||
| 521 | 522 | ||
| 522 | def test_simt_codegen_rejects_pre_a5_architecture(): | 523 | def test_simt_codegen_rejects_pre_a5_architecture(): |
| 523 | - with pytest.raises(NotSupported, match="requires arch='a5'"): | 524 | + with pytest.raises(NotSupported, match="requires arch='3510'"): |
| 524 | _compile_to_cce(_simt_tile_codegen_kernel, arch="a3") | 525 | _compile_to_cce(_simt_tile_codegen_kernel, arch="a3") |
| @@ -12,12 +12,13 @@ | |||
| 12 | from textwrap import dedent | 12 | from textwrap import dedent |
| 13 | 13 | ||
| 14 | import pypto_pro.language as pl | 14 | import pypto_pro.language as pl |
| 15 | +from pypto_pro.runtime.platform import NpuArch | ||
| 15 | 16 | ||
| 16 | 17 | ||
| 17 | def _compile_cube(kernel) -> str: | 18 | def _compile_cube(kernel) -> str: |
| 18 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets | 19 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets |
| 19 | 20 | ||
| 20 | - cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "") | 21 | + cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "") |
| 21 | source = _assemble_cv_source(cube, vector).content | 22 | source = _assemble_cv_source(cube, vector).content |
| 22 | return source.split("#if defined(__DAV_VEC__)")[0] | 23 | return source.split("#if defined(__DAV_VEC__)")[0] |
| 23 | 24 | ||
| @@ -28,6 +28,7 @@ tests/st/pypto_pro/frontend/datacopy/test_load_order_variants.py. | |||
| 28 | import re | 28 | import re |
| 29 | 29 | ||
| 30 | import pypto_pro.language as pl | 30 | import pypto_pro.language as pl |
| 31 | +from pypto_pro.runtime.platform import NpuArch | ||
| 31 | 32 | ||
| 32 | DIM = 16 | 33 | DIM = 16 |
| 33 | TILE = 64 | 34 | TILE = 64 |
| @@ -36,7 +37,7 @@ TILE = 64 | |||
| 36 | def _compile_to_cce(kernel) -> str: | 37 | def _compile_to_cce(kernel) -> str: |
| 37 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets | 38 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets |
| 38 | 39 | ||
| 39 | - cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "") | 40 | + cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "") |
| 40 | return _assemble_cv_source(cube, vector).content | 41 | return _assemble_cv_source(cube, vector).content |
| 41 | 42 | ||
| 42 | 43 | ||
| @@ -22,13 +22,14 @@ import subprocess | |||
| 22 | from textwrap import dedent | 22 | from textwrap import dedent |
| 23 | 23 | ||
| 24 | import pypto_pro.language as pl | 24 | import pypto_pro.language as pl |
| 25 | +from pypto_pro.runtime.platform import NpuArch | ||
| 25 | import pytest | 26 | import pytest |
| 26 | 27 | ||
| 27 | 28 | ||
| 28 | def _compile_to_cce(kernel) -> str: | 29 | def _compile_to_cce(kernel) -> str: |
| 29 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets | 30 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets |
| 30 | 31 | ||
| 31 | - cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "") | 32 | + cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "") |
| 32 | return _assemble_cv_source(cube, vector).content | 33 | return _assemble_cv_source(cube, vector).content |
| 33 | 34 | ||
| 34 | 35 | ||
| @@ -11,12 +11,13 @@ | |||
| 11 | """CCE code-generation tests for pointer and tensor re-view APIs.""" | 11 | """CCE code-generation tests for pointer and tensor re-view APIs.""" |
| 12 | 12 | ||
| 13 | import pypto_pro.language as pl | 13 | import pypto_pro.language as pl |
| 14 | +from pypto_pro.runtime.platform import NpuArch | ||
| 14 | 15 | ||
| 15 | 16 | ||
| 16 | def _compile_to_cce(kernel) -> str: | 17 | def _compile_to_cce(kernel) -> str: |
| 17 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets | 18 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets |
| 18 | 19 | ||
| 19 | - cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "") | 20 | + cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "") |
| 20 | return _assemble_cv_source(cube, vector).content | 21 | return _assemble_cv_source(cube, vector).content |
| 21 | 22 | ||
| 22 | 23 | ||
| @@ -21,6 +21,7 @@ coverage. | |||
| 21 | import re | 21 | import re |
| 22 | 22 | ||
| 23 | import pypto_pro.language as pl | 23 | import pypto_pro.language as pl |
| 24 | +from pypto_pro.runtime.platform import NpuArch | ||
| 24 | from pypto_pro.runtime.tilingkey import TilingKeyField | 25 | from pypto_pro.runtime.tilingkey import TilingKeyField |
| 25 | import pytest | 26 | import pytest |
| 26 | 27 | ||
| @@ -38,7 +39,7 @@ class _ManualSyncTilingKey: | |||
| 38 | def _compile_to_cce(kernel_def) -> str: | 39 | def _compile_to_cce(kernel_def) -> str: |
| 39 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets | 40 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets |
| 40 | 41 | ||
| 41 | - cube, vector = _parse_and_codegen_targets(kernel_def, "a5", "") | 42 | + cube, vector = _parse_and_codegen_targets(kernel_def, NpuArch.DAV_3510, "") |
| 42 | return _assemble_cv_source(cube, vector).content | 43 | return _assemble_cv_source(cube, vector).content |
| 43 | 44 | ||
| 44 | 45 | ||
| @@ -14,6 +14,7 @@ from dataclasses import dataclass | |||
| 14 | import logging | 14 | import logging |
| 15 | 15 | ||
| 16 | import pypto_pro.language as pl | 16 | import pypto_pro.language as pl |
| 17 | +from pypto_pro.runtime.platform import NpuArch | ||
| 17 | 18 | ||
| 18 | 19 | ||
| 19 | def _codegen_result(kernel): | 20 | def _codegen_result(kernel): |
| @@ -21,7 +22,7 @@ def _codegen_result(kernel): | |||
| 21 | from pypto_pro.runtime.kernel import KernelDef | 22 | from pypto_pro.runtime.kernel import KernelDef |
| 22 | 23 | ||
| 23 | kernel_def = kernel if isinstance(kernel, KernelDef) else kernel.to_kernel_def() | 24 | kernel_def = kernel if isinstance(kernel, KernelDef) else kernel.to_kernel_def() |
| 24 | - cube, vector = _parse_and_codegen_targets(kernel_def, "a5", "") | 25 | + cube, vector = _parse_and_codegen_targets(kernel_def, NpuArch.DAV_3510, "") |
| 25 | return _assemble_cv_source(cube, vector) | 26 | return _assemble_cv_source(cube, vector) |
| 26 | 27 | ||
| 27 | 28 | ||
| @@ -18,12 +18,13 @@ core_type attribute. Covered cases include the default Mix and explicit AIVOnly. | |||
| 18 | import logging | 18 | import logging |
| 19 | 19 | ||
| 20 | import pypto_pro.language as pl | 20 | import pypto_pro.language as pl |
| 21 | +from pypto_pro.runtime.platform import NpuArch | ||
| 21 | 22 | ||
| 22 | 23 | ||
| 23 | def _compile_to_cce(kernel) -> str: | 24 | def _compile_to_cce(kernel) -> str: |
| 24 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets | 25 | from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets |
| 25 | 26 | ||
| 26 | - cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "") | 27 | + cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "") |
| 27 | return _assemble_cv_source(cube, vector).content | 28 | return _assemble_cv_source(cube, vector).content |
| 28 | 29 | ||
| 29 | 30 | ||
| @@ -773,7 +773,7 @@ def test_make_tile_addr_from_constant_expression(): | |||
| 773 | @pytest.mark.parametrize("memory", [pl.MemorySpace.Left, pl.MemorySpace.Right, pl.MemorySpace.Acc]) | 773 | @pytest.mark.parametrize("memory", [pl.MemorySpace.Left, pl.MemorySpace.Right, pl.MemorySpace.Acc]) |
| 774 | @pytest.mark.parametrize("layout", [pl.ZZ, pl.NN]) | 774 | @pytest.mark.parametrize("layout", [pl.ZZ, pl.NN]) |
| 775 | def test_a5_rejects_zz_nn_for_cube_buffers(monkeypatch, memory, layout): | 775 | def test_a5_rejects_zz_nn_for_cube_buffers(monkeypatch, memory, layout): |
| 776 | - monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "a5") | 776 | + monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "3510") |
| 777 | 777 | ||
| 778 | with pytest.raises(InvalidVal, match="do not support"): | 778 | with pytest.raises(InvalidVal, match="do not support"): |
| 779 | 779 | ||
| @@ -791,7 +791,7 @@ def test_a5_rejects_zz_nn_for_cube_buffers(monkeypatch, memory, layout): | |||
| 791 | 791 | ||
| 792 | 792 | ||
| 793 | def test_a5_allows_regular_cube_buffer_layouts(monkeypatch): | 793 | def test_a5_allows_regular_cube_buffer_layouts(monkeypatch): |
| 794 | - monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "a5") | 794 | + monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "3510") |
| 795 | 795 | ||
| 796 | @pl.jit(auto_mutex=False) | 796 | @pl.jit(auto_mutex=False) |
| 797 | def create_tile(_jit_entry: pl.DT_INT64): | 797 | def create_tile(_jit_entry: pl.DT_INT64): |
| @@ -831,7 +831,7 @@ def test_high_dimensional_nz_load_store_use_last_two_axes_by_default(): | |||
| 831 | 831 | ||
| 832 | 832 | ||
| 833 | def test_store_and_store_tile_with_scaling_tile_use_store_op(monkeypatch): | 833 | def test_store_and_store_tile_with_scaling_tile_use_store_op(monkeypatch): |
| 834 | - monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "a5") | 834 | + monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "3510") |
| 835 | 835 | ||
| 836 | @pl.jit(auto_mutex=False) | 836 | @pl.jit(auto_mutex=False) |
| 837 | def main(out: pl.Tensor[[64, 64], pl.DT_INT8]): | 837 | def main(out: pl.Tensor[[64, 64], pl.DT_INT8]): |
| @@ -300,7 +300,7 @@ def test_matmul_mx_acc_rejects_invalid_phase(): | |||
| 300 | ) | 300 | ) |
| 301 | def test_mx_scale_tile_defaults_to_fractal_32(target_memory, layout, shape, monkeypatch): | 301 | def test_mx_scale_tile_defaults_to_fractal_32(target_memory, layout, shape, monkeypatch): |
| 302 | if target_memory in (ir.MemorySpace.ScaleLeft, ir.MemorySpace.ScaleRight): | 302 | if target_memory in (ir.MemorySpace.ScaleLeft, ir.MemorySpace.ScaleRight): |
| 303 | - monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "a5") | 303 | + monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "3510") |
| 304 | tile_type = TileType( | 304 | tile_type = TileType( |
| 305 | shape=shape, dtype=DataType.FP8E8M0, target_memory=target_memory, layout=layout | 305 | shape=shape, dtype=DataType.FP8E8M0, target_memory=target_memory, layout=layout |
| 306 | ) | 306 | ) |
| @@ -317,7 +317,7 @@ def test_mx_scale_tile_defaults_to_fractal_32(target_memory, layout, shape, monk | |||
| 317 | ], | 317 | ], |
| 318 | ) | 318 | ) |
| 319 | def test_mx_scale_tile_rejects_non_32_fractal(target_memory, layout, shape, monkeypatch): | 319 | def test_mx_scale_tile_rejects_non_32_fractal(target_memory, layout, shape, monkeypatch): |
| 320 | - monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "a5") | 320 | + monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "3510") |
| 321 | with pytest.raises(ValueError, match="require fractal=32"): | 321 | with pytest.raises(ValueError, match="require fractal=32"): |
| 322 | TileType( | 322 | TileType( |
| 323 | shape=shape, | 323 | shape=shape, |
| @@ -32,13 +32,13 @@ from pypto_pro._errors import ( | |||
| 32 | NotSupported, | 32 | NotSupported, |
| 33 | ) | 33 | ) |
| 34 | import pypto_pro.language as pl | 34 | import pypto_pro.language as pl |
| 35 | -from pypto_pro.runtime.platform import get_platform_info | 35 | +from pypto_pro.runtime.platform import NpuArch, get_platform_info |
| 36 | import pytest | 36 | import pytest |
| 37 | import torch | 37 | import torch |
| 38 | 38 | ||
| 39 | pytestmark = pytest.mark.skipif( | 39 | pytestmark = pytest.mark.skipif( |
| 40 | - get_platform_info().arch != "a5", | 40 | + get_platform_info().arch != NpuArch.DAV_3510, |
| 41 | - reason="PyPTO Pro only supports arch 'a5'", | 41 | + reason="PyPTO Pro only supports arch '3510'", |
| 42 | ) | 42 | ) |
| 43 | 43 | ||
| 44 | 44 | ||
| @@ -219,7 +219,7 @@ def test_auto_mutex_single_tile(): | |||
| 219 | 219 | ||
| 220 | 220 | ||
| 221 | def test_auto_mutex_locks_scale_kwarg_tile(monkeypatch): | 221 | def test_auto_mutex_locks_scale_kwarg_tile(monkeypatch): |
| 222 | - monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "a5") | 222 | + monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "3510") |
| 223 | 223 | ||
| 224 | @pl.jit(auto_mutex=True) | 224 | @pl.jit(auto_mutex=True) |
| 225 | def k(out: pl.Tensor[[64, 64], pl.DT_INT8]): | 225 | def k(out: pl.Tensor[[64, 64], pl.DT_INT8]): |
| @@ -276,7 +276,7 @@ def test_sync_rejects_aic_only_path_in_vector_section(): | |||
| 276 | event_id=0, | 276 | event_id=0, |
| 277 | ) | 277 | ) |
| 278 | 278 | ||
| 279 | - with pytest.raises(NotSupported, match="unsupported A5 synchronization path on AIV"): | 279 | + with pytest.raises(NotSupported, match="unsupported 3510 synchronization path on AIV"): |
| 280 | func.to_kernel_def().parse_target_program(ir.SectionKind.Vector) | 280 | func.to_kernel_def().parse_target_program(ir.SectionKind.Vector) |
| 281 | 281 | ||
| 282 | 282 | ||
| @@ -290,7 +290,7 @@ def test_sync_rejects_aiv_only_path_in_cube_section(): | |||
| 290 | event_id=0, | 290 | event_id=0, |
| 291 | ) | 291 | ) |
| 292 | 292 | ||
| 293 | - with pytest.raises(NotSupported, match="unsupported A5 synchronization path on AIC"): | 293 | + with pytest.raises(NotSupported, match="unsupported 3510 synchronization path on AIC"): |
| 294 | func.to_kernel_def().parse_target_program(ir.SectionKind.Cube) | 294 | func.to_kernel_def().parse_target_program(ir.SectionKind.Cube) |
| 295 | 295 | ||
| 296 | 296 | ||
| @@ -304,7 +304,7 @@ def test_sync_rejects_unsupported_aic_pipe_path(): | |||
| 304 | event_id=0, | 304 | event_id=0, |
| 305 | ) | 305 | ) |
| 306 | 306 | ||
| 307 | - with pytest.raises(NotSupported, match="unsupported A5 synchronization path on AIC"): | 307 | + with pytest.raises(NotSupported, match="unsupported 3510 synchronization path on AIC"): |
| 308 | func.to_kernel_def().parse_target_program(ir.SectionKind.Cube) | 308 | func.to_kernel_def().parse_target_program(ir.SectionKind.Cube) |
| 309 | 309 | ||
| 310 | 310 | ||
| @@ -89,7 +89,7 @@ def test_tile_type_bias_single_row_allowed(): | |||
| 89 | 89 | ||
| 90 | 90 | ||
| 91 | def test_tile_type_bias_non_nd_layout_rejected(): | 91 | def test_tile_type_bias_non_nd_layout_rejected(): |
| 92 | - @pl.jit(arch="a5") | 92 | + @pl.jit(arch="3510") |
| 93 | def k(x: pl.Tensor[[1, 128], pl.DT_FP32]): | 93 | def k(x: pl.Tensor[[1, 128], pl.DT_FP32]): |
| 94 | tt = pl.TileType( | 94 | tt = pl.TileType( |
| 95 | shape=[1, 128], dtype=pl.DT_FP32, target_memory=pl.MemorySpace.Bias, layout=pl.DN | 95 | shape=[1, 128], dtype=pl.DT_FP32, target_memory=pl.MemorySpace.Bias, layout=pl.DN |
| @@ -22,6 +22,7 @@ import sys | |||
| 22 | from unittest.mock import MagicMock | 22 | from unittest.mock import MagicMock |
| 23 | 23 | ||
| 24 | from pypto_pro._errors import InvalidShape | 24 | from pypto_pro._errors import InvalidShape |
| 25 | +from pypto_pro.runtime.platform import NpuArch | ||
| 25 | import pytest | 26 | import pytest |
| 26 | 27 | ||
| 27 | # --------------------------------------------------------------------------- | 28 | # --------------------------------------------------------------------------- |
| @@ -672,7 +673,7 @@ def test_direct_call_launches_with_auto_sentinel(monkeypatch): | |||
| 672 | monkeypatch.setattr(_jit, "ctypes", _CtypesProxy(lib)) | 673 | monkeypatch.setattr(_jit, "ctypes", _CtypesProxy(lib)) |
| 673 | compiled = CompiledKernel(lib_path="<fake>", param_specs=[]) | 674 | compiled = CompiledKernel(lib_path="<fake>", param_specs=[]) |
| 674 | monkeypatch.setattr(_jit, "_launch", MagicMock()) | 675 | monkeypatch.setattr(_jit, "_launch", MagicMock()) |
| 675 | - kernel = _jit._TileJitKernel(lambda: None, arch="a5") | 676 | + kernel = _jit._TileJitKernel(lambda: None, arch=NpuArch.DAV_3510) |
| 676 | monkeypatch.setattr(kernel, "_validate_launch_arch", lambda: None) | 677 | monkeypatch.setattr(kernel, "_validate_launch_arch", lambda: None) |
| 677 | monkeypatch.setattr(kernel, "_ensure_compiled", lambda *_args, **_kwargs: compiled) | 678 | monkeypatch.setattr(kernel, "_ensure_compiled", lambda *_args, **_kwargs: compiled) |
| 678 | kernel() | 679 | kernel() |
| @@ -703,7 +704,7 @@ def test_explicit_stream_validated_once_at_launcher_creation(monkeypatch): | |||
| 703 | _as_parameter_ = 0xDEAD | 704 | _as_parameter_ = 0xDEAD |
| 704 | 705 | ||
| 705 | monkeypatch.setattr(_torch_mock.npu, "Stream", NPUStream) | 706 | monkeypatch.setattr(_torch_mock.npu, "Stream", NPUStream) |
| 706 | - kernel = _jit._TileJitKernel(lambda: None, arch="a5") | 707 | + kernel = _jit._TileJitKernel(lambda: None, arch=NpuArch.DAV_3510) |
| 707 | with pytest.raises(TypeError, match="stream must be torch.npu.Stream or None"): | 708 | with pytest.raises(TypeError, match="stream must be torch.npu.Stream or None"): |
| 708 | kernel[ForeignStream(), 8] | 709 | kernel[ForeignStream(), 8] |
| 709 | 710 | ||
| @@ -16,6 +16,7 @@ from unittest.mock import MagicMock | |||
| 16 | from pypto_pro._errors import InvalidVal, RuntimeFailure | 16 | from pypto_pro._errors import InvalidVal, RuntimeFailure |
| 17 | import pypto_pro.language as pl | 17 | import pypto_pro.language as pl |
| 18 | from pypto_pro.runtime.compile_config import JitCompileConfig, KernelTarget, get_jit_compile_config | 18 | from pypto_pro.runtime.compile_config import JitCompileConfig, KernelTarget, get_jit_compile_config |
| 19 | +from pypto_pro.runtime.platform import NpuArch, normalize_arch | ||
| 19 | import pytest | 20 | import pytest |
| 20 | 21 | ||
| 21 | jit = importlib.import_module("pypto_pro.runtime.jit") | 22 | jit = importlib.import_module("pypto_pro.runtime.jit") |
| @@ -23,22 +24,21 @@ jit = importlib.import_module("pypto_pro.runtime.jit") | |||
| 23 | 24 | ||
| 24 | @pytest.fixture | 25 | @pytest.fixture |
| 25 | def future_config(): | 26 | def future_config(): |
| 26 | - """A hypothetical 1:1 architecture must coexist with A5; its compiler name is a test-only placeholder.""" | 27 | + """A hypothetical 1:1 architecture (the unconfigured DAV_3003 slot) must coexist with 3510.""" |
| 27 | config = get_jit_compile_config() | 28 | config = get_jit_compile_config() |
| 28 | return replace( | 29 | return replace( |
| 29 | config, | 30 | config, |
| 30 | kernel_targets={ | 31 | kernel_targets={ |
| 31 | **config.kernel_targets, | 32 | **config.kernel_targets, |
| 32 | - "future": {"cube_vec": KernelTarget("test-mixed-1-1", 1, 1, True)}, | 33 | + NpuArch.DAV_3003: {"cube_vec": KernelTarget("test-mixed-1-1", 1, 1, True)}, |
| 33 | }, | 34 | }, |
| 34 | - memory_arch_flags={**config.memory_arch_flags, "future": "-DTEST_MEMORY_ARCH"}, | 35 | + memory_arch_flags={**config.memory_arch_flags, NpuArch.DAV_3003: "-DTEST_MEMORY_ARCH"}, |
| 35 | ) | 36 | ) |
| 36 | 37 | ||
| 37 | 38 | ||
| 38 | @pytest.mark.parametrize("arch,npu_arch,memory", [ | 39 | @pytest.mark.parametrize("arch,npu_arch,memory", [ |
| 39 | - ("a2", "dav-2201", "-DMEMORY_BASE"), | 40 | + (NpuArch.DAV_2201, "dav-2201", "-DMEMORY_BASE"), |
| 40 | - ("a3", "dav-2201", "-DMEMORY_BASE"), | 41 | + (NpuArch.DAV_3510, "dav-3510", "-DREGISTER_BASE"), |
| 41 | - ("a5", "dav-3510", "-DREGISTER_BASE"), | ||
| 42 | ]) | 42 | ]) |
| 43 | @pytest.mark.parametrize("cube,vector,qualifier,cores,kernel_type", [ | 43 | @pytest.mark.parametrize("cube,vector,qualifier,cores,kernel_type", [ |
| 44 | (True, False, "__cube__", (1, 0), 0), | 44 | (True, False, "__cube__", (1, 0), 0), |
| @@ -77,12 +77,12 @@ def test_asc_targets_keep_entry_profiling_and_launch_geometry_consistent( | |||
| 77 | 77 | ||
| 78 | 78 | ||
| 79 | def test_simt_launcher_bakes_inferred_dynamic_ub_into_generated_caller(): | 79 | def test_simt_launcher_bakes_inferred_dynamic_ub_into_generated_caller(): |
| 80 | - target = get_jit_compile_config().resolve_kernel_target("a5", has_cube=False, has_vector=True) | 80 | + target = get_jit_compile_config().resolve_kernel_target(NpuArch.DAV_3510, has_cube=False, has_vector=True) |
| 81 | caller = jit._generate_caller_cpp( | 81 | caller = jit._generate_caller_cpp( |
| 82 | [], "kernel.cpp", "probe", target=target, required_dynamic_ub_size=16 * 1024, | 82 | [], "kernel.cpp", "probe", target=target, required_dynamic_ub_size=16 * 1024, |
| 83 | ) | 83 | ) |
| 84 | flags = jit._build_bisheng_flags( | 84 | flags = jit._build_bisheng_flags( |
| 85 | - "/toolkit", "a5", target, has_cross_sync=False, enable_print_debug=False, | 85 | + "/toolkit", NpuArch.DAV_3510, target, has_cross_sync=False, enable_print_debug=False, |
| 86 | ) | 86 | ) |
| 87 | assert "uint32_t dynamicUbSize" not in caller | 87 | assert "uint32_t dynamicUbSize" not in caller |
| 88 | assert 'call_kernel(uint32_t blockDim, void* stream)' in caller | 88 | assert 'call_kernel(uint32_t blockDim, void* stream)' in caller |
| @@ -93,40 +93,42 @@ def test_simt_launcher_bakes_inferred_dynamic_ub_into_generated_caller(): | |||
| 93 | 93 | ||
| 94 | def test_architecture_specific_mixed_geometry_is_independent(future_config): | 94 | def test_architecture_specific_mixed_geometry_is_independent(future_config): |
| 95 | """A future 1:1 target must not overwrite the 1:2 rule of an existing architecture.""" | 95 | """A future 1:1 target must not overwrite the 1:2 rule of an existing architecture.""" |
| 96 | - a5 = future_config.resolve_kernel_target(" A5 ", has_cube=True, has_vector=True) | 96 | + a5 = future_config.resolve_kernel_target(NpuArch.DAV_3510, has_cube=True, has_vector=True) |
| 97 | - future = future_config.resolve_kernel_target("future", has_cube=True, has_vector=True) | 97 | + future = future_config.resolve_kernel_target(NpuArch.DAV_3003, has_cube=True, has_vector=True) |
| 98 | assert (a5.aic_per_block, a5.aiv_per_block) == (1, 2) | 98 | assert (a5.aic_per_block, a5.aiv_per_block) == (1, 2) |
| 99 | assert (future.aic_per_block, future.aiv_per_block) == (1, 1) | 99 | assert (future.aic_per_block, future.aiv_per_block) == (1, 1) |
| 100 | assert "__mix__(1, 1)" in jit._make_global_entry("probe", [], target=future) | 100 | assert "__mix__(1, 1)" in jit._make_global_entry("probe", [], target=future) |
| 101 | 101 | ||
| 102 | 102 | ||
| 103 | def test_missing_architecture_is_not_assumed_to_use_a5_geometry(): | 103 | def test_missing_architecture_is_not_assumed_to_use_a5_geometry(): |
| 104 | - """Adding an extensible target table must not advertise unsupported A6 compilation.""" | 104 | + """Unknown arch names are rejected at the parse boundary; unconfigured members fail loudly.""" |
| 105 | - with pytest.raises(InvalidVal, match="kernel_targets.*a6"): | 105 | + with pytest.raises(InvalidVal, match="unknown arch.*a6"): |
| 106 | - get_jit_compile_config().resolve_kernel_target("a6", has_cube=True, has_vector=True) | 106 | + normalize_arch("a6") |
| 107 | + with pytest.raises(InvalidVal, match="does not define kernel_targets"): | ||
| 108 | + get_jit_compile_config().resolve_kernel_target(NpuArch.DAV_3113, has_cube=True, has_vector=True) | ||
| 107 | 109 | ||
| 108 | 110 | ||
| 109 | def test_missing_kernel_mode_is_not_replaced_with_mixed_target(future_config): | 111 | def test_missing_kernel_mode_is_not_replaced_with_mixed_target(future_config): |
| 110 | """A missing single-engine compiler target cannot safely use a mixed binary's launch ABI.""" | 112 | """A missing single-engine compiler target cannot safely use a mixed binary's launch ABI.""" |
| 111 | - with pytest.raises(InvalidVal, match=r"kernel_targets.future.cube"): | 113 | + with pytest.raises(InvalidVal, match=r"kernel_targets.3003.cube"): |
| 112 | - future_config.resolve_kernel_target("future", has_cube=True, has_vector=False) | 114 | + future_config.resolve_kernel_target(NpuArch.DAV_3003, has_cube=True, has_vector=False) |
| 113 | 115 | ||
| 114 | 116 | ||
| 115 | def test_empty_kernel_is_rejected_before_selecting_flags(): | 117 | def test_empty_kernel_is_rejected_before_selecting_flags(): |
| 116 | """The old default arch variant could hide a kernel with neither execution engine.""" | 118 | """The old default arch variant could hide a kernel with neither execution engine.""" |
| 117 | with pytest.raises(RuntimeFailure, match="add a target section"): | 119 | with pytest.raises(RuntimeFailure, match="add a target section"): |
| 118 | - get_jit_compile_config().resolve_kernel_target("a5", has_cube=False, has_vector=False) | 120 | + get_jit_compile_config().resolve_kernel_target(NpuArch.DAV_3510, has_cube=False, has_vector=False) |
| 119 | 121 | ||
| 120 | 122 | ||
| 121 | @pytest.mark.parametrize("cube,vector,missing", [(True, False, "vector"), (False, True, "cube")]) | 123 | @pytest.mark.parametrize("cube,vector,missing", [(True, False, "vector"), (False, True, "cube")]) |
| 122 | def test_cross_sync_still_requires_both_engines(cube, vector, missing): | 124 | def test_cross_sync_still_requires_both_engines(cube, vector, missing): |
| 123 | """Switching flag generation to a descriptor must retain the incomplete-sync diagnostic.""" | 125 | """Switching flag generation to a descriptor must retain the incomplete-sync diagnostic.""" |
| 124 | - target = get_jit_compile_config().resolve_kernel_target("a5", has_cube=cube, has_vector=vector) | 126 | + target = get_jit_compile_config().resolve_kernel_target(NpuArch.DAV_3510, has_cube=cube, has_vector=vector) |
| 125 | with pytest.raises(ValueError, match=f"{missing} code is missing"): | 127 | with pytest.raises(ValueError, match=f"{missing} code is missing"): |
| 126 | - jit._build_bisheng_flags("/toolkit", "a5", target, has_cross_sync=True, enable_print_debug=False) | 128 | + jit._build_bisheng_flags("/toolkit", NpuArch.DAV_3510, target, has_cross_sync=True, enable_print_debug=False) |
| 127 | 129 | ||
| 128 | 130 | ||
| 129 | -@pytest.mark.parametrize("arch,cores", [("a5", (1, 2)), ("future", (1, 1))]) | 131 | +@pytest.mark.parametrize("arch,cores", [(NpuArch.DAV_3510, (1, 2)), (NpuArch.DAV_3003, (1, 1))]) |
| 130 | def test_shared_library_and_caller_use_the_same_resolved_target(monkeypatch, tmp_path, future_config, arch, cores): | 132 | def test_shared_library_and_caller_use_the_same_resolved_target(monkeypatch, tmp_path, future_config, arch, cores): |
| 131 | """Capture a real build command and caller; independently resolving either half would permit ABI drift.""" | 133 | """Capture a real build command and caller; independently resolving either half would permit ABI drift.""" |
| 132 | target = future_config.resolve_kernel_target(arch, has_cube=True, has_vector=True) | 134 | target = future_config.resolve_kernel_target(arch, has_cube=True, has_vector=True) |
| @@ -181,12 +183,12 @@ def test_compilation_preserves_target_for_cached_launch_and_debug(monkeypatch, t | |||
| 181 | monkeypatch.setattr(jit, "_codegen", lambda *_args, **_kwargs: cg) | 183 | monkeypatch.setattr(jit, "_codegen", lambda *_args, **_kwargs: cg) |
| 182 | build = MagicMock(return_value="/tmp/test-kernel.so") | 184 | build = MagicMock(return_value="/tmp/test-kernel.so") |
| 183 | monkeypatch.setattr(jit, "_build_jit_so", build) | 185 | monkeypatch.setattr(jit, "_build_jit_so", build) |
| 184 | - kernel = jit._TileJitKernel(lambda: None, arch="a5", compile_timeout=30) | 186 | + kernel = jit._TileJitKernel(lambda: None, arch=NpuArch.DAV_3510, compile_timeout=30) |
| 185 | monkeypatch.setattr(kernel, "to_kernel_def", lambda *_args, **_kwargs: None) | 187 | monkeypatch.setattr(kernel, "to_kernel_def", lambda *_args, **_kwargs: None) |
| 186 | compiled = kernel._compile_variant(None, (None, None, None, None), None, ()) | 188 | compiled = kernel._compile_variant(None, (None, None, None, None), None, ()) |
| 187 | - resolve.assert_called_once_with("a5", has_cube=True, has_vector=True) | 189 | + resolve.assert_called_once_with(NpuArch.DAV_3510, has_cube=True, has_vector=True) |
| 188 | assert compiled.target is build.call_args.kwargs["target"] | 190 | assert compiled.target is build.call_args.kwargs["target"] |
| 189 | - assert compiled.target is config.kernel_targets["a5"]["cube_vec"] | 191 | + assert compiled.target is config.kernel_targets[NpuArch.DAV_3510]["cube_vec"] |
| 190 | 192 | ||
| 191 | 193 | ||
| 192 | def test_debug_command_reuses_compiled_target_without_resolving(monkeypatch, tmp_path): | 194 | def test_debug_command_reuses_compiled_target_without_resolving(monkeypatch, tmp_path): |
| @@ -196,7 +198,7 @@ def test_debug_command_reuses_compiled_target_without_resolving(monkeypatch, tmp | |||
| 196 | monkeypatch.setenv("ASCEND_WORK_PATH", str(tmp_path)) | 198 | monkeypatch.setenv("ASCEND_WORK_PATH", str(tmp_path)) |
| 197 | monkeypatch.setenv("ASCEND_HOME_PATH", "/toolkit") | 199 | monkeypatch.setenv("ASCEND_HOME_PATH", "/toolkit") |
| 198 | monkeypatch.setenv("ASCEND_TOOLKIT_HOME", "/toolkit") | 200 | monkeypatch.setenv("ASCEND_TOOLKIT_HOME", "/toolkit") |
| 199 | - monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "a5") | 201 | + monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "3510") |
| 200 | monkeypatch.setattr(dump.shutil, "which", lambda _: "/toolkit/bin/bisheng") | 202 | monkeypatch.setattr(dump.shutil, "which", lambda _: "/toolkit/bin/bisheng") |
| 201 | monkeypatch.setattr( | 203 | monkeypatch.setattr( |
| 202 | JitCompileConfig, "resolve_kernel_target", MagicMock(side_effect=AssertionError("Already resolved")), | 204 | JitCompileConfig, "resolve_kernel_target", MagicMock(side_effect=AssertionError("Already resolved")), |
| @@ -22,6 +22,7 @@ import importlib | |||
| 22 | from pathlib import Path | 22 | from pathlib import Path |
| 23 | import subprocess | 23 | import subprocess |
| 24 | 24 | ||
| 25 | +from pypto_pro.runtime.platform import NpuArch | ||
| 25 | import pytest | 26 | import pytest |
| 26 | 27 | ||
| 27 | jit = importlib.import_module("pypto_pro.runtime.jit") | 28 | jit = importlib.import_module("pypto_pro.runtime.jit") |
| @@ -81,18 +82,18 @@ static void RecordLaunch(uint32_t dim, void*, int64_t* = nullptr) | |||
| 81 | } | 82 | } |
| 82 | """ | 83 | """ |
| 83 | config = jit.get_jit_compile_config() | 84 | config = jit.get_jit_compile_config() |
| 84 | - # A future architecture can use 1:1 without changing A5's 1:2 ABI. This target | 85 | + # A future architecture can use 1:1 without changing 3510's 1:2 ABI. This target |
| 85 | # name is only a test fixture, not a supported Bisheng architecture. | 86 | # name is only a test fixture, not a supported Bisheng architecture. |
| 86 | config = replace(config, kernel_targets={ | 87 | config = replace(config, kernel_targets={ |
| 87 | **config.kernel_targets, | 88 | **config.kernel_targets, |
| 88 | - "future": {"cube_vec": jit.KernelTarget("test-mixed-1-1", 1, 1, True)}, | 89 | + NpuArch.DAV_3003: {"cube_vec": jit.KernelTarget("test-mixed-1-1", 1, 1, True)}, |
| 89 | }) | 90 | }) |
| 90 | modes = { | 91 | modes = { |
| 91 | - "cube": ("a5", True, False, False), | 92 | + "cube": (NpuArch.DAV_3510, True, False, False), |
| 92 | - "vector": ("a5", False, True, False), | 93 | + "vector": (NpuArch.DAV_3510, False, True, False), |
| 93 | - "mixed": ("a5", True, True, False), | 94 | + "mixed": (NpuArch.DAV_3510, True, True, False), |
| 94 | - "mixed_1_1": ("future", True, True, False), | 95 | + "mixed_1_1": (NpuArch.DAV_3003, True, True, False), |
| 95 | - "sync": ("a5", True, True, True), | 96 | + "sync": (NpuArch.DAV_3510, True, True, True), |
| 96 | } | 97 | } |
| 97 | for name, (arch, has_cube, has_vec, cross_sync) in modes.items(): | 98 | for name, (arch, has_cube, has_vec, cross_sync) in modes.items(): |
| 98 | caller = jit._generate_caller_cpp( | 99 | caller = jit._generate_caller_cpp( |
| @@ -22,10 +22,11 @@ from pypto_pro.runtime.jit import ( | |||
| 22 | _generate_prof_range_snippet, | 22 | _generate_prof_range_snippet, |
| 23 | _parse_and_codegen_targets, | 23 | _parse_and_codegen_targets, |
| 24 | ) | 24 | ) |
| 25 | +from pypto_pro.runtime.platform import NpuArch | ||
| 25 | 26 | ||
| 26 | 27 | ||
| 27 | def _snippet(kernel_name, specs, dims): | 28 | def _snippet(kernel_name, specs, dims): |
| 28 | - target = get_jit_compile_config().resolve_kernel_target("a5", has_cube=False, has_vector=True) | 29 | + target = get_jit_compile_config().resolve_kernel_target(NpuArch.DAV_3510, has_cube=False, has_vector=True) |
| 29 | return _generate_prof_range_snippet( | 30 | return _generate_prof_range_snippet( |
| 30 | kernel_name, specs, dims, target=target, launch_stmt=" k<<<blockDim, nullptr, stream>>>(a, out);\n" | 31 | kernel_name, specs, dims, target=target, launch_stmt=" k<<<blockDim, nullptr, stream>>>(a, out);\n" |
| 31 | ) | 32 | ) |
| @@ -49,7 +50,7 @@ def test_output_annotation_sets_direction(): | |||
| 49 | pl.store(out, ta, [0, 0]) | 50 | pl.store(out, ta, [0, 0]) |
| 50 | 51 | ||
| 51 | kernel_def = marked_kernel.to_kernel_def() | 52 | kernel_def = marked_kernel.to_kernel_def() |
| 52 | - cube, vector = _parse_and_codegen_targets(kernel_def, "a5", "") | 53 | + cube, vector = _parse_and_codegen_targets(kernel_def, NpuArch.DAV_3510, "") |
| 53 | cg = cube or vector | 54 | cg = cube or vector |
| 54 | assert kernel_def.last_param_directions == {1: pl.Output} | 55 | assert kernel_def.last_param_directions == {1: pl.Output} |
| 55 | assert cg.param_specs[0].direction is pl.Input | 56 | assert cg.param_specs[0].direction is pl.Input |
| @@ -69,7 +70,7 @@ def test_call_style_output_annotation_sets_direction(): | |||
| 69 | pl.store(out, ta, [0, 0]) | 70 | pl.store(out, ta, [0, 0]) |
| 70 | 71 | ||
| 71 | kernel_def = marked_kernel.to_kernel_def() | 72 | kernel_def = marked_kernel.to_kernel_def() |
| 72 | - cube, vector = _parse_and_codegen_targets(kernel_def, "a5", "") | 73 | + cube, vector = _parse_and_codegen_targets(kernel_def, NpuArch.DAV_3510, "") |
| 73 | cg = cube or vector | 74 | cg = cube or vector |
| 74 | assert kernel_def.last_param_directions == {1: pl.Output} | 75 | assert kernel_def.last_param_directions == {1: pl.Output} |
| 75 | assert cg.param_specs[0].direction is pl.Input | 76 | assert cg.param_specs[0].direction is pl.Input |
| @@ -90,7 +91,7 @@ def test_output_direction_uses_absolute_parameter_index(): | |||
| 90 | pl.store(out, ta, [0, 0]) | 91 | pl.store(out, ta, [0, 0]) |
| 91 | 92 | ||
| 92 | kernel_def = marked_kernel.to_kernel_def() | 93 | kernel_def = marked_kernel.to_kernel_def() |
| 93 | - cube, vector = _parse_and_codegen_targets(kernel_def, "a5", "") | 94 | + cube, vector = _parse_and_codegen_targets(kernel_def, NpuArch.DAV_3510, "") |
| 94 | cg = cube or vector | 95 | cg = cube or vector |
| 95 | assert kernel_def.last_param_directions == {2: pl.Output} | 96 | assert kernel_def.last_param_directions == {2: pl.Output} |
| 96 | assert cg.param_specs[0].kind is ParamKind.SCALAR | 97 | assert cg.param_specs[0].kind is ParamKind.SCALAR |
| @@ -112,7 +113,7 @@ def test_omitted_direction_defaults_to_input(): | |||
| 112 | with pl.section_vector(): | 113 | with pl.section_vector(): |
| 113 | pl.store(out, ta, [0, 0]) | 114 | pl.store(out, ta, [0, 0]) |
| 114 | 115 | ||
| 115 | - cube, vector = _parse_and_codegen_targets(unmarked_kernel.to_kernel_def(), "a5", "") | 116 | + cube, vector = _parse_and_codegen_targets(unmarked_kernel.to_kernel_def(), NpuArch.DAV_3510, "") |
| 116 | cg = cube or vector | 117 | cg = cube or vector |
| 117 | assert cg.param_specs[0].direction is pl.Input | 118 | assert cg.param_specs[0].direction is pl.Input |
| 118 | 119 | ||
| @@ -182,10 +183,10 @@ def test_caller_embeds_metadata_around_launch_static(): | |||
| 182 | pl.add(tc, ta, ta) | 183 | pl.add(tc, ta, ta) |
| 183 | pl.store(out, tc, [0, 0]) | 184 | pl.store(out, tc, [0, 0]) |
| 184 | 185 | ||
| 185 | - cube, vector = _parse_and_codegen_targets(static_kernel.to_kernel_def(), "a5", "") | 186 | + cube, vector = _parse_and_codegen_targets(static_kernel.to_kernel_def(), NpuArch.DAV_3510, "") |
| 186 | from pypto_pro.runtime.compile_config import get_jit_compile_config | 187 | from pypto_pro.runtime.compile_config import get_jit_compile_config |
| 187 | 188 | ||
| 188 | - target = get_jit_compile_config().resolve_kernel_target("a5", has_cube=cube is not None, | 189 | + target = get_jit_compile_config().resolve_kernel_target(NpuArch.DAV_3510, has_cube=cube is not None, |
| 189 | has_vector=vector is not None) | 190 | has_vector=vector is not None) |
| 190 | cg = cube or vector | 191 | cg = cube or vector |
| 191 | content = _generate_caller_cpp( | 192 | content = _generate_caller_cpp( |
| @@ -220,10 +221,10 @@ def test_metadata_checks_collection_and_capture_independently(): | |||
| 220 | pl.add(tc, ta, ta) | 221 | pl.add(tc, ta, ta) |
| 221 | pl.store(out, tc, [0, 0]) | 222 | pl.store(out, tc, [0, 0]) |
| 222 | 223 | ||
| 223 | - cube, vector = _parse_and_codegen_targets(bare_kernel.to_kernel_def(), "a5", "") | 224 | + cube, vector = _parse_and_codegen_targets(bare_kernel.to_kernel_def(), NpuArch.DAV_3510, "") |
| 224 | from pypto_pro.runtime.compile_config import get_jit_compile_config | 225 | from pypto_pro.runtime.compile_config import get_jit_compile_config |
| 225 | 226 | ||
| 226 | - target = get_jit_compile_config().resolve_kernel_target("a5", has_cube=cube is not None, | 227 | + target = get_jit_compile_config().resolve_kernel_target(NpuArch.DAV_3510, has_cube=cube is not None, |
| 227 | has_vector=vector is not None) | 228 | has_vector=vector is not None) |
| 228 | cg = cube or vector | 229 | cg = cube or vector |
| 229 | content = _generate_caller_cpp( | 230 | content = _generate_caller_cpp( |
| @@ -251,7 +252,7 @@ def test_metadata_checks_collection_and_capture_independently(): | |||
| 251 | 252 | ||
| 252 | def test_native_metadata_gate(tmp_path): | 253 | def test_native_metadata_gate(tmp_path): |
| 253 | """Execute the emitted control flow with recording APIs; an ordinary launch must not report.""" | 254 | """Execute the emitted control flow with recording APIs; an ordinary launch must not report.""" |
| 254 | - target = get_jit_compile_config().resolve_kernel_target("a5", has_cube=False, has_vector=True) | 255 | + target = get_jit_compile_config().resolve_kernel_target(NpuArch.DAV_3510, has_cube=False, has_vector=True) |
| 255 | _inc, push, pop = _generate_prof_range_snippet( | 256 | _inc, push, pop = _generate_prof_range_snippet( |
| 256 | "k", [_spec("a", [64], "fp32", pl.Input)], set(), target=target, launch_stmt=" ++launches;\n" | 257 | "k", [_spec("a", [64], "fp32", pl.Input)], set(), target=target, launch_stmt=" ++launches;\n" |
| 257 | ) | 258 | ) |
| @@ -14,6 +14,7 @@ import shutil | |||
| 14 | import struct | 14 | import struct |
| 15 | import subprocess | 15 | import subprocess |
| 16 | 16 | ||
| 17 | +from pypto_pro.runtime.platform import NpuArch | ||
| 17 | import pytest | 18 | import pytest |
| 18 | 19 | ||
| 19 | jit = importlib.import_module("pypto_pro.runtime.jit") | 20 | jit = importlib.import_module("pypto_pro.runtime.jit") |
| @@ -75,7 +76,7 @@ static void probe_impl({signature}) | |||
| 75 | out[12] = *ffts_addr; | 76 | out[12] = *ffts_addr; |
| 76 | }} | 77 | }} |
| 77 | """) | 78 | """) |
| 78 | - target = jit.get_jit_compile_config().resolve_kernel_target("a5", has_cube=False, has_vector=True) | 79 | + target = jit.get_jit_compile_config().resolve_kernel_target(NpuArch.DAV_3510, has_cube=False, has_vector=True) |
| 79 | entry = jit._make_global_entry("probe", entry_params, target=target) | 80 | entry = jit._make_global_entry("probe", entry_params, target=target) |
| 80 | entry += """template<class... Args> void CheckLaunchSlots(Args... args) | 81 | entry += """template<class... Args> void CheckLaunchSlots(Args... args) |
| 81 | { | 82 | { |
| @@ -13,6 +13,7 @@ from types import SimpleNamespace | |||
| 13 | 13 | ||
| 14 | from pypto_pro._errors import OutOfRange | 14 | from pypto_pro._errors import OutOfRange |
| 15 | import pypto_pro.language as pl | 15 | import pypto_pro.language as pl |
| 16 | +from pypto_pro.runtime.platform import NpuArch | ||
| 16 | import pytest | 17 | import pytest |
| 17 | 18 | ||
| 18 | from pypto.pypto_impl import ir | 19 | from pypto.pypto_impl import ir |
| @@ -115,7 +116,7 @@ def test_cube_and_vector_facts_are_aggregated_for_one_kernel(monkeypatch): | |||
| 115 | 116 | ||
| 116 | monkeypatch.setattr(jit, "_codegen_target_cce", fake_codegen) | 117 | monkeypatch.setattr(jit, "_codegen_target_cce", fake_codegen) |
| 117 | 118 | ||
| 118 | - jit._parse_and_codegen_targets(FakeKernelDef(), "a5", "unused") | 119 | + jit._parse_and_codegen_targets(FakeKernelDef(), NpuArch.DAV_3510, "unused") |
| 119 | 120 | ||
| 120 | assert recorded_dynamic_ub == { | 121 | assert recorded_dynamic_ub == { |
| 121 | ir.SectionKind.Cube: 208 * 1024, | 122 | ir.SectionKind.Cube: 208 * 1024, |
| @@ -25,6 +25,7 @@ from pypto_pro.runtime.opc.pypto_compile import ( | |||
| 25 | prepare_binary_headers, | 25 | prepare_binary_headers, |
| 26 | pypto_compile_op, | 26 | pypto_compile_op, |
| 27 | ) | 27 | ) |
| 28 | +from pypto_pro.runtime.platform import NpuArch | ||
| 28 | from pypto_pro.runtime.tilingkey import TilingKeyField | 29 | from pypto_pro.runtime.tilingkey import TilingKeyField |
| 29 | import pytest | 30 | import pytest |
| 30 | 31 | ||
| @@ -75,8 +76,8 @@ def test_generate_binary_headers_emits_only_tiling_headers(monkeypatch, tmp_path | |||
| 75 | "_codegen", | 76 | "_codegen", |
| 76 | lambda *args, **kwargs: pytest.fail("generate_binary_headers must not run full codegen"), | 77 | lambda *args, **kwargs: pytest.fail("generate_binary_headers must not run full codegen"), |
| 77 | ) | 78 | ) |
| 78 | - binary_dir = Path(generate_binary_headers(header_generation_kernel, "a5")) | 79 | + binary_dir = Path(generate_binary_headers(header_generation_kernel, "3510")) |
| 79 | - assert os.environ["PYPTOPRO_JIT_ARCH"] == "a5" | 80 | + assert os.environ["PYPTOPRO_JIT_ARCH"] == "3510" |
| 80 | assert binary_dir.is_dir(), f"binary dir not created: {binary_dir}" | 81 | assert binary_dir.is_dir(), f"binary dir not created: {binary_dir}" |
| 81 | 82 | ||
| 82 | tiling_header = binary_dir / "HeaderTiling_tiling.h" | 83 | tiling_header = binary_dir / "HeaderTiling_tiling.h" |
| @@ -103,7 +104,7 @@ def test_prepare_binary_headers_loads_the_kernel_file(monkeypatch, tmp_path): | |||
| 103 | 104 | ||
| 104 | binary_dir = Path(prepare_binary_headers(__file__)) | 105 | binary_dir = Path(prepare_binary_headers(__file__)) |
| 105 | 106 | ||
| 106 | - assert os.environ["PYPTOPRO_JIT_ARCH"] == "a5" | 107 | + assert os.environ["PYPTOPRO_JIT_ARCH"] == "3510" |
| 107 | assert (binary_dir / "HeaderTiling_tiling.h").is_file() | 108 | assert (binary_dir / "HeaderTiling_tiling.h").is_file() |
| 108 | assert (binary_dir / "HeaderTilingKey_tilingkey.h").is_file() | 109 | assert (binary_dir / "HeaderTilingKey_tilingkey.h").is_file() |
| 109 | assert not list(binary_dir.glob("*_pypto_infer.cpp")) | 110 | assert not list(binary_dir.glob("*_pypto_infer.cpp")) |
| @@ -122,9 +123,9 @@ def test_pypto_compile_op_sets_up_explicit_arch(monkeypatch): | |||
| 122 | monkeypatch.setattr(compile_module, "_setup_options", stop_after_arch_setup) | 123 | monkeypatch.setattr(compile_module, "_setup_options", stop_after_arch_setup) |
| 123 | 124 | ||
| 124 | with pytest.raises(RuntimeError, match="stop after arch setup"): | 125 | with pytest.raises(RuntimeError, match="stop after arch setup"): |
| 125 | - pypto_compile_op("unused.py", "kernel", {"kernel_name": "kernel"}, arch="a5") | 126 | + pypto_compile_op("unused.py", "kernel", {"kernel_name": "kernel"}, arch="3510") |
| 126 | 127 | ||
| 127 | - assert received_arch == ["a5"] | 128 | + assert received_arch == [NpuArch.DAV_3510] |
| 128 | 129 | ||
| 129 | 130 | ||
| 130 | @pytest.mark.parametrize("kernel_count", [0, 2]) | 131 | @pytest.mark.parametrize("kernel_count", [0, 2]) |
| @@ -0,0 +1,122 @@ | |||
| 1 | +#!/usr/bin/env python3 | ||
| 2 | +# coding: utf-8 | ||
| 3 | +# Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 4 | +# This program is free software and can be redistributed and modified under the terms and conditions of | ||
| 5 | +# CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 6 | +# You may not use this file except in compliance with the License. | ||
| 7 | +# You may obtain a copy of the License at | ||
| 8 | +# | ||
| 9 | +# http://www.huawei.com/ | ||
| 10 | +# | ||
| 11 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR | ||
| 12 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A | ||
| 13 | +# PARTICULAR PURPOSE. | ||
| 14 | +# See the License for the specific language governing permissions and limitations under the License. | ||
| 15 | +# ----------------------------------------------------------------------------------------------------------- | ||
| 16 | +"""Arch identity and legacy-alias compatibility tests.""" | ||
| 17 | + | ||
| 18 | +import os | ||
| 19 | +import warnings | ||
| 20 | + | ||
| 21 | +from pypto_pro._errors import InvalidVal, NotSupported | ||
| 22 | +from pypto_pro.runtime.platform import NpuArch, normalize_arch | ||
| 23 | +import pytest | ||
| 24 | + | ||
| 25 | + | ||
| 26 | +def test_parse_arch_canonical_forms(): | ||
| 27 | + assert normalize_arch("3510") == NpuArch.DAV_3510 | ||
| 28 | + assert normalize_arch(" 3510 ") == NpuArch.DAV_3510 | ||
| 29 | + | ||
| 30 | + | ||
| 31 | +def test_parse_arch_accepts_enum_values(): | ||
| 32 | + assert normalize_arch(NpuArch.DAV_3510) == NpuArch.DAV_3510 | ||
| 33 | + assert normalize_arch(NpuArch.DAV_2201) == NpuArch.DAV_2201 | ||
| 34 | + | ||
| 35 | + | ||
| 36 | +def test_parse_arch_collapses_unregistered_enum_values_to_unknown(): | ||
| 37 | + assert normalize_arch(NpuArch(9999)) == NpuArch.DAV_UNKNOWN | ||
| 38 | + assert normalize_arch(NpuArch.DAV_UNKNOWN) == NpuArch.DAV_UNKNOWN | ||
| 39 | + assert normalize_arch(NpuArch(3510)) == NpuArch.DAV_3510 | ||
| 40 | + | ||
| 41 | + | ||
| 42 | +def test_npuarch_str_is_canonical_form(): | ||
| 43 | + assert str(NpuArch.DAV_3510) == "3510" | ||
| 44 | + assert f"{NpuArch.DAV_3510}" == "3510" | ||
| 45 | + | ||
| 46 | + | ||
| 47 | +def test_parse_arch_legacy_a5_maps_to_3510_with_deprecation(): | ||
| 48 | + with pytest.warns(DeprecationWarning, match="'a5' is deprecated"): | ||
| 49 | + assert normalize_arch("a5") == NpuArch.DAV_3510 | ||
| 50 | + | ||
| 51 | + | ||
| 52 | +def test_parse_arch_legacy_a2_a3_map_to_2201_without_warning(): | ||
| 53 | + with warnings.catch_warnings(): | ||
| 54 | + warnings.simplefilter("error") | ||
| 55 | + assert normalize_arch("a2") == NpuArch.DAV_2201 | ||
| 56 | + assert normalize_arch("a3") == NpuArch.DAV_2201 | ||
| 57 | + | ||
| 58 | + | ||
| 59 | +def test_parse_arch_unknown_raises(): | ||
| 60 | + for bad in ("future", "a6", ""): | ||
| 61 | + with pytest.raises(InvalidVal): | ||
| 62 | + normalize_arch(bad) | ||
| 63 | + | ||
| 64 | + | ||
| 65 | +def test_setup_arch_env_accepts_deprecated_a5(monkeypatch): | ||
| 66 | + from pypto_pro.runtime.jit import _setup_arch_env | ||
| 67 | + | ||
| 68 | + monkeypatch.delenv("PYPTOPRO_JIT_ARCH", raising=False) | ||
| 69 | + with pytest.warns(DeprecationWarning): | ||
| 70 | + parsed = normalize_arch("a5") | ||
| 71 | + assert _setup_arch_env(parsed) == NpuArch.DAV_3510 | ||
| 72 | + assert os.environ["PYPTOPRO_JIT_ARCH"] == "3510" | ||
| 73 | + | ||
| 74 | + | ||
| 75 | +def test_setup_arch_env_canonicalises_env_value(monkeypatch): | ||
| 76 | + from pypto_pro.runtime.jit import _setup_arch_env, get_current_arch | ||
| 77 | + | ||
| 78 | + monkeypatch.delenv("PYPTOPRO_JIT_ARCH", raising=False) | ||
| 79 | + assert _setup_arch_env(NpuArch.DAV_3510) == NpuArch.DAV_3510 | ||
| 80 | + assert get_current_arch() == NpuArch.DAV_3510 | ||
| 81 | + | ||
| 82 | + | ||
| 83 | +def test_setup_arch_env_rejects_non_3510(): | ||
| 84 | + from pypto_pro.runtime.jit import _setup_arch_env | ||
| 85 | + | ||
| 86 | + with pytest.raises(NotSupported, match="only supports arch '3510'"): | ||
| 87 | + _setup_arch_env(NpuArch.DAV_2201) | ||
| 88 | + | ||
| 89 | + | ||
| 90 | +def test_get_current_arch_env_a5_warns_and_canonicalises(monkeypatch): | ||
| 91 | + from pypto_pro.runtime.jit import get_current_arch | ||
| 92 | + | ||
| 93 | + monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "a5") | ||
| 94 | + with pytest.warns(DeprecationWarning): | ||
| 95 | + assert get_current_arch() == NpuArch.DAV_3510 | ||
| 96 | + | ||
| 97 | + | ||
| 98 | +def test_jit_decorator_warns_on_deprecated_a5(): | ||
| 99 | + import pypto_pro.language as pl | ||
| 100 | + | ||
| 101 | + with pytest.warns(DeprecationWarning): | ||
| 102 | + | ||
| 103 | + @pl.jit(arch="a5") | ||
| 104 | + def kernel(x): | ||
| 105 | + return x | ||
| 106 | + | ||
| 107 | + | ||
| 108 | +def test_resolve_kernel_target_treats_a5_as_3510(): | ||
| 109 | + from pypto_pro.runtime.compile_config import get_jit_compile_config | ||
| 110 | + | ||
| 111 | + cfg = get_jit_compile_config() | ||
| 112 | + with pytest.warns(DeprecationWarning): | ||
| 113 | + legacy = normalize_arch("a5") | ||
| 114 | + canonical_target = cfg.resolve_kernel_target(NpuArch.DAV_3510, has_cube=True, has_vector=True) | ||
| 115 | + assert cfg.resolve_kernel_target(legacy, has_cube=True, has_vector=True) == canonical_target | ||
| 116 | + | ||
| 117 | + | ||
| 118 | +def test_platform_arch_is_enum(): | ||
| 119 | + from pypto_pro.runtime.platform import get_platform_info | ||
| 120 | + | ||
| 121 | + arch = get_platform_info().arch | ||
| 122 | + assert arch is None or isinstance(arch, NpuArch) | ||
| @@ -43,14 +43,14 @@ def _static_signature_suffix(signature): | |||
| 43 | return _private(jit_runtime, "_static_signature_suffix")(signature) | 43 | return _private(jit_runtime, "_static_signature_suffix")(signature) |
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | -@pl.jit(arch="a5") | 46 | +@pl.jit(arch="3510") |
| 47 | def static_dynamic_kernel( | 47 | def static_dynamic_kernel( |
| 48 | x: pl.Tensor[[pl.STATIC, pl.DYNAMIC], pl.DT_FP16], | 48 | x: pl.Tensor[[pl.STATIC, pl.DYNAMIC], pl.DT_FP16], |
| 49 | ): | 49 | ): |
| 50 | return | 50 | return |
| 51 | 51 | ||
| 52 | 52 | ||
| 53 | -@pl.jit(arch="a5") | 53 | +@pl.jit(arch="3510") |
| 54 | def dynamic_dynamic_kernel( | 54 | def dynamic_dynamic_kernel( |
| 55 | x: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16], | 55 | x: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16], |
| 56 | ): | 56 | ): |
| @@ -30,21 +30,21 @@ def _static_signature_suffix(signature): | |||
| 30 | return _private(jit_runtime, "_static_signature_suffix")(signature) | 30 | return _private(jit_runtime, "_static_signature_suffix")(signature) |
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | -@pl.jit(arch="a5") | 33 | +@pl.jit(arch="3510") |
| 34 | def mixed_policy_kernel( | 34 | def mixed_policy_kernel( |
| 35 | x: pl.Tensor[[pl.DYNAMIC, pl.STATIC, 4], pl.DT_FP32], | 35 | x: pl.Tensor[[pl.DYNAMIC, pl.STATIC, 4], pl.DT_FP32], |
| 36 | ): | 36 | ): |
| 37 | return | 37 | return |
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | -@pl.jit(arch="a5") | 40 | +@pl.jit(arch="3510") |
| 41 | def ellipsis_policy_kernel( | 41 | def ellipsis_policy_kernel( |
| 42 | x: pl.Tensor[[pl.DYNAMIC, ...], pl.DT_FP32], | 42 | x: pl.Tensor[[pl.DYNAMIC, ...], pl.DT_FP32], |
| 43 | ): | 43 | ): |
| 44 | return | 44 | return |
| 45 | 45 | ||
| 46 | 46 | ||
| 47 | -@pl.jit(arch="a5") | 47 | +@pl.jit(arch="3510") |
| 48 | def call_style_policy_kernel( | 48 | def call_style_policy_kernel( |
| 49 | x: pl.Tensor([pl.DYNAMIC, pl.STATIC, 4], pl.DT_FP32), | 49 | x: pl.Tensor([pl.DYNAMIC, pl.STATIC, 4], pl.DT_FP32), |
| 50 | ): | 50 | ): |
| @@ -37,7 +37,7 @@ def _compiled_cache(kernel): | |||
| 37 | return getattr(kernel, "_compiled_by_signature") | 37 | return getattr(kernel, "_compiled_by_signature") |
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | -@pl.jit(arch="a5", auto_mutex=True, tiling_key=TkPermutation) | 40 | +@pl.jit(arch="3510", auto_mutex=True, tiling_key=TkPermutation) |
| 41 | def kernel_permutation( | 41 | def kernel_permutation( |
| 42 | x: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16], | 42 | x: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16], |
| 43 | y: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16], | 43 | y: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16], |
| @@ -31,7 +31,7 @@ class TkBits16: | |||
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | def _make_kernel(tiling_key_cls): | 33 | def _make_kernel(tiling_key_cls): |
| 34 | - @pl.jit(arch="a5", auto_mutex=True, tiling_key=tiling_key_cls) | 34 | + @pl.jit(arch="3510", auto_mutex=True, tiling_key=tiling_key_cls) |
| 35 | def _kernel( | 35 | def _kernel( |
| 36 | x: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16], | 36 | x: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16], |
| 37 | y: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16], | 37 | y: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16], |
| @@ -36,6 +36,7 @@ from pypto_pro._errors import ( | |||
| 36 | ) | 36 | ) |
| 37 | import pypto_pro.language as pl | 37 | import pypto_pro.language as pl |
| 38 | from pypto_pro.language import Vf as vf # noqa: N813 | 38 | from pypto_pro.language import Vf as vf # noqa: N813 |
| 39 | +from pypto_pro.runtime.platform import NpuArch | ||
| 39 | import pytest | 40 | import pytest |
| 40 | 41 | ||
| 41 | from pypto.pypto_impl import ir | 42 | from pypto.pypto_impl import ir |
| @@ -246,7 +247,7 @@ def test_a_codegen_check_renders_its_location_block_like_a_parse_one(): | |||
| 246 | pl.store(out, t_u0, [0, 0]) | 247 | pl.store(out, t_u0, [0, 0]) |
| 247 | 248 | ||
| 248 | with pytest.raises(PyptoProError) as excinfo: | 249 | with pytest.raises(PyptoProError) as excinfo: |
| 249 | - _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "") | 250 | + _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "") |
| 250 | rendered = Rendered(excinfo.value) | 251 | rendered = Rendered(excinfo.value) |
| 251 | 252 | ||
| 252 | # The C++ first line is passed through whole: its own file, module and code. | 253 | # The C++ first line is passed through whole: its own file, module and code. |