Merged
feat(pypto_pro): replace internal 'a5' with NPUArch enum #6705
LiwenerAdd on Sep 24
feat(pypto_pro): replace internal 'a5' with NPUArch enum #6705
Merged
LiwenerAdd on Sep 24
Total: 78 files changed+672-450
@@ -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```text36```text
37-===== kernel 'oob_kernel' (./build/oob_kernel__a5__d0/tk_none) =====37+===== kernel 'oob_kernel' (./build/oob_kernel__3510__d0/tk_none) =====
38PyPTO Sanitizer: 1 issue(s) detected38PyPTO 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:6839[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 dimension40 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```text80```text
81-===== kernel 'oob_kernel' (./build/oob_kernel__a5__d0/tk_none) =====81+===== kernel 'oob_kernel' (./build/oob_kernel__3510__d0/tk_none) =====
82PyPTO Sanitizer: 1 issue(s) detected82PyPTO 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:6883[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 dimension84 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```text106```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) =====
108PyPTO Sanitizer: 1 issue(s) detected108PyPTO Sanitizer: 1 issue(s) detected
109[1/1] GM_OUT_OF_BOUNDS: scalar access at linear offset 64 exceeds 64 elements at demo.py:17109[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 count110 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```text128```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) =====
130PyPTO Sanitizer: 1 issue(s) detected130PyPTO 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:1255131[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 source132 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```text156```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) =====
158PyPTO Sanitizer: 1 issue(s) detected158PyPTO 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:227159[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 dims160 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```text178```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) =====
180PyPTO Sanitizer: 1 issue(s) detected180PyPTO 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:64181[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 dims182 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```text203```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) =====
205PyPTO Sanitizer: 3 issue(s) detected205PyPTO 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:46206[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 dimension207 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```text230```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) =====
232PyPTO Sanitizer: 1 issue(s) detected232PyPTO 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:31233[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 count234 Hint: getval/setval offsets must stay inside the tile element count
@@ -252,7 +252,7 @@ tb = tb_group.current()
252```252```
253 253 
254```text254```text
255-===== kernel 'overlap_kernel' (./build/overlap_kernel__a5__d0/tk_none) =====255+===== kernel 'overlap_kernel' (./build/overlap_kernel__3510__d0/tk_none) =====
256PyPTO Sanitizer: 1 issue(s) detected256PyPTO Sanitizer: 1 issue(s) detected
257[1/1] TILE_OVERLAP: tile range [Vec 0x0, 0x2000) overlaps another tile [Vec 0x1000, 0x3000) at demo.py:124257[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 space258 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```text278```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) =====
280PyPTO Sanitizer: 1 issue(s) detected280PyPTO 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:705281[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```python47```python
48import pypto_pro.language as pl48import pypto_pro.language as pl
49 49 
50-@pl.jit(arch="a5")50+@pl.jit(arch="3510")
51def transform_kernel(51def 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启动外层Kernel64### 从Host启动外层Kernel
65 65 
66-在A5环境中,通过Host启动外层jit kernel函数:66+通过Host启动外层jit kernel函数:
67 67 
68```python68```python
69import torch69import 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")
205def gather_kernel(205def 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")
94def copy_kernel(94def 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 ```python81 ```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 
39namespace pypto {40namespace pypto {
40 41 
@@ -129,7 +130,7 @@ public:
129 * \param program The IR Program to generate code for130 * \param program The IR Program to generate code for
130 * \return Generated C++ code as a single string131 * \return Generated C++ code as a single string
131 */132 */
132- [[nodiscard]] std::string GenerateSingle(const ir::ProgramPtr& program, const std::string& arch);133+ [[nodiscard]] std::string GenerateSingle(const ir::ProgramPtr& program, npu::tile_fwk::NPUArch arch);
133 134 
134 /**135 /**
135 * \brief Tiling struct headers generated by the last GenerateSingle call.136 * \brief Tiling struct headers generated by the last GenerateSingle call.
@@ -170,7 +171,7 @@ public:
170 const TypeConverter& GetTypeConverter() const { return type_converter_; }171 const TypeConverter& GetTypeConverter() const { return type_converter_; }
171 172 
172 /** \brief Get the target architecture */173 /** \brief Get the target architecture */
173- const std::string& GetArch() const { return arch_; }174+ npu::tile_fwk::NPUArch GetArch() const { return arch_; }
174 175 
175 /** \brief Get the fixed Cube/Vector target selected for this generation. */176 /** \brief Get the fixed Cube/Vector target selected for this generation. */
176 ir::SectionKind GetTarget() const { return target_; }177 ir::SectionKind GetTarget() const { return target_; }
@@ -595,13 +596,13 @@ private:
595 std::map<std::string, std::string> tiling_headers_; ///< Tiling struct headers (filename -> content)596 std::map<std::string, std::string> tiling_headers_; ///< Tiling struct headers (filename -> content)
596 std::map<std::string, StructDefinition> struct_definitions_; ///< Struct type name ->definition597 std::map<std::string, StructDefinition> struct_definitions_; ///< Struct type name ->definition
597 598 
598- CodeEmitter emitter_; ///< Code emitter for structured output599+ CodeEmitter emitter_; ///< Code emitter for structured output
599- CodeContext context_; ///< Context for variable tracking600+ CodeContext context_; ///< Context for variable tracking
600- TypeConverter type_converter_; ///< Type converter601+ TypeConverter type_converter_; ///< Type converter
601- const backend::Backend* backend_; ///< CCE backend instance (for op info, core type)602+ const backend::Backend* backend_; ///< CCE backend instance (for op info, core type)
602- std::string arch_ = "a3"; ///< Target architecture ("a2", "a3", "a5")603+ npu::tile_fwk::NPUArch arch_ = npu::tile_fwk::NPUArch::DAV_2201; ///< Target architecture
603- const ir::SectionKind target_; ///< Fixed Cube/Vector target for this generator604+ const ir::SectionKind target_; ///< Fixed Cube/Vector target for this generator
604- bool in_vf_section_ = false; ///< True only while emitting a nested VF section605+ bool in_vf_section_ = false; ///< True only while emitting a nested VF section
605 ir::FunctionType current_function_type_ = ir::FunctionType::OPAQUE;606 ir::FunctionType current_function_type_ = ir::FunctionType::OPAQUE;
606 std::map<std::string, ir::FunctionPtr> simt_callees_;607 std::map<std::string, ir::FunctionPtr> simt_callees_;
607 std::unordered_map<std::string, std::string> tensor_to_pointer_; ///< Tensor var name ->raw pointer expression608 std::unordered_map<std::string, std::string> tensor_to_pointer_; ///< Tensor var name ->raw pointer expression
@@ -656,5 +656,5 @@ inline constexpr char kMemorySpaceAcc[] = "Acc";
656// Buffer capacity (bytes) of ``space`` for ``arch``, read from the platform656// Buffer capacity (bytes) of ``space`` for ``arch``, read from the platform
657// ini shipped with the package. Returns 0 when the arch or space key is not657// ini shipped with the package. Returns 0 when the arch or space key is not
658// recognized / the ini cannot be found or parsed.658// recognized / the ini cannot be found or parsed.
659-size_t GetMemoryLimitForArch(const std::string& arch, const std::string& space);659+size_t GetMemoryLimitForArch(NPUArch arch, const std::string& space);
660} // namespace npu::tile_fwk660} // namespace npu::tile_fwk
@@ -1394,7 +1394,7 @@ static std::string MakeCrossCoreSetCodegenCCE(const ir::CallPtr& op, codegen::Co
1394 auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base);1394 auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base);
1395 auto pipe = op->GetKwarg<int>("pipe");1395 auto pipe = op->GetKwarg<int>("pipe");
1396 std::string pipe_str = PipeTypeToCCEString(static_cast<ir::PipeType>(pipe));1396 std::string pipe_str = PipeTypeToCCEString(static_cast<ir::PipeType>(pipe));
1397- bool is_a5 = (codegen.GetArch() == "a5");1397+ bool is_a5 = (codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510);
1398 auto sync_mode = static_cast<ir::CrossCoreSyncMode>(op->GetKwarg<int>("sync_mode"));1398 auto sync_mode = static_cast<ir::CrossCoreSyncMode>(op->GetKwarg<int>("sync_mode"));
1399 bool is_intra_unicast = sync_mode == ir::CrossCoreSyncMode::INTRA_BLOCK ||1399 bool is_intra_unicast = sync_mode == ir::CrossCoreSyncMode::INTRA_BLOCK ||
1400 sync_mode == ir::CrossCoreSyncMode::UNICAST_BLOCK;1400 sync_mode == ir::CrossCoreSyncMode::UNICAST_BLOCK;
@@ -1462,7 +1462,7 @@ static std::string MakeCrossCoreWaitCodegenCCE(const ir::CallPtr& op, codegen::C
1462 bool is_intra_unicast = (sync_mode == ir::CrossCoreSyncMode::INTRA_BLOCK ||1462 bool is_intra_unicast = (sync_mode == ir::CrossCoreSyncMode::INTRA_BLOCK ||
1463 sync_mode == ir::CrossCoreSyncMode::UNICAST_BLOCK);1463 sync_mode == ir::CrossCoreSyncMode::UNICAST_BLOCK);
1464 bool wait_two_vec_subcores = (sync_mode == ir::CrossCoreSyncMode::INTRA_BLOCK);1464 bool wait_two_vec_subcores = (sync_mode == ir::CrossCoreSyncMode::INTRA_BLOCK);
1465- bool is_a5 = (codegen.GetArch() == "a5");1465+ bool is_a5 = (codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510);
1466 if (is_a5 && is_intra_unicast) {1466 if (is_a5 && is_intra_unicast) {
1467 // A5 + INTRA_BLOCK(2) or UNICAST_BLOCK(3): wait_intra_block1467 // A5 + INTRA_BLOCK(2) or UNICAST_BLOCK(3): wait_intra_block
1468 // CUBE waiting for VEC: INTRA_BLOCK expands to two calls (v0: id, v1: id+16); UNICAST_BLOCK single call1468 // CUBE waiting for VEC: INTRA_BLOCK expands to two calls (v0: id, v1: id+16); UNICAST_BLOCK single call
@@ -2155,7 +2155,7 @@ REGISTER_BACKEND_OP(BackendCCE, "system.set_mm_layout_transform")
2155 .f_codegen([](const ir::CallPtr& op, codegen::CodegenBase& codegen_base) {2155 .f_codegen([](const ir::CallPtr& op, codegen::CodegenBase& codegen_base) {
2156 auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base);2156 auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base);
2157 auto enabled = op->GetKwarg<int>("enabled");2157 auto enabled = op->GetKwarg<int>("enabled");
2158- if (codegen.GetArch() == "a5") {2158+ if (codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510) {
2159 // Direct register manipulation: MM_LAYOUT_MODE_BIT = 512159 // Direct register manipulation: MM_LAYOUT_MODE_BIT = 51
2160 if (enabled) {2160 if (enabled) {
2161 codegen.Emit("set_ctrl(sbitset1(get_ctrl(), 51));");2161 codegen.Emit("set_ctrl(sbitset1(get_ctrl(), 51));");
@@ -128,8 +128,8 @@ std::string MakeSimtWarpCodegenCCE(const ir::CallPtr& op, codegen::CodegenBase&
128 auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base);128 auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base);
129 PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext())129 PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext())
130 << op->name_ << " reached CCE codegen outside a SIMT function";130 << op->name_ << " reached CCE codegen outside a SIMT function";
131- PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == "a5")131+ PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510)
132- << op->name_ << " currently requires arch='a5'";132+ << op->name_ << " currently requires arch='3510'";
133 PRO_CODEGEN_CHECK(ExternalError::INVALID_ARGUMENT, op->args_.size() == operand_count)133 PRO_CODEGEN_CHECK(ExternalError::INVALID_ARGUMENT, op->args_.size() == operand_count)
134 << op->name_ << " requires exactly " << operand_count << " operand(s)";134 << op->name_ << " requires exactly " << operand_count << " operand(s)";
135 135 
@@ -332,8 +332,8 @@ std::string MakeSimtCastCodegenCCE(const ir::CallPtr& op, codegen::CodegenBase&
332 auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base);332 auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base);
333 PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext())333 PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext())
334 << "simt.cast reached CCE codegen outside a SIMT function";334 << "simt.cast reached CCE codegen outside a SIMT function";
335- PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == "a5")335+ PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510)
336- << "simt.cast currently requires arch='a5'";336+ << "simt.cast currently requires arch='3510'";
337 PRO_CODEGEN_CHECK(ExternalError::INVALID_ARGUMENT, op->args_.size() == 1)337 PRO_CODEGEN_CHECK(ExternalError::INVALID_ARGUMENT, op->args_.size() == 1)
338 << "simt.cast requires one scalar argument";338 << "simt.cast requires one scalar argument";
339 339 
@@ -373,8 +373,8 @@ std::string MakeSimtBitcastCodegenCCE(const ir::CallPtr& op, codegen::CodegenBas
373 auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base);373 auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base);
374 PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext())374 PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext())
375 << "simt.bitcast reached CCE codegen outside a SIMT function";375 << "simt.bitcast reached CCE codegen outside a SIMT function";
376- PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == "a5")376+ PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510)
377- << "simt.bitcast currently requires arch='a5'";377+ << "simt.bitcast currently requires arch='3510'";
378 PRO_CODEGEN_CHECK(ExternalError::INVALID_ARGUMENT, op->args_.size() == 1)378 PRO_CODEGEN_CHECK(ExternalError::INVALID_ARGUMENT, op->args_.size() == 1)
379 << "simt.bitcast requires one scalar argument";379 << "simt.bitcast requires one scalar argument";
380 380 
@@ -470,8 +470,8 @@ SimtUnaryCodegenInput GetSimtUnaryCodegenInput(const ir::CallPtr& op, codegen::C
470 auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base);470 auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base);
471 PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext())471 PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext())
472 << op->name_ << " reached CCE codegen outside a SIMT function";472 << op->name_ << " reached CCE codegen outside a SIMT function";
473- PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == "a5")473+ PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510)
474- << op->name_ << " currently requires arch='a5'";474+ << op->name_ << " currently requires arch='3510'";
475 auto scalar_type = ir::As<ir::ScalarType>(op->args_[0]->GetType());475 auto scalar_type = ir::As<ir::ScalarType>(op->args_[0]->GetType());
476 PRO_CODEGEN_CHECK(ExternalError::INVALID_TYPE, scalar_type != nullptr) << op->name_ << " operand must be a scalar";476 PRO_CODEGEN_CHECK(ExternalError::INVALID_TYPE, scalar_type != nullptr) << op->name_ << " operand must be a scalar";
477 return {scalar_type->dtype_, codegen.GetExprAsCode(op->args_[0])};477 return {scalar_type->dtype_, codegen.GetExprAsCode(op->args_[0])};
@@ -844,8 +844,8 @@ std::string MakeSimtMinCodegenCCE(const ir::CallPtr& op, codegen::CodegenBase& c
844 auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base);844 auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base);
845 PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext())845 PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext())
846 << "simt.min reached CCE codegen outside a SIMT function";846 << "simt.min reached CCE codegen outside a SIMT function";
847- PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == "a5")847+ PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510)
848- << "simt.min currently requires arch='a5'";848+ << "simt.min currently requires arch='3510'";
849 auto scalar_type = ir::As<ir::ScalarType>(op->args_[0]->GetType());849 auto scalar_type = ir::As<ir::ScalarType>(op->args_[0]->GetType());
850 PRO_CODEGEN_CHECK(ExternalError::INVALID_TYPE, scalar_type != nullptr) << "simt.min operand must be a scalar";850 PRO_CODEGEN_CHECK(ExternalError::INVALID_TYPE, scalar_type != nullptr) << "simt.min operand must be a scalar";
851 const auto& dtype = scalar_type->dtype_;851 const auto& dtype = scalar_type->dtype_;
@@ -873,8 +873,8 @@ std::string MakeSimtMaxCodegenCCE(const ir::CallPtr& op, codegen::CodegenBase& c
873 auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base);873 auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base);
874 PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext())874 PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext())
875 << "simt.max reached CCE codegen outside a SIMT function";875 << "simt.max reached CCE codegen outside a SIMT function";
876- PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == "a5")876+ PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510)
877- << "simt.max currently requires arch='a5'";877+ << "simt.max currently requires arch='3510'";
878 auto scalar_type = ir::As<ir::ScalarType>(op->args_[0]->GetType());878 auto scalar_type = ir::As<ir::ScalarType>(op->args_[0]->GetType());
879 PRO_CODEGEN_CHECK(ExternalError::INVALID_TYPE, scalar_type != nullptr) << "simt.max operand must be a scalar";879 PRO_CODEGEN_CHECK(ExternalError::INVALID_TYPE, scalar_type != nullptr) << "simt.max operand must be a scalar";
880 const auto& dtype = scalar_type->dtype_;880 const auto& dtype = scalar_type->dtype_;
@@ -902,8 +902,8 @@ std::string MakeSimtFmaCodegenCCE(const ir::CallPtr& op, codegen::CodegenBase& c
902 auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base);902 auto& codegen = dynamic_cast<codegen::CCECodegen&>(codegen_base);
903 PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext())903 PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext())
904 << "simt.fma reached CCE codegen outside a SIMT function";904 << "simt.fma reached CCE codegen outside a SIMT function";
905- PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == "a5")905+ PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510)
906- << "simt.fma currently requires arch='a5'";906+ << "simt.fma currently requires arch='3510'";
907 return "__fma(" + codegen.GetExprAsCode(op->args_[0]) + ", " + codegen.GetExprAsCode(op->args_[1]) + ", " +907 return "__fma(" + codegen.GetExprAsCode(op->args_[0]) + ", " + codegen.GetExprAsCode(op->args_[1]) + ", " +
908 codegen.GetExprAsCode(op->args_[2]) + ")";908 codegen.GetExprAsCode(op->args_[2]) + ")";
909}909}
@@ -958,8 +958,8 @@ std::string MakeSimtAtomicCodegenCCE(const ir::CallPtr& op, codegen::CodegenBase
958 SimtAtomicSpec spec = GetSimtAtomicSpec(op->name_);958 SimtAtomicSpec spec = GetSimtAtomicSpec(op->name_);
959 PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext())959 PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.IsInSimtContext())
960 << op->name_ << " reached CCE codegen outside a SIMT function";960 << op->name_ << " reached CCE codegen outside a SIMT function";
961- PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == "a5")961+ PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510)
962- << op->name_ << " currently requires arch='a5'";962+ << op->name_ << " currently requires arch='3510'";
963 PRO_CODEGEN_CHECK(ExternalError::INVALID_ARGUMENT, op->args_.size() == spec.operand_count + 2)963 PRO_CODEGEN_CHECK(ExternalError::INVALID_ARGUMENT, op->args_.size() == spec.operand_count + 2)
964 << op->name_ << " requires container, offset, and " << spec.operand_count << " scalar operand(s)";964 << op->name_ << " requires container, offset, and " << spec.operand_count << " scalar operand(s)";
965 965 
@@ -1003,8 +1003,8 @@ std::string MakeSimtLaunchCodegenCCE(const ir::CallPtr& op, codegen::CodegenBase
1003 << "Nested simt.launch is not supported";1003 << "Nested simt.launch is not supported";
1004 PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.GetTarget() == ir::SectionKind::Vector)1004 PRO_CODEGEN_CHECK(ExternalError::INVALID_OPERATION, codegen.GetTarget() == ir::SectionKind::Vector)
1005 << "simt.launch requires the Vector target";1005 << "simt.launch requires the Vector target";
1006- PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == "a5")1006+ PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, codegen.GetArch() == npu::tile_fwk::NPUArch::DAV_3510)
1007- << "simt.launch currently requires arch='a5'";1007+ << "simt.launch currently requires arch='3510'";
1008 int64_t thread_dims[3] = {};1008 int64_t thread_dims[3] = {};
1009 for (size_t i = 0; i < 3; ++i) {1009 for (size_t i = 0; i < 3; ++i) {
1010 auto dim = ir::As<ir::ConstInt>(op->args_[i]);1010 auto dim = ir::As<ir::ConstInt>(op->args_[i]);
@@ -626,13 +626,15 @@ std::vector<ir::FunctionPtr> OrderSimtCallees(const std::map<std::string, ir::Fu
626 626 
627} // namespace627} // namespace
628 628 
629-std::string CCECodegen::GenerateSingle(const ir::ProgramPtr& program, const std::string& arch)629+std::string CCECodegen::GenerateSingle(const ir::ProgramPtr& program, npu::tile_fwk::NPUArch arch)
630{630{
631 PRO_CODEGEN_CHECK(npu::tile_fwk::InternalError::CODEGEN_INNER_ERROR, program != nullptr)631 PRO_CODEGEN_CHECK(npu::tile_fwk::InternalError::CODEGEN_INNER_ERROR, program != nullptr)
632 << "Cannot generate code for null program";632 << "Cannot generate code for null program";
633 633 
634 ResetFunctionGenerationState();634 ResetFunctionGenerationState();
635 arch_ = arch;635 arch_ = arch;
636+ PRO_CODEGEN_CHECK(ExternalError::INVALID_VAL, arch_ != npu::tile_fwk::NPUArch::DAV_UNKNOWN)
637+ << "unknown arch '" << npu::tile_fwk::NPUArchToString(arch_) << "'";
636 638 
637 // Parser-produced Programs always carry the tuple metadata table created at639 // Parser-produced Programs always carry the tuple metadata table created at
638 // the top-level parse entry. Codegen relies on absence *within* that table to640 // the top-level parse entry. Codegen relies on absence *within* that table to
@@ -666,8 +668,8 @@ std::string CCECodegen::GenerateSingle(const ir::ProgramPtr& program, const std:
666 if (!simt_funcs.empty() || !simt_callees_.empty()) {668 if (!simt_funcs.empty() || !simt_callees_.empty()) {
667 PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, target_ == ir::SectionKind::Vector)669 PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, target_ == ir::SectionKind::Vector)
668 << "SIMT functions can only be generated for the Vector target";670 << "SIMT functions can only be generated for the Vector target";
669- PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, arch_ == "a5")671+ PRO_CODEGEN_CHECK(ExternalError::NOT_IMPLEMENTED_ERROR, arch_ == npu::tile_fwk::NPUArch::DAV_3510)
670- << "SIMT direct CCE generation currently requires arch='a5'";672+ << "SIMT direct CCE generation currently requires arch='3510'";
671 }673 }
672 674 
673 emitter_.Clear();675 emitter_.Clear();
@@ -676,7 +678,7 @@ std::string CCECodegen::GenerateSingle(const ir::ProgramPtr& program, const std:
676 678 
677 // Detect cross-core sync (a5 uses hardware sync, not ffts)679 // Detect cross-core sync (a5 uses hardware sync, not ffts)
678 bool has_cross_sync = DetectCrossCoreSyncOps(kernel_func->body_);680 bool has_cross_sync = DetectCrossCoreSyncOps(kernel_func->body_);
679- bool needs_ffts = has_cross_sync && (arch_ != "a5");681+ bool needs_ffts = has_cross_sync && (arch_ != npu::tile_fwk::NPUArch::DAV_3510);
680 682 
681 for (const auto& simt_callee : OrderSimtCallees(simt_callees_)) {683 for (const auto& simt_callee : OrderSimtCallees(simt_callees_)) {
682 GenerateSimtFunction(simt_callee);684 GenerateSimtFunction(simt_callee);
@@ -919,7 +921,7 @@ void CCECodegen::EmitSingleFunctionSignature(const ir::FunctionPtr& func, bool h
919 if (has_cross_sync) {921 if (has_cross_sync) {
920 emitter_.EmitLine("set_ffts_base_addr((unsigned long)ffts_addr);");922 emitter_.EmitLine("set_ffts_base_addr((unsigned long)ffts_addr);");
921 }923 }
922- if (target_ == ir::SectionKind::Vector && arch_ == "a3") {924+ if (target_ == ir::SectionKind::Vector && arch_ == npu::tile_fwk::NPUArch::DAV_2201) {
923 emitter_.EmitLine("set_mask_norm();");925 emitter_.EmitLine("set_mask_norm();");
924 emitter_.EmitLine("set_vector_mask(-1, -1);");926 emitter_.EmitLine("set_vector_mask(-1, -1);");
925 }927 }
@@ -2854,7 +2856,7 @@ void CCECodegen::CollectMutexPipeInfo(const ir::StmtPtr& stmt)
2854 2856 
2855bool CCECodegen::ShouldSkipVPipeMutex(ir::PipeType pipe, const std::vector<int>& buf_ids) const2857bool CCECodegen::ShouldSkipVPipeMutex(ir::PipeType pipe, const std::vector<int>& buf_ids) const
2856{2858{
2857- if (pipe != ir::PipeType::V || arch_ != "a5")2859+ if (pipe != ir::PipeType::V || arch_ != npu::tile_fwk::NPUArch::DAV_3510)
2858 return false;2860 return false;
2859 for (int bid : buf_ids) {2861 for (int bid : buf_ids) {
2860 auto it = mutex_pipes_.find(bid);2862 auto it = mutex_pipes_.find(bid);
@@ -371,12 +371,11 @@ void Platform::ReloadMemoryPaths(const std::string& archType)
371 }371 }
372}372}
373 373 
374-size_t GetMemoryLimitForArch(const std::string& arch, const std::string& space)374+size_t GetMemoryLimitForArch(NPUArch arch, const std::string& space)
375{375{
376- // Arch (machine-level legacy name kept as pypto_pro API) -> standard soc_version ini.376+ // Compilation arch -> standard soc_version ini. PyPTO Pro only supports 3510 (Ascend950 series).
377- // PyPTO Pro only supports A5 (NPU_ARCH 3510, Ascend950 series).377+ static const std::unordered_map<NPUArch, std::string> archToIni = {
378- static const std::unordered_map<std::string, std::string> archToIni = {378+ {NPUArch::DAV_3510, "Ascend950PR_9579"},
379- {"a5", "Ascend950PR_9579"},
380 };379 };
381 const auto iniIt = archToIni.find(arch);380 const auto iniIt = archToIni.find(arch);
382 if (iniIt == archToIni.end()) {381 if (iniIt == archToIni.end()) {
@@ -398,7 +397,7 @@ size_t GetMemoryLimitForArch(const std::string& arch, const std::string& space)
398 return 0;397 return 0;
399 }398 }
400 } catch (const std::exception& e) {399 } catch (const std::exception& e) {
401- PLATFORM_LOGW("GetMemoryLimitForArch(%s) failed: %s.", arch.c_str(), e.what());400+ PLATFORM_LOGW("GetMemoryLimitForArch(%s) failed: %s.", NPUArchToString(arch).c_str(), e.what());
402 return 0;401 return 0;
403 }402 }
404 return memoryLimit;403 return memoryLimit;
@@ -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*.
@@ -1339,7 +1339,7 @@ TEST(BackendCCEBlockOutOps, GeneratesLoadAndStoreThroughFullCodegen)
1339 ir::Span::Unknown());1339 ir::Span::Unknown());
1340 1340 
1341 codegen::CCECodegen codegen(ir::SectionKind::Vector);1341 codegen::CCECodegen codegen(ir::SectionKind::Vector);
1342- auto generated = codegen.GenerateSingle(MakeProgram(body, {tensor}), "a5");1342+ auto generated = codegen.GenerateSingle(MakeProgram(body, {tensor}), npu::tile_fwk::NPUArch::DAV_3510);
1343 1343 
1344 EXPECT_CONTAINS(generated, "TASSIGN(tensor, tensor_ptr + ");1344 EXPECT_CONTAINS(generated, "TASSIGN(tensor, tensor_ptr + ");
1345 EXPECT_CONTAINS(generated, "TLOAD(tile");1345 EXPECT_CONTAINS(generated, "TLOAD(tile");
@@ -2037,7 +2037,7 @@ TEST(BackendCCEBlockOutOps, GeneratesStructCreateThroughAssignStmt)
2037 auto body = std::make_shared<const ir::AssignStmt>(result, create, ir::Span::Unknown());2037 auto body = std::make_shared<const ir::AssignStmt>(result, create, ir::Span::Unknown());
2038 2038 
2039 codegen::CCECodegen codegen(ir::SectionKind::Vector);2039 codegen::CCECodegen codegen(ir::SectionKind::Vector);
2040- auto generated = codegen.GenerateSingle(MakeProgram(body), "a5");2040+ auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_3510);
2041 2041 
2042 EXPECT_CONTAINS(generated, "class MyStruct");2042 EXPECT_CONTAINS(generated, "class MyStruct");
2043 EXPECT_CONTAINS(generated, "MyStruct result = {");2043 EXPECT_CONTAINS(generated, "MyStruct result = {");
@@ -171,7 +171,7 @@ TEST(BackendCceOpsTest, GetBlockIdx)
171 auto body = std::make_shared<const ir::AssignStmt>(result, call, ir::Span::Unknown());171 auto body = std::make_shared<const ir::AssignStmt>(result, call, ir::Span::Unknown());
172 172 
173 codegen::CCECodegen codegen(ir::SectionKind::Cube);173 codegen::CCECodegen codegen(ir::SectionKind::Cube);
174- auto generated = codegen.GenerateSingle(MakeProgram(body), "a3");174+ auto generated = codegen.GenerateSingle(MakeProgram(body), npu::tile_fwk::NPUArch::DAV_2201);
175 EXPECT_NE(generated.find("(int64_t)(get_block_idx())"), std::string::npos);175 EXPECT_NE(generated.find("(int64_t)(get_block_idx())"), std::string::npos);
176}176}
177 177 
@@ -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 
209TEST(CCECodegenTest, RejectsProgramWithoutDebugInfo)211TEST(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 
222TEST(CCECodegenHeaderTest, CoversPointerAndBasicCodegenHelpers)224TEST(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 access905 // 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();
@@ -484,7 +484,7 @@ ir::ProgramPtr MakeSimtAtomicOpsProgram()
484TEST(CCESimtCodegenTest, GeneratesContextCalleesMemoryAccessAndLaunch)484TEST(CCESimtCodegenTest, GeneratesContextCalleesMemoryAccessAndLaunch)
485{485{
486 CCECodegen codegen(ir::SectionKind::Vector);486 CCECodegen codegen(ir::SectionKind::Vector);
487- std::string generated = codegen.GenerateSingle(MakeSimtProgram(), "a5");487+ std::string generated = codegen.GenerateSingle(MakeSimtProgram(), npu::tile_fwk::NPUArch::DAV_3510);
488 488 
489 auto add_pos = generated.find("__simt_callee__ inline float add_scalar(");489 auto add_pos = generated.find("__simt_callee__ inline float add_scalar(");
490 auto store_pos = generated.find("__simt_callee__ inline void store_scalar(");490 auto store_pos = generated.find("__simt_callee__ inline void store_scalar(");
@@ -545,16 +545,19 @@ TEST(CCESimtCodegenTest, GeneratesContextCalleesMemoryAccessAndLaunch)
545TEST(CCESimtCodegenTest, RejectsUnsupportedTargetAndArchitecture)545TEST(CCESimtCodegenTest, RejectsUnsupportedTargetAndArchitecture)
546{546{
547 CCECodegen cube_codegen(ir::SectionKind::Cube);547 CCECodegen cube_codegen(ir::SectionKind::Cube);
548- EXPECT_THROW((void)cube_codegen.GenerateSingle(MakeSimtProgram(), "a5"), npu::tile_fwk::Error);548+ EXPECT_THROW((void)cube_codegen.GenerateSingle(MakeSimtProgram(), npu::tile_fwk::NPUArch::DAV_3510),
549+ npu::tile_fwk::Error);
549 550 
550 CCECodegen vector_codegen(ir::SectionKind::Vector);551 CCECodegen vector_codegen(ir::SectionKind::Vector);
551- EXPECT_THROW((void)vector_codegen.GenerateSingle(MakeSimtProgram(), "a3"), npu::tile_fwk::Error);552+ EXPECT_THROW((void)vector_codegen.GenerateSingle(MakeSimtProgram(), npu::tile_fwk::NPUArch::DAV_2201),
553+ npu::tile_fwk::Error);
552}554}
553 555 
554TEST(CCESimtCodegenTest, DoesNotInterceptOrdinaryKernelCallsWithMatchingCalleeName)556TEST(CCESimtCodegenTest, DoesNotInterceptOrdinaryKernelCallsWithMatchingCalleeName)
555{557{
556 CCECodegen codegen(ir::SectionKind::Vector);558 CCECodegen codegen(ir::SectionKind::Vector);
557- std::string generated = codegen.GenerateSingle(MakeSimtCalleeNameCollisionProgram(), "a5");559+ std::string generated = codegen.GenerateSingle(MakeSimtCalleeNameCollisionProgram(),
560+ npu::tile_fwk::NPUArch::DAV_3510);
558 561 
559 auto entry_pos = generated.find("__simt_vf__ __launch_bounds__(32) inline void collision_entry(");562 auto entry_pos = generated.find("__simt_vf__ __launch_bounds__(32) inline void collision_entry(");
560 auto kernel_pos = generated.find("__aicore__ inline void kernel_impl_vector(");563 auto kernel_pos = generated.find("__aicore__ inline void kernel_impl_vector(");
@@ -570,7 +573,7 @@ TEST(CCESimtCodegenTest, DoesNotInterceptOrdinaryKernelCallsWithMatchingCalleeNa
570TEST(CCESimtCodegenTest, GeneratesRegisteredSynchronizationScalarCastAndMathOperations)573TEST(CCESimtCodegenTest, GeneratesRegisteredSynchronizationScalarCastAndMathOperations)
571{574{
572 CCECodegen codegen(ir::SectionKind::Vector);575 CCECodegen codegen(ir::SectionKind::Vector);
573- std::string generated = codegen.GenerateSingle(MakeSimtScalarOpsProgram(), "a5");576+ std::string generated = codegen.GenerateSingle(MakeSimtScalarOpsProgram(), npu::tile_fwk::NPUArch::DAV_3510);
574 577 
575 const std::vector<std::string> scalar_intrinsics = {578 const std::vector<std::string> scalar_intrinsics = {
576 "__sync_workitems();",579 "__sync_workitems();",
@@ -643,7 +646,7 @@ TEST(CCESimtCodegenTest, GeneratesRegisteredSynchronizationScalarCastAndMathOper
643TEST(CCESimtCodegenTest, GeneratesRegisteredWarpOperations)646TEST(CCESimtCodegenTest, GeneratesRegisteredWarpOperations)
644{647{
645 CCECodegen codegen(ir::SectionKind::Vector);648 CCECodegen codegen(ir::SectionKind::Vector);
646- std::string generated = codegen.GenerateSingle(MakeSimtWarpOpsProgram(), "a5");649+ std::string generated = codegen.GenerateSingle(MakeSimtWarpOpsProgram(), npu::tile_fwk::NPUArch::DAV_3510);
647 650 
648 const std::vector<std::string> warp_intrinsics = {651 const std::vector<std::string> warp_intrinsics = {
649 "laneid()", "lanemask_eq()", "lanemask_le()", "lanemask_lt()", "lanemask_ge()", "lanemask_gt()",652 "laneid()", "lanemask_eq()", "lanemask_le()", "lanemask_lt()", "lanemask_ge()", "lanemask_gt()",
@@ -665,7 +668,7 @@ TEST(CCESimtCodegenTest, GeneratesRegisteredWarpOperations)
665TEST(CCESimtCodegenTest, GeneratesRegisteredAtomicOperationsForTileAndTensor)668TEST(CCESimtCodegenTest, GeneratesRegisteredAtomicOperationsForTileAndTensor)
666{669{
667 CCECodegen codegen(ir::SectionKind::Vector);670 CCECodegen codegen(ir::SectionKind::Vector);
668- std::string generated = codegen.GenerateSingle(MakeSimtAtomicOpsProgram(), "a5");671+ std::string generated = codegen.GenerateSingle(MakeSimtAtomicOpsProgram(), npu::tile_fwk::NPUArch::DAV_3510);
669 672 
670 for (const auto& intrinsic : {"atomicAdd(", "atomicSub(", "atomicExch(", "atomicMax(", "atomicMin(", "atomicInc(",673 for (const auto& intrinsic : {"atomicAdd(", "atomicSub(", "atomicExch(", "atomicMax(", "atomicMin(", "atomicInc(",
671 "atomicDec(", "atomicCAS(", "atomicAnd(", "atomicOr(", "atomicXOr("}) {674 "atomicDec(", "atomicCAS(", "atomicAnd(", "atomicOr(", "atomicXOr("}) {
@@ -23,6 +23,7 @@ import enum
23import struct23import struct
24from typing import Any, Optional24from typing import Any, Optional
25 25 
26+from pypto.pypto_impl import NpuArch
26from pypto.pypto_impl import ir as _ir_core27from pypto.pypto_impl import ir as _ir_core
27from pypto.pypto_impl.ir import (28from pypto.pypto_impl.ir import (
28 AccPhase,29 AccPhase,
@@ -1788,12 +1789,12 @@ def _apply_default_layout(tt: "TileType") -> None:
1788 from pypto_pro.runtime.jit import get_current_arch1789 from pypto_pro.runtime.jit import get_current_arch
1789 1790 
1790 arch = get_current_arch()1791 arch = get_current_arch()
1791- layout_dict = _DEFAULT_LAYOUTS_A5 if arch == "a5" else _DEFAULT_LAYOUTS_A31792+ layout_dict = _DEFAULT_LAYOUTS_A5 if arch == NpuArch.DAV_3510 else _DEFAULT_LAYOUTS_A3
1792 default_layout = layout_dict.get(tt.target_memory)1793 default_layout = layout_dict.get(tt.target_memory)
1793 1794 
1794 if tt.target_memory in (MemorySpace.ScaleLeft, MemorySpace.ScaleRight):1795 if tt.target_memory in (MemorySpace.ScaleLeft, MemorySpace.ScaleRight):
1795 if default_layout is None:1796 if default_layout is None:
1796- raise InvalidVal(f"{tt.target_memory.name} is only supported on A5, got architecture '{arch}'")1797+ raise InvalidVal(f"{tt.target_memory.name} is only supported on 3510, got architecture '{arch}'")
1797 1798 
1798 if default_layout is None:1799 if default_layout is None:
1799 return1800 return
@@ -1817,7 +1818,7 @@ def _apply_default_layout(tt: "TileType") -> None:
1817 allowed_layouts = {_DEFAULT_LAYOUTS_A3[MemorySpace.Left], _DEFAULT_LAYOUTS_A5[MemorySpace.Left]}1818 allowed_layouts = {_DEFAULT_LAYOUTS_A3[MemorySpace.Left], _DEFAULT_LAYOUTS_A5[MemorySpace.Left]}
1818 elif tt.target_memory == MemorySpace.Mat:1819 elif tt.target_memory == MemorySpace.Mat:
1819 allowed_layouts.add(TensorLayout.ZN)1820 allowed_layouts.add(TensorLayout.ZN)
1820- if arch == "a5":1821+ if arch == NpuArch.DAV_3510:
1821 allowed_layouts.update({TensorLayout.ND, TensorLayout.DN})1822 allowed_layouts.update({TensorLayout.ND, TensorLayout.DN})
1822 elif tt.dtype in (DataType.UINT64, DataType.INT64):1823 elif tt.dtype in (DataType.UINT64, DataType.INT64):
1823 allowed_layouts.add(TensorLayout.ND)1824 allowed_layouts.add(TensorLayout.ND)
@@ -1825,7 +1826,7 @@ def _apply_default_layout(tt: "TileType") -> None:
1825 allowed_layouts.update({TensorLayout.ZZ, TensorLayout.NN})1826 allowed_layouts.update({TensorLayout.ZZ, TensorLayout.NN})
1826 1827 
1827 if (1828 if (
1828- arch == "a5"1829+ arch == NpuArch.DAV_3510
1829 and tt.target_memory in (MemorySpace.Left, MemorySpace.Right, MemorySpace.Acc)1830 and tt.target_memory in (MemorySpace.Left, MemorySpace.Right, MemorySpace.Acc)
1830 and tt.layout in _REJECTED_LAYOUTS_ON_A51831 and tt.layout in _REJECTED_LAYOUTS_ON_A5
1831 ):1832 ):
@@ -2259,7 +2260,7 @@ _A5_MATMUL_DTYPE_COMBOS = (
2259 2260 
2260 2261 
2261_MATMUL_DTYPE_COMBOS = {2262_MATMUL_DTYPE_COMBOS = {
2262- "a5": _A5_MATMUL_DTYPE_COMBOS,2263+ NpuArch.DAV_3510: _A5_MATMUL_DTYPE_COMBOS,
2263}2264}
2264 2265 
2265 2266 
@@ -3181,19 +3182,13 @@ _A5_INSERT_QUANT_COMBOS = (
3181)3182)
3182 3183 
3183_LAYOUT_DTYPE_COMBOS = {3184_LAYOUT_DTYPE_COMBOS = {
3184- "load": {"a5": _A5_LOAD_COMBOS},3185+ "load": {NpuArch.DAV_3510: (_A5_LOAD_COMBOS, None)},
3185- "load_tile": {"a5": _A5_LOAD_COMBOS},3186+ "load_tile": {NpuArch.DAV_3510: (_A5_LOAD_COMBOS, None)},
3186- "store": {"a5": _A5_STORE_COMBOS, "a5_quant": _A5_STORE_QUANT_COMBOS},3187+ "store": {NpuArch.DAV_3510: (_A5_STORE_COMBOS, _A5_STORE_QUANT_COMBOS)},
3187- "store_tile": {"a5": _A5_STORE_COMBOS, "a5_quant": _A5_STORE_QUANT_COMBOS},3188+ "store_tile": {NpuArch.DAV_3510: (_A5_STORE_COMBOS, _A5_STORE_QUANT_COMBOS)},
3188- "move": {3189+ "move": {NpuArch.DAV_3510: (_A5_MOVE_COMBOS, _A5_MOVE_QUANT_COMBOS)},
3189- "a5": _A5_MOVE_COMBOS,3190+ "extract": {NpuArch.DAV_3510: (_A5_ACC_NZ_TO_MAT_NZ_COMBOS, _A5_INSERT_QUANT_COMBOS)},
3190- "a5_quant": _A5_MOVE_QUANT_COMBOS,3191+ "insert": {NpuArch.DAV_3510: (_A5_INSERT_COMBOS, _A5_INSERT_QUANT_COMBOS)},
3191- },
3192- "extract": {"a5": _A5_ACC_NZ_TO_MAT_NZ_COMBOS, "a5_quant": _A5_INSERT_QUANT_COMBOS},
3193- "insert": {
3194- "a5": _A5_INSERT_COMBOS,
3195- "a5_quant": _A5_INSERT_QUANT_COMBOS,
3196- },
3197}3192}
3198 3193 
3199 3194 
@@ -3232,7 +3227,7 @@ def _check_layout_dtype(
3232 dst: destination operand —— tile 或 tensor。3227 dst: destination operand —— tile 或 tensor。
3233 is_transpose: load 专用——降序 order 时 GM 有效排布为 DN(仅 load 传入);3228 is_transpose: load 专用——降序 order 时 GM 有效排布为 DN(仅 load 传入);
3234 为 None 时 GM 排布取 tensor 声明值(store 场景)。3229 为 None 时 GM 排布取 tensor 声明值(store 场景)。
3235- quant: 量化路径时查 `a5_quant` 子表,非量化时查 `a5` 主表。3230+ quant: 量化路径时查量化组合表,非量化时查主组合表(按 NpuArch 索引)。
3236 """3231 """
3237 from pypto_pro.runtime.jit import get_current_arch3232 from pypto_pro.runtime.jit import get_current_arch
3238 3233 
@@ -3240,11 +3235,13 @@ def _check_layout_dtype(
3240 combos_by_arch = _LAYOUT_DTYPE_COMBOS.get(op)3235 combos_by_arch = _LAYOUT_DTYPE_COMBOS.get(op)
3241 if combos_by_arch is None:3236 if combos_by_arch is None:
3242 return3237 return
3243- key = f"{arch}_quant" if quant else arch3238+ combos_entry = combos_by_arch.get(arch)
3244- combos = combos_by_arch.get(key)3239+ if combos_entry is None:
3245- if combos is None:
3246 # 该平台暂未配置支持表(如 a3)——不做硬拦截,后续按平台补表后自动生效。3240 # 该平台暂未配置支持表(如 a3)——不做硬拦截,后续按平台补表后自动生效。
3247 return3241 return
3242+ combos = combos_entry[1] if quant else combos_entry[0]
3243+ if combos is None:
3244+ return
3248 3245 
3249 src_loc = _loc_name(src.type)3246 src_loc = _loc_name(src.type)
3250 dst_loc = _loc_name(dst.type)3247 dst_loc = _loc_name(dst.type)
@@ -3382,7 +3379,7 @@ def _get_memory_capacity(target_memory: MemorySpace) -> int:
3382 import logging3379 import logging
3383 3380 
3384 logging.getLogger(__name__).warning(3381 logging.getLogger(__name__).warning(
3385- "Cannot determine %s capacity for arch %r; skipping tile capacity validation. "3382+ "Cannot determine %s capacity for arch %s; skipping tile capacity validation. "
3386 "Check that pypto_impl is loaded and the arch maps to an installed platform ini.",3383 "Check that pypto_impl is loaded and the arch maps to an installed platform ini.",
3387 target_memory,3384 target_memory,
3388 arch,3385 arch,
@@ -122,7 +122,7 @@ def _validate_sync_pipes(
122 if wait_pipe not in supported_wait_pipes:122 if wait_pipe not in supported_wait_pipes:
123 supported = ", ".join(str(pipe) for pipe in supported_wait_pipes)123 supported = ", ".join(str(pipe) for pipe in supported_wait_pipes)
124 raise NotSupported(124 raise NotSupported(
125- f"unsupported A5 synchronization path{side}: {set_pipe} -> {wait_pipe}; "125+ f"unsupported 3510 synchronization path{side}: {set_pipe} -> {wait_pipe}; "
126 f"supported wait_pipe values for {set_pipe}: {supported}"126 f"supported wait_pipe values for {set_pipe}: {supported}"
127 )127 )
128 128 
@@ -18,6 +18,7 @@ from dataclasses import dataclass
18import os18import os
19 19 
20from .._errors import InvalidArgument, InvalidVal, NotSupported, RuntimeFailure20from .._errors import InvalidArgument, InvalidVal, NotSupported, RuntimeFailure
21+from .platform import NpuArch
21 22 
22CCE_BACKEND = "cce"23CCE_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: str59 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_args122 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 target135 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_arch141 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
37from pypto_pro import DataType37from pypto_pro import DataType
38from pypto_pro.language.typing.direction import TensorDirection38from pypto_pro.language.typing.direction import TensorDirection
39from pypto_pro.runtime.compile_config import KernelTarget, get_jit_compile_config39from pypto_pro.runtime.compile_config import KernelTarget, get_jit_compile_config
40+from pypto_pro.runtime.platform import NpuArch, normalize_arch
40 41 
41from .._errors import (42from .._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 concrete318 """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 
1141def _build_bisheng_flags(1144def _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 
1174def _prepare_codegen_inputs(1177def _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 
1291def _codegen_target_cce(1294def _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 raise1316 raise
1314 raise wrapper(str(exc), span=span_of_spec_message(str(exc))) from None1317 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 
1435def _parse_and_codegen_targets(1438def _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 instrumented1447 With ``sanitizer`` enabled, each parsed target program is instrumented
1445 (block.sanitizer_log records injected, one per detection type and1448 (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 = False1453 requires_simt = False
@@ -1543,7 +1546,7 @@ def _runtime_link_args(ascend_home_path: str) -> list[str]:
1543def _run_bisheng(1546def _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 
1575def _compile_shared_library(1578def _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 
1636def _codegen(1639def _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 arch1739 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 = None1993 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().arch2244 platform_arch = get_platform_info().arch
2238 if self._arch is None:2245 if self._arch is None:
2239 self._arch = platform_arch2246 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 @property2251 @property
2246 def arch(self):2252 def arch(self):
@@ -92,6 +92,7 @@ from asc_op_compile_base.common.utils import log as logger
92 92 
93from pypto_pro import DataType93from pypto_pro import DataType
94from pypto_pro.runtime.compile_config import get_jit_compile_config94from pypto_pro.runtime.compile_config import get_jit_compile_config
95+from pypto_pro.runtime.platform import NpuArch
95 96 
96from ..._errors import (97from ..._errors import (
97 InvalidArgument,98 InvalidArgument,
@@ -257,7 +258,7 @@ def _kernel_type_from_target(target) -> KernelMetaType:
257 return kernel_type258 return kernel_type
258 259 
259 260 
260-def _kernel_type_from_codegen(cg, arch: str) -> KernelMetaType:261+def _kernel_type_from_codegen(cg, arch: NpuArch) -> KernelMetaType:
261 target = get_jit_compile_config().resolve_kernel_target(262 target = get_jit_compile_config().resolve_kernel_target(
262 arch,263 arch,
263 has_cube=cg.has_cube,264 has_cube=cg.has_cube,
@@ -369,7 +370,7 @@ def _prepare_infer_cpp(
369 return infer_cpp_path, kernel_type370 return infer_cpp_path, kernel_type
370 371 
371 372 
372-def generate_binary_headers(kernel, arch="a5") -> str:373+def generate_binary_headers(kernel, arch: str = "3510") -> str:
373 """Generate the TilingData and TilingKey headers required by binary delivery."""374 """Generate the TilingData and TilingKey headers required by binary delivery."""
374 from pypto_pro.runtime.jit import (375 from pypto_pro.runtime.jit import (
375 _artifact_prefix_from_filename,376 _artifact_prefix_from_filename,
@@ -377,6 +378,7 @@ def generate_binary_headers(kernel, arch="a5") -> str:
377 _setup_arch_env,378 _setup_arch_env,
378 _TileJitKernel,379 _TileJitKernel,
379 )380 )
381+ from pypto_pro.runtime.platform import normalize_arch
380 382 
381 if not isinstance(kernel, _TileJitKernel):383 if not isinstance(kernel, _TileJitKernel):
382 raise InvalidType("generate_binary_headers() expects a @pl.jit kernel")384 raise InvalidType("generate_binary_headers() expects a @pl.jit kernel")
@@ -386,7 +388,7 @@ def generate_binary_headers(kernel, arch="a5") -> str:
386 f"'{kernel.__name__}' has none; binary delivery needs a tilingkey header"388 f"'{kernel.__name__}' has none; binary delivery needs a tilingkey header"
387 )389 )
388 390 
389- arch = _setup_arch_env(arch)391+ arch = _setup_arch_env(normalize_arch(arch))
390 schema = kernel.tilingkey_schema392 schema = kernel.tilingkey_schema
391 valid_combos = schema.enumerate_valid()393 valid_combos = schema.enumerate_valid()
392 if not valid_combos:394 if not valid_combos:
@@ -405,7 +407,7 @@ def generate_binary_headers(kernel, arch="a5") -> str:
405 return binary_dir407 return binary_dir
406 408 
407 409 
408-def prepare_binary_headers(op_path: str, arch="a5") -> str:410+def prepare_binary_headers(op_path: str, arch: str = "3510") -> str:
409 """Load the sole ``@pl.jit`` kernel in ``op_path`` and prepare its binary-delivery headers."""411 """Load the sole ``@pl.jit`` kernel in ``op_path`` and prepare its binary-delivery headers."""
410 return generate_binary_headers(_load_kernel(op_path), arch)412 return generate_binary_headers(_load_kernel(op_path), arch)
411 413 
@@ -670,7 +672,7 @@ def pypto_compile_op(
670 code_channel=-1,672 code_channel=-1,
671 op_compile_option="{}",673 op_compile_option="{}",
672 extend_options=None,674 extend_options=None,
673- arch="a5",675+ arch: str = "3510",
674):676):
675 """PyPTO leaf replacing ``asc_op_compiler.compile_op``. Signature-compatible; ``cce_file`` is the PyPTO677 """PyPTO leaf replacing ``asc_op_compiler.compile_op``. Signature-compatible; ``cce_file`` is the PyPTO
676 DSL ``.py``. Writes the flat ``kernel_meta`` artifacts + ``<kernel>.o``/``.json`` and records the json678 DSL ``.py``. Writes the flat ``kernel_meta`` artifacts + ``<kernel>.o``/``.json`` and records the json
@@ -685,7 +687,9 @@ def pypto_compile_op(
685 687 
686 extend_options = extend_options or {}688 extend_options = extend_options or {}
687 kernel_name = _op_info_get(op_info, "kernel_name")689 kernel_name = _op_info_get(op_info, "kernel_name")
688- arch = _setup_arch_env(arch)690+ from pypto_pro.runtime.platform import normalize_arch
691+ 
692+ arch = _setup_arch_env(normalize_arch(arch))
689 opt = _setup_options(op_info, compile_options, op_compile_option, extend_options)693 opt = _setup_options(op_info, compile_options, op_compile_option, extend_options)
690 694 
691 kernel = _load_kernel(cce_file)695 kernel = _load_kernel(cce_file)
@@ -30,16 +30,47 @@ from __future__ import annotations
30from dataclasses import dataclass30from dataclasses import dataclass
31import logging31import logging
32from typing import Optional32from typing import Optional
33+import warnings
34+ 
35+from pypto.pypto_impl import NpuArch
36+ 
37+from .._errors import InvalidVal
33 38 
34logger = logging.getLogger(__name__)39logger = logging.getLogger(__name__)
35 40 
36# NPUArch string → compilation arch mapping41# NPUArch string → compilation arch mapping
37_ARCH_MAP = {42_ARCH_MAP = {
38- "DAV_1001": "a3", # 91043+ "DAV_1001": NpuArch.DAV_1001,
39- "DAV_2201": "a3", # 910B/910C44+ "DAV_2201": NpuArch.DAV_2201,
40- "DAV_3510": "a5", # 95045+ "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@dataclass75@dataclass
45class PlatformInfo:76class PlatformInfo:
@@ -54,15 +85,16 @@ class PlatformInfo:
54 vector_core_num: int = 085 vector_core_num: int = 0
55 86 
56 @property87 @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] = None100_cached_info: Optional[PlatformInfo] = None
@@ -128,11 +160,11 @@ def _get_aiv_core_num() -> int:
128 return 0160 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;
22namespace pypto {22namespace pypto {
23void BindPlatform(py::module_& m)23void 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 pypto51} // 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]))
137def four_stage_kernel(137def 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]))
204def mixed_preload_kernel(204def 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))
125def loop_body_shapes(125def 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))
206def struct_filled_in_by_helper(206def 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))
246def stmt_between_stages(246def 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))
270def section_without_stage_between_stages(270def 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))
298def stmt_beside_stage_in_section(298def 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))
321def slot_taken_in_loop_body(321def 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))
344def slot_taken_inside_a_helper(344def 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))
368def cross_core_touched_outside_stage(368def 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))
401def helper_returns_a_slot(401def 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))
423def stage_call_without_a_section(423def 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))
445def one_stage_called_twice(445def 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):
@@ -52,7 +52,7 @@ OVER_32_DEPTH = 33
52OVER_32_FULL_ROWS = OVER_32_ROWS * OVER_32_DEPTH52OVER_32_FULL_ROWS = OVER_32_ROWS * OVER_32_DEPTH
53 53 
54 54 
55-@pl.jit(arch="a5", auto_mutex=True)55+@pl.jit(arch="3510", auto_mutex=True)
56def auto_over_32_kernel(56def auto_over_32_kernel(
57 source: pl.Tensor[[OVER_32_FULL_ROWS, OVER_32_COLS], pl.DT_FP16],57 source: pl.Tensor[[OVER_32_FULL_ROWS, OVER_32_COLS], pl.DT_FP16],
58 output: pl.Tensor[[OVER_32_FULL_ROWS, OVER_32_COLS], pl.DT_FP16],58 output: pl.Tensor[[OVER_32_FULL_ROWS, OVER_32_COLS], pl.DT_FP16],
@@ -104,7 +104,7 @@ GUARD_CHAIN_DEPTH = 2
104GUARD_FULL_ROWS = GUARD_ROWS * (GUARD_MANUAL_DEPTH + GUARD_CHAIN_DEPTH)104GUARD_FULL_ROWS = GUARD_ROWS * (GUARD_MANUAL_DEPTH + GUARD_CHAIN_DEPTH)
105 105 
106 106 
107-@pl.jit(arch="a5", auto_mutex=True)107+@pl.jit(arch="3510", auto_mutex=True)
108def auto_and_manual_guard_paths_kernel(108def auto_and_manual_guard_paths_kernel(
109 source: pl.Tensor[[GUARD_FULL_ROWS, GUARD_COLS], pl.DT_FP16],109 source: pl.Tensor[[GUARD_FULL_ROWS, GUARD_COLS], pl.DT_FP16],
110 output: pl.Tensor[[GUARD_FULL_ROWS, GUARD_COLS], pl.DT_FP16],110 output: pl.Tensor[[GUARD_FULL_ROWS, GUARD_COLS], pl.DT_FP16],
@@ -171,7 +171,7 @@ IF_MERGE_MANUAL_IDS = (25, 26)
171IF_MERGE_FULL_ROWS = IF_MERGE_ROWS * IF_MERGE_DEPTH171IF_MERGE_FULL_ROWS = IF_MERGE_ROWS * IF_MERGE_DEPTH
172 172 
173 173 
174-@pl.jit(arch="a5", auto_mutex=True)174+@pl.jit(arch="3510", auto_mutex=True)
175def auto_if_merge_manual_candidates_kernel(175def auto_if_merge_manual_candidates_kernel(
176 source: pl.Tensor[[IF_MERGE_FULL_ROWS, IF_MERGE_COLS], pl.DT_FP16],176 source: pl.Tensor[[IF_MERGE_FULL_ROWS, IF_MERGE_COLS], pl.DT_FP16],
177 output: pl.Tensor[[IF_MERGE_FULL_ROWS, IF_MERGE_COLS], pl.DT_FP16],177 output: pl.Tensor[[IF_MERGE_FULL_ROWS, IF_MERGE_COLS], pl.DT_FP16],
@@ -238,7 +238,7 @@ ALIAS_TILES = 6
238ALIAS_FULL_ROWS = ALIAS_ROWS * ALIAS_TILES238ALIAS_FULL_ROWS = ALIAS_ROWS * ALIAS_TILES
239 239 
240 240 
241-@pl.jit(arch="a5", auto_mutex=True)241+@pl.jit(arch="3510", auto_mutex=True)
242def auto_partial_alias_matching_manual_id_kernel(242def auto_partial_alias_matching_manual_id_kernel(
243 source: pl.Tensor[[ALIAS_FULL_ROWS, ALIAS_COLS], pl.DT_FP16],243 source: pl.Tensor[[ALIAS_FULL_ROWS, ALIAS_COLS], pl.DT_FP16],
244 output: pl.Tensor[[ALIAS_FULL_ROWS, ALIAS_COLS], pl.DT_FP16],244 output: pl.Tensor[[ALIAS_FULL_ROWS, ALIAS_COLS], pl.DT_FP16],
@@ -319,7 +319,7 @@ TRIPLE_TILES = 10
319TRIPLE_FULL_ROWS = TRIPLE_ROWS * TRIPLE_TILES319TRIPLE_FULL_ROWS = TRIPLE_ROWS * TRIPLE_TILES
320 320 
321 321 
322-@pl.jit(arch="a5", auto_mutex=True)322+@pl.jit(arch="3510", auto_mutex=True)
323def auto_three_groups_partial_vec_overlap_kernel(323def auto_three_groups_partial_vec_overlap_kernel(
324 source: pl.Tensor[[TRIPLE_FULL_ROWS, TRIPLE_COLS], pl.DT_FP16],324 source: pl.Tensor[[TRIPLE_FULL_ROWS, TRIPLE_COLS], pl.DT_FP16],
325 output: pl.Tensor[[TRIPLE_FULL_ROWS, TRIPLE_COLS], pl.DT_FP16],325 output: pl.Tensor[[TRIPLE_FULL_ROWS, TRIPLE_COLS], pl.DT_FP16],
@@ -384,7 +384,7 @@ NONCONTIG_TILES = NONCONTIG_DEPTH * 2
384NONCONTIG_FULL_ROWS = NONCONTIG_ROWS * NONCONTIG_TILES384NONCONTIG_FULL_ROWS = NONCONTIG_ROWS * NONCONTIG_TILES
385 385 
386 386 
387-@pl.jit(arch="a5", auto_mutex=True)387+@pl.jit(arch="3510", auto_mutex=True)
388def auto_noncontiguous_over_32_kernel(388def auto_noncontiguous_over_32_kernel(
389 source: pl.Tensor[[NONCONTIG_FULL_ROWS, NONCONTIG_COLS], pl.DT_FP16],389 source: pl.Tensor[[NONCONTIG_FULL_ROWS, NONCONTIG_COLS], pl.DT_FP16],
390 output: pl.Tensor[[NONCONTIG_FULL_ROWS, NONCONTIG_COLS], pl.DT_FP16],390 output: pl.Tensor[[NONCONTIG_FULL_ROWS, NONCONTIG_COLS], pl.DT_FP16],
@@ -450,7 +450,7 @@ def _make_nested_auto_group(tile_type, base_addr):
450 return _make_nested_auto_group_leaf(tile_type, base_addr)450 return _make_nested_auto_group_leaf(tile_type, base_addr)
451 451 
452 452 
453-@pl.jit(arch="a5", auto_mutex=True)453+@pl.jit(arch="3510", auto_mutex=True)
454def auto_nested_helper_permuted_slots_kernel(454def auto_nested_helper_permuted_slots_kernel(
455 lhs: pl.Tensor[[NESTED_FULL_ROWS, NESTED_COLS], pl.DT_FP16],455 lhs: pl.Tensor[[NESTED_FULL_ROWS, NESTED_COLS], pl.DT_FP16],
456 rhs: pl.Tensor[[NESTED_FULL_ROWS, NESTED_COLS], pl.DT_FP16],456 rhs: pl.Tensor[[NESTED_FULL_ROWS, NESTED_COLS], pl.DT_FP16],
@@ -520,7 +520,7 @@ def _make_compile_time_branch_group(tile_type, base_addr, use_primary):
520 return group520 return group
521 521 
522 522 
523-@pl.jit(arch="a5", auto_mutex=True)523+@pl.jit(arch="3510", auto_mutex=True)
524def auto_helper_compile_time_branches_kernel(524def auto_helper_compile_time_branches_kernel(
525 source: pl.Tensor[[BRANCH_FULL_ROWS, BRANCH_COLS], pl.DT_FP16],525 source: pl.Tensor[[BRANCH_FULL_ROWS, BRANCH_COLS], pl.DT_FP16],
526 output: pl.Tensor[[BRANCH_FULL_ROWS, BRANCH_COLS], pl.DT_FP16],526 output: pl.Tensor[[BRANCH_FULL_ROWS, BRANCH_COLS], pl.DT_FP16],
@@ -567,7 +567,7 @@ CV_N = 64
567CV_VEC_ROWS = 32567CV_VEC_ROWS = 32
568 568 
569 569 
570-@pl.jit(arch="a5", auto_mutex=True)570+@pl.jit(arch="3510", auto_mutex=True)
571def auto_cube_vector_kernel(571def auto_cube_vector_kernel(
572 a: pl.Tensor[[CV_M, CV_N], pl.DT_FP32],572 a: pl.Tensor[[CV_M, CV_N], pl.DT_FP32],
573 b: pl.Tensor[[CV_M, CV_K], pl.DT_FP16],573 b: pl.Tensor[[CV_M, CV_K], pl.DT_FP16],
@@ -45,7 +45,7 @@ def _require_a5(device):
45 pytest.skip(f"Current device is {name}, not A5 (Ascend950). Skip.")45 pytest.skip(f"Current device is {name}, not A5 (Ascend950). Skip.")
46 46 
47 47 
48-@pl.jit(arch="a5", auto_mutex=True)48+@pl.jit(arch="3510", auto_mutex=True)
49def getval_setval_am_kernel(a: pl.Tensor[[64, 128], pl.DT_FP16]):49def getval_setval_am_kernel(a: pl.Tensor[[64, 128], pl.DT_FP16]):
50 tt = pl.TileType(shape=[64, 128], dtype=pl.DT_FP16, target_memory=pl.MemorySpace.Vec)50 tt = pl.TileType(shape=[64, 128], dtype=pl.DT_FP16, target_memory=pl.MemorySpace.Vec)
51 a_db = pl.make_tile_group(type=tt, addrs=[0x00000], mutex_ids=[20])51 a_db = pl.make_tile_group(type=tt, addrs=[0x00000], mutex_ids=[20])
@@ -60,7 +60,7 @@ def getval_setval_am_kernel(a: pl.Tensor[[64, 128], pl.DT_FP16]):
60 pl.store(a, t, [0, 0]) # MTE3 consumer60 pl.store(a, t, [0, 0]) # MTE3 consumer
61 61 
62 62 
63-@pl.jit(arch="a5", auto_mutex=True)63+@pl.jit(arch="3510", auto_mutex=True)
64def getval_while_condition_am_kernel(64def getval_while_condition_am_kernel(
65 a: pl.Tensor[[64, 128], pl.DT_FP16],65 a: pl.Tensor[[64, 128], pl.DT_FP16],
66 out: pl.Tensor[[1], pl.DT_INT64],66 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)
79def cube_move_tile_group_to_tile_kernel(79def 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)
141def cube_move_tile_to_tile_group_kernel(141def 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 -> group201# Pure Vector: group -> tile -> group
202# =============================================================================202# =============================================================================
203-@pl.jit(arch="a5", auto_mutex=True)203+@pl.jit(arch="3510", auto_mutex=True)
204def vector_mixed_move_both_directions_kernel(204def 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)
242def cv_move_acc_group_to_vec_tile_kernel(242def 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],
@@ -69,7 +69,7 @@ def _select_tile_with_if_else(true_tile, false_tile, choose_true):
69 return selected_tile69 return selected_tile
70 70 
71 71 
72-@pl.jit(arch="a5", auto_mutex=True)72+@pl.jit(arch="3510", auto_mutex=True)
73def mixed_width_groups_kernel(73def mixed_width_groups_kernel(
74 source: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16],74 source: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16],
75 output: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16],75 output: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16],
@@ -139,7 +139,7 @@ L0B_K_WIDE = 256
139L0B_N = 128139L0B_N = 128
140 140 
141 141 
142-@pl.jit(arch="a5", auto_mutex=True)142+@pl.jit(arch="3510", auto_mutex=True)
143def cube_vector_multi_id_kernel(143def cube_vector_multi_id_kernel(
144 a: pl.Tensor[[CUBE_M, CUBE_N], pl.DT_FP32],144 a: pl.Tensor[[CUBE_M, CUBE_N], pl.DT_FP32],
145 b: pl.Tensor[[CUBE_M, CUBE_K], pl.DT_FP16],145 b: pl.Tensor[[CUBE_M, CUBE_K], pl.DT_FP16],
@@ -197,7 +197,7 @@ def cube_vector_multi_id_kernel(
197 pl.store(out, vec_group[3], [row_offset, 0])197 pl.store(out, vec_group[3], [row_offset, 0])
198 198 
199 199 
200-@pl.jit(arch="a5", auto_mutex=True)200+@pl.jit(arch="3510", auto_mutex=True)
201def dynamic_multi_id_patterns_kernel(201def dynamic_multi_id_patterns_kernel(
202 a: pl.Tensor[[DYN_FULL_ROWS, TILE_COLS], pl.DT_FP16],202 a: pl.Tensor[[DYN_FULL_ROWS, TILE_COLS], pl.DT_FP16],
203 b: pl.Tensor[[DYN_FULL_ROWS, TILE_COLS], pl.DT_FP16],203 b: pl.Tensor[[DYN_FULL_ROWS, TILE_COLS], pl.DT_FP16],
@@ -230,7 +230,7 @@ def dynamic_multi_id_patterns_kernel(
230 pl.store(offset_out, offset_tile_a, [row, 0])230 pl.store(offset_out, offset_tile_a, [row, 0])
231 231 
232 232 
233-@pl.jit(arch="a5", auto_mutex=True)233+@pl.jit(arch="3510", auto_mutex=True)
234def same_group_overlapping_slots_kernel(234def same_group_overlapping_slots_kernel(
235 a: pl.Tensor[[TILE_ROWS, TILE_COLS], pl.DT_FP16],235 a: pl.Tensor[[TILE_ROWS, TILE_COLS], pl.DT_FP16],
236 b: pl.Tensor[[TILE_ROWS, TILE_COLS], pl.DT_FP16],236 b: pl.Tensor[[TILE_ROWS, TILE_COLS], pl.DT_FP16],
@@ -248,7 +248,7 @@ def same_group_overlapping_slots_kernel(
248 pl.store(out, tile_a, [0, 0])248 pl.store(out, tile_a, [0, 0])
249 249 
250 250 
251-@pl.jit(arch="a5", auto_mutex=True)251+@pl.jit(arch="3510", auto_mutex=True)
252def subfunction_tile_if_else_kernel(252def subfunction_tile_if_else_kernel(
253 true_source: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16],253 true_source: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16],
254 false_source: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16],254 false_source: pl.Tensor[[FULL_ROWS, TILE_COLS], pl.DT_FP16],
@@ -338,7 +338,7 @@ def test_subfunction_tile_if_else():
338 torch.testing.assert_close(out.cpu().float(), golden, rtol=3e-3, atol=3e-3)338 torch.testing.assert_close(out.cpu().float(), golden, rtol=3e-3, atol=3e-3)
339 339 
340 340 
341-@pl.jit(arch="a5", auto_mutex=True)341+@pl.jit(arch="3510", auto_mutex=True)
342def l0a_l0b_overlap_same_id_kernel(342def l0a_l0b_overlap_same_id_kernel(
343 a: pl.Tensor[[L0A_M, L0A_K_WIDE], pl.DT_FP16],343 a: pl.Tensor[[L0A_M, L0A_K_WIDE], pl.DT_FP16],
344 b: pl.Tensor[[L0B_K_WIDE, L0B_N], pl.DT_FP16],344 b: pl.Tensor[[L0B_K_WIDE, L0B_N], pl.DT_FP16],
@@ -64,7 +64,7 @@ def _vec_tile_type():
64# Test 1: TileGroup 动态下标访问64# Test 1: TileGroup 动态下标访问
65# TileGroup dynamic subscript65# TileGroup dynamic subscript
66# =============================================================================66# =============================================================================
67-@pl.jit(arch="a5", auto_mutex=True)67+@pl.jit(arch="3510", auto_mutex=True)
68def dynamic_index_kernel(68def dynamic_index_kernel(
69 a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],69 a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],
70 out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],70 out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],
@@ -86,7 +86,7 @@ def dynamic_index_kernel(
86# Test 2: mutex_ids=None 时通过 depth 创建 TileGroup86# Test 2: mutex_ids=None 时通过 depth 创建 TileGroup
87# TileGroup depth with mutex_ids=None87# TileGroup depth with mutex_ids=None
88# =============================================================================88# =============================================================================
89-@pl.jit(arch="a5", auto_mutex=True)89+@pl.jit(arch="3510", auto_mutex=True)
90def no_mutex_none_kernel(90def no_mutex_none_kernel(
91 a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],91 a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],
92 out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],92 out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],
@@ -123,7 +123,7 @@ def pipeline_mixed_subscript_stage(k, a, out, g):
123 pl.store(out, tile, [k * TILE_M, 0])123 pl.store(out, tile, [k * TILE_M, 0])
124 124 
125 125 
126-@pl.jit(arch="a5", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1))126+@pl.jit(arch="3510", auto_mutex=True, pipeline=pl.pipeline.PipelineConfig(preload=1))
127def pipeline_stage_subscript_kernel(127def pipeline_stage_subscript_kernel(
128 a: pl.Tensor[[PIPELINE_FULL_M, TILE_N], pl.DT_FP16],128 a: pl.Tensor[[PIPELINE_FULL_M, TILE_N], pl.DT_FP16],
129 out: pl.Tensor[[PIPELINE_FULL_M, TILE_N], pl.DT_FP16],129 out: pl.Tensor[[PIPELINE_FULL_M, TILE_N], pl.DT_FP16],
@@ -138,7 +138,7 @@ def pipeline_stage_subscript_kernel(
138# Test 4: 重复 mutex ID 的 16 槽轮转访问138# Test 4: 重复 mutex ID 的 16 槽轮转访问
139# Round-robin access with repeated mutex IDs139# Round-robin access with repeated mutex IDs
140# =============================================================================140# =============================================================================
141-@pl.jit(arch="a5", auto_mutex=True)141+@pl.jit(arch="3510", auto_mutex=True)
142def repeated_mutex_ids_kernel(142def repeated_mutex_ids_kernel(
143 a: pl.Tensor[[REPEATED_FULL_M, TILE_N], pl.DT_FP16],143 a: pl.Tensor[[REPEATED_FULL_M, TILE_N], pl.DT_FP16],
144 out: pl.Tensor[[REPEATED_FULL_M, TILE_N], pl.DT_FP16],144 out: pl.Tensor[[REPEATED_FULL_M, TILE_N], pl.DT_FP16],
@@ -168,7 +168,7 @@ def repeated_mutex_ids_kernel(
168# Test 5: 两个 Tile 槽并行存活的预取场景168# Test 5: 两个 Tile 槽并行存活的预取场景
169# Prefetch with two live Tile slots169# Prefetch with two live Tile slots
170# =============================================================================170# =============================================================================
171-@pl.jit(arch="a5", auto_mutex=True)171+@pl.jit(arch="3510", auto_mutex=True)
172def prefetch_kernel(172def prefetch_kernel(
173 a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],173 a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],
174 out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],174 out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],
@@ -198,7 +198,7 @@ def prefetch_kernel(
198# Test 6: 同一算子访问两个 Tile 槽198# Test 6: 同一算子访问两个 Tile 槽
199# Two Tile slots used by one operation199# Two Tile slots used by one operation
200# =============================================================================200# =============================================================================
201-@pl.jit(arch="a5", auto_mutex=True)201+@pl.jit(arch="3510", auto_mutex=True)
202def two_slots_one_op_kernel(202def two_slots_one_op_kernel(
203 a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],203 a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],
204 out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],204 out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],
@@ -225,7 +225,7 @@ def two_slots_one_op_kernel(
225# Test 7: 循环携带 g[0] 和 g[3] 后执行 add225# Test 7: 循环携带 g[0] 和 g[3] 后执行 add
226# Loop-carried g[0] and g[3] add226# Loop-carried g[0] and g[3] add
227# =============================================================================227# =============================================================================
228-@pl.jit(arch="a5", auto_mutex=True)228+@pl.jit(arch="3510", auto_mutex=True)
229def four_slots_loop_carried_add_kernel(229def four_slots_loop_carried_add_kernel(
230 a: pl.Tensor[[TILE_M, TILE_N], pl.DT_FP16],230 a: pl.Tensor[[TILE_M, TILE_N], pl.DT_FP16],
231 b: pl.Tensor[[TILE_M, TILE_N], pl.DT_FP16],231 b: pl.Tensor[[TILE_M, TILE_N], pl.DT_FP16],
@@ -254,7 +254,7 @@ def four_slots_loop_carried_add_kernel(
254# Test 8: if/else 合并重叠 mutex 候选 ID254# Test 8: if/else 合并重叠 mutex 候选 ID
255# Merge overlapping mutex candidates across if/else255# Merge overlapping mutex candidates across if/else
256# =============================================================================256# =============================================================================
257-@pl.jit(arch="a5", auto_mutex=True)257+@pl.jit(arch="3510", auto_mutex=True)
258def ifelse_overlapping_mutex_ids_kernel(258def ifelse_overlapping_mutex_ids_kernel(
259 a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],259 a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],
260 out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],260 out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],
@@ -289,7 +289,7 @@ def ifelse_overlapping_mutex_ids_kernel(
289# Test 9: TileGroup 边界内常量下标访问289# Test 9: TileGroup 边界内常量下标访问
290# TileGroup bounded constant subscripts290# TileGroup bounded constant subscripts
291# =============================================================================291# =============================================================================
292-@pl.jit(arch="a5", auto_mutex=True)292+@pl.jit(arch="3510", auto_mutex=True)
293def bounded_constant_index_kernel(293def bounded_constant_index_kernel(
294 a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],294 a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],
295 out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],295 out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],
@@ -315,7 +315,7 @@ def bounded_constant_index_kernel(
315# Test 10: 下标 Tile 的 getval/setval 标量访问315# Test 10: 下标 Tile 的 getval/setval 标量访问
316# Scalar getval/setval on a subscript-selected Tile316# Scalar getval/setval on a subscript-selected Tile
317# =============================================================================317# =============================================================================
318-@pl.jit(arch="a5", auto_mutex=True)318+@pl.jit(arch="3510", auto_mutex=True)
319def getval_setval_kernel(319def getval_setval_kernel(
320 a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],320 a: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],
321 out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],321 out: pl.Tensor[[FULL_M, TILE_N], pl.DT_FP16],
@@ -354,7 +354,7 @@ def getval_setval_kernel(
354# Test 11: Cube 双缓冲矩阵乘354# Test 11: Cube 双缓冲矩阵乘
355# Cube double-buffered matmul355# Cube double-buffered matmul
356# =============================================================================356# =============================================================================
357-@pl.jit(arch="a5", auto_mutex=True)357+@pl.jit(arch="3510", auto_mutex=True)
358def matmul_subscript_kernel(358def matmul_subscript_kernel(
359 a: pl.Tensor[[MM_M, MM_K], pl.DT_FP16],359 a: pl.Tensor[[MM_M, MM_K], pl.DT_FP16],
360 b: pl.Tensor[[MM_K, MM_N], pl.DT_FP16],360 b: pl.Tensor[[MM_K, MM_N], pl.DT_FP16],
@@ -21,7 +21,7 @@ CV_NUM_TILES = 13
21CV_M = CV_TILE_M * CV_NUM_TILES21CV_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)
25def limited_matmul(25def 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],
@@ -38,6 +38,7 @@ import os
38from pypto_pro import ir38from pypto_pro import ir
39from pypto_pro._errors import OutOfRange39from pypto_pro._errors import OutOfRange
40import pypto_pro.language as pl40import pypto_pro.language as pl
41+from pypto_pro.runtime.platform import NpuArch
41import pytest42import pytest
42import torch43import torch
43import torch_npu # noqa: F401 — registers npu backend44import torch_npu # noqa: F401 — registers npu backend
@@ -79,7 +80,7 @@ def _run(kernel, *args, **kwargs):
79def _compile_to_cce(kernel) -> str:80def _compile_to_cce(kernel) -> str:
80 from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets81 from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets
81 82 
82- cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "")83+ cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "")
83 return _assemble_cv_source(cube, vector).content84 return _assemble_cv_source(cube, vector).content
84 85 
85 86 
@@ -910,7 +910,7 @@ def compute_gu(ctx_gu, pv_vec_db, exp_corr_db, global_sum_buf, running_o, o_f16,
910# ================================================================910# ================================================================
911# Kernel with NBuffer + auto_mutex911# Kernel with NBuffer + auto_mutex
912# ================================================================912# ================================================================
913-@pl.jit(arch="a5", auto_mutex=True, compile_timeout=200)913+@pl.jit(arch="3510", auto_mutex=True, compile_timeout=200)
914def fa_tnd_with_mask_kernel(914def fa_tnd_with_mask_kernel(
915 q: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16],915 q: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16],
916 k: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16],916 k: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16],
@@ -783,7 +783,7 @@ def compute_gu(ctx_gu, pv_vec_db, exp_corr_db, global_sum_buf, running_o, o_f16,
783# ================================================================783# ================================================================
784# Kernel with NBuffer + auto_mutex784# Kernel with NBuffer + auto_mutex
785# ================================================================785# ================================================================
786-@pl.jit(arch="a5", auto_mutex=True, compile_timeout=200)786+@pl.jit(arch="3510", auto_mutex=True, compile_timeout=200)
787def flex_attention(787def flex_attention(
788 q: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16],788 q: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16],
789 k: pl.Tensor[[pl.DYNAMIC, pl.DYNAMIC, pl.DYNAMIC], pl.DT_FP16],789 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_mutex837# 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)
840def flex_attention_bf16(840def 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")
60def simt_atomic_add_loaded_gm_value(60def 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")
27def simt_bitcast_loaded_gm_value(27def 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],
@@ -49,7 +49,7 @@ def write_lane_id(output: pl.Tensor[[1, WARP_SIZE], pl.DT_INT32]):
49 output[0, tid] = pl.simt.lane_id()49 output[0, tid] = pl.simt.lane_id()
50 50 
51 51 
52-@pl.jit(arch="a5")52+@pl.jit(arch="3510")
53def simt_lane_id(output: pl.Tensor[[1, WARP_SIZE], pl.DT_INT32]):53def simt_lane_id(output: pl.Tensor[[1, WARP_SIZE], pl.DT_INT32]):
54 with pl.section_vector():54 with pl.section_vector():
55 write_lane_id[WARP_SIZE](output)55 write_lane_id[WARP_SIZE](output)
@@ -61,7 +61,7 @@ def write_lanemask_eq(output: pl.Tensor[[1, WARP_SIZE], pl.DT_INT32]):
61 output[0, tid] = pl.simt.lanemask_eq()61 output[0, tid] = pl.simt.lanemask_eq()
62 62 
63 63 
64-@pl.jit(arch="a5")64+@pl.jit(arch="3510")
65def simt_lanemask_eq(output: pl.Tensor[[1, WARP_SIZE], pl.DT_INT32]):65def simt_lanemask_eq(output: pl.Tensor[[1, WARP_SIZE], pl.DT_INT32]):
66 with pl.section_vector():66 with pl.section_vector():
67 write_lanemask_eq[WARP_SIZE](output)67 write_lanemask_eq[WARP_SIZE](output)
@@ -73,7 +73,7 @@ def write_lanemask_ge(output: pl.Tensor[[1, WARP_SIZE], pl.DT_INT32]):
73 output[0, tid] = pl.simt.lanemask_ge()73 output[0, tid] = pl.simt.lanemask_ge()
74 74 
75 75 
76-@pl.jit(arch="a5")76+@pl.jit(arch="3510")
77def simt_lanemask_ge(output: pl.Tensor[[1, WARP_SIZE], pl.DT_INT32]):77def simt_lanemask_ge(output: pl.Tensor[[1, WARP_SIZE], pl.DT_INT32]):
78 with pl.section_vector():78 with pl.section_vector():
79 write_lanemask_ge[WARP_SIZE](output)79 write_lanemask_ge[WARP_SIZE](output)
@@ -85,7 +85,7 @@ def write_lanemask_gt(output: pl.Tensor[[1, WARP_SIZE], pl.DT_INT32]):
85 output[0, tid] = pl.simt.lanemask_gt()85 output[0, tid] = pl.simt.lanemask_gt()
86 86 
87 87 
88-@pl.jit(arch="a5")88+@pl.jit(arch="3510")
89def simt_lanemask_gt(output: pl.Tensor[[1, WARP_SIZE], pl.DT_INT32]):89def simt_lanemask_gt(output: pl.Tensor[[1, WARP_SIZE], pl.DT_INT32]):
90 with pl.section_vector():90 with pl.section_vector():
91 write_lanemask_gt[WARP_SIZE](output)91 write_lanemask_gt[WARP_SIZE](output)
@@ -97,7 +97,7 @@ def write_lanemask_le(output: pl.Tensor[[1, WARP_SIZE], pl.DT_INT32]):
97 output[0, tid] = pl.simt.lanemask_le()97 output[0, tid] = pl.simt.lanemask_le()
98 98 
99 99 
100-@pl.jit(arch="a5")100+@pl.jit(arch="3510")
101def simt_lanemask_le(output: pl.Tensor[[1, WARP_SIZE], pl.DT_INT32]):101def simt_lanemask_le(output: pl.Tensor[[1, WARP_SIZE], pl.DT_INT32]):
102 with pl.section_vector():102 with pl.section_vector():
103 write_lanemask_le[WARP_SIZE](output)103 write_lanemask_le[WARP_SIZE](output)
@@ -109,7 +109,7 @@ def write_lanemask_lt(output: pl.Tensor[[1, WARP_SIZE], pl.DT_INT32]):
109 output[0, tid] = pl.simt.lanemask_lt()109 output[0, tid] = pl.simt.lanemask_lt()
110 110 
111 111 
112-@pl.jit(arch="a5")112+@pl.jit(arch="3510")
113def simt_lanemask_lt(output: pl.Tensor[[1, WARP_SIZE], pl.DT_INT32]):113def simt_lanemask_lt(output: pl.Tensor[[1, WARP_SIZE], pl.DT_INT32]):
114 with pl.section_vector():114 with pl.section_vector():
115 write_lanemask_lt[WARP_SIZE](output)115 write_lanemask_lt[WARP_SIZE](output)
@@ -49,7 +49,7 @@ def write_warp_reduce_add(
49 output[0, tid] = pl.simt.warp_reduce_add(values[0, tid])49 output[0, tid] = pl.simt.warp_reduce_add(values[0, tid])
50 50 
51 51 
52-@pl.jit(arch="a5")52+@pl.jit(arch="3510")
53def simt_warp_reduce_add(53def simt_warp_reduce_add(
54 values: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],54 values: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],
55 output: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],55 output: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],
@@ -67,7 +67,7 @@ def write_warp_reduce_max(
67 output[0, tid] = pl.simt.warp_reduce_max(values[0, tid])67 output[0, tid] = pl.simt.warp_reduce_max(values[0, tid])
68 68 
69 69 
70-@pl.jit(arch="a5")70+@pl.jit(arch="3510")
71def simt_warp_reduce_max(71def simt_warp_reduce_max(
72 values: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],72 values: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],
73 output: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],73 output: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],
@@ -85,7 +85,7 @@ def write_warp_reduce_min(
85 output[0, tid] = pl.simt.warp_reduce_min(values[0, tid])85 output[0, tid] = pl.simt.warp_reduce_min(values[0, tid])
86 86 
87 87 
88-@pl.jit(arch="a5")88+@pl.jit(arch="3510")
89def simt_warp_reduce_min(89def simt_warp_reduce_min(
90 values: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],90 values: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],
91 output: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],91 output: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],
@@ -113,7 +113,7 @@ def write_warp_reduce_fp16_divergent(
113 output[2, tid] = pl.simt.warp_reduce_min(doubled)113 output[2, tid] = pl.simt.warp_reduce_min(doubled)
114 114 
115 115 
116-@pl.jit(arch="a5")116+@pl.jit(arch="3510")
117def simt_warp_reduce_fp16_divergent(117def simt_warp_reduce_fp16_divergent(
118 values: pl.Tensor[[1, WARP_SIZE], pl.DT_FP16],118 values: pl.Tensor[[1, WARP_SIZE], pl.DT_FP16],
119 output: pl.Tensor[[3, WARP_SIZE], pl.DT_FP16],119 output: pl.Tensor[[3, WARP_SIZE], pl.DT_FP16],
@@ -60,7 +60,7 @@ def write_warp_shfl(
60 output[0, tid] = pl.simt.warp_shfl(values[0, tid], SOURCE_LANE, subgroup_width)60 output[0, tid] = pl.simt.warp_shfl(values[0, tid], SOURCE_LANE, subgroup_width)
61 61 
62 62 
63-@pl.jit(arch="a5")63+@pl.jit(arch="3510")
64def simt_warp_shfl(64def simt_warp_shfl(
65 values: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],65 values: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],
66 output: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],66 output: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],
@@ -80,7 +80,7 @@ def write_warp_shfl_down(
80 output[0, tid] = pl.simt.warp_shfl_down(values[0, tid], DELTA, subgroup_width)80 output[0, tid] = pl.simt.warp_shfl_down(values[0, tid], DELTA, subgroup_width)
81 81 
82 82 
83-@pl.jit(arch="a5")83+@pl.jit(arch="3510")
84def simt_warp_shfl_down(84def simt_warp_shfl_down(
85 values: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],85 values: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],
86 output: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],86 output: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],
@@ -100,7 +100,7 @@ def write_warp_shfl_up(
100 output[0, tid] = pl.simt.warp_shfl_up(values[0, tid], DELTA, subgroup_width)100 output[0, tid] = pl.simt.warp_shfl_up(values[0, tid], DELTA, subgroup_width)
101 101 
102 102 
103-@pl.jit(arch="a5")103+@pl.jit(arch="3510")
104def simt_warp_shfl_up(104def simt_warp_shfl_up(
105 values: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],105 values: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],
106 output: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],106 output: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],
@@ -120,7 +120,7 @@ def write_warp_shfl_xor(
120 output[0, tid] = pl.simt.warp_shfl_xor(values[0, tid], LANE_MASK, subgroup_width)120 output[0, tid] = pl.simt.warp_shfl_xor(values[0, tid], LANE_MASK, subgroup_width)
121 121 
122 122 
123-@pl.jit(arch="a5")123+@pl.jit(arch="3510")
124def simt_warp_shfl_xor(124def simt_warp_shfl_xor(
125 values: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],125 values: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],
126 output: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],126 output: pl.Tensor[[1, WARP_SIZE], pl.DT_FP32],
@@ -139,7 +139,7 @@ def write_warp_shfl_bf16(
139 output[0, tid] = pl.simt.warp_shfl(values[0, tid], src_lane, SUBGROUP_WIDTH)139 output[0, tid] = pl.simt.warp_shfl(values[0, tid], src_lane, SUBGROUP_WIDTH)
140 140 
141 141 
142-@pl.jit(arch="a5")142+@pl.jit(arch="3510")
143def simt_warp_shfl_bf16(143def simt_warp_shfl_bf16(
144 values: pl.Tensor[[1, WARP_SIZE], pl.DT_BF16],144 values: pl.Tensor[[1, WARP_SIZE], pl.DT_BF16],
145 output: pl.Tensor[[1, WARP_SIZE], pl.DT_BF16],145 output: pl.Tensor[[1, WARP_SIZE], pl.DT_BF16],
@@ -157,7 +157,7 @@ def write_warp_shfl_xor_fp16(
157 output[0, tid] = pl.simt.warp_shfl_xor(values[0, tid], LANE_MASK, SUBGROUP_WIDTH)157 output[0, tid] = pl.simt.warp_shfl_xor(values[0, tid], LANE_MASK, SUBGROUP_WIDTH)
158 158 
159 159 
160-@pl.jit(arch="a5")160+@pl.jit(arch="3510")
161def simt_warp_shfl_xor_fp16(161def simt_warp_shfl_xor_fp16(
162 values: pl.Tensor[[1, WARP_SIZE], pl.DT_FP16],162 values: pl.Tensor[[1, WARP_SIZE], pl.DT_FP16],
163 output: pl.Tensor[[1, WARP_SIZE], pl.DT_FP16],163 output: pl.Tensor[[1, WARP_SIZE], pl.DT_FP16],
@@ -175,7 +175,7 @@ def write_warp_shfl_down_int64(
175 output[0, tid] = pl.simt.warp_shfl_down(values[0, tid], DELTA)175 output[0, tid] = pl.simt.warp_shfl_down(values[0, tid], DELTA)
176 176 
177 177 
178-@pl.jit(arch="a5")178+@pl.jit(arch="3510")
179def simt_warp_shfl_down_int64(179def simt_warp_shfl_down_int64(
180 values: pl.Tensor[[1, TWO_WARPS], pl.DT_INT64],180 values: pl.Tensor[[1, TWO_WARPS], pl.DT_INT64],
181 output: pl.Tensor[[1, TWO_WARPS], pl.DT_INT64],181 output: pl.Tensor[[1, TWO_WARPS], pl.DT_INT64],
@@ -193,7 +193,7 @@ def write_warp_shfl_down_uint64(
193 output[0, tid] = pl.simt.warp_shfl_down(values[0, tid], DELTA)193 output[0, tid] = pl.simt.warp_shfl_down(values[0, tid], DELTA)
194 194 
195 195 
196-@pl.jit(arch="a5")196+@pl.jit(arch="3510")
197def simt_warp_shfl_down_uint64(197def simt_warp_shfl_down_uint64(
198 values: pl.Tensor[[1, TWO_WARPS], pl.DT_UINT64],198 values: pl.Tensor[[1, TWO_WARPS], pl.DT_UINT64],
199 output: pl.Tensor[[1, TWO_WARPS], pl.DT_UINT64],199 output: pl.Tensor[[1, TWO_WARPS], pl.DT_UINT64],
@@ -57,7 +57,7 @@ def write_warp_active_mask(output: pl.Tensor[[3, WARP_SIZE], pl.DT_UINT32]):
57 output[2, tid] = pl.simt.warp_active_mask()57 output[2, tid] = pl.simt.warp_active_mask()
58 58 
59 59 
60-@pl.jit(arch="a5")60+@pl.jit(arch="3510")
61def simt_warp_active_mask(output: pl.Tensor[[3, WARP_SIZE], pl.DT_UINT32]):61def simt_warp_active_mask(output: pl.Tensor[[3, WARP_SIZE], pl.DT_UINT32]):
62 with pl.section_vector():62 with pl.section_vector():
63 write_warp_active_mask[WARP_SIZE](output)63 write_warp_active_mask[WARP_SIZE](output)
@@ -72,7 +72,7 @@ def write_warp_all(output: pl.Tensor[[2, WARP_SIZE], pl.DT_INT32]):
72 output[1, tid] = pl.simt.warp_all(lane < warp_size - 1)72 output[1, tid] = pl.simt.warp_all(lane < warp_size - 1)
73 73 
74 74 
75-@pl.jit(arch="a5")75+@pl.jit(arch="3510")
76def simt_warp_all(output: pl.Tensor[[2, WARP_SIZE], pl.DT_INT32]):76def simt_warp_all(output: pl.Tensor[[2, WARP_SIZE], pl.DT_INT32]):
77 with pl.section_vector():77 with pl.section_vector():
78 write_warp_all[WARP_SIZE](output)78 write_warp_all[WARP_SIZE](output)
@@ -87,7 +87,7 @@ def write_warp_any(output: pl.Tensor[[2, WARP_SIZE], pl.DT_INT32]):
87 output[1, tid] = pl.simt.warp_any(lane == warp_size)87 output[1, tid] = pl.simt.warp_any(lane == warp_size)
88 88 
89 89 
90-@pl.jit(arch="a5")90+@pl.jit(arch="3510")
91def simt_warp_any(output: pl.Tensor[[2, WARP_SIZE], pl.DT_INT32]):91def simt_warp_any(output: pl.Tensor[[2, WARP_SIZE], pl.DT_INT32]):
92 with pl.section_vector():92 with pl.section_vector():
93 write_warp_any[WARP_SIZE](output)93 write_warp_any[WARP_SIZE](output)
@@ -102,7 +102,7 @@ def write_warp_ballot(output: pl.Tensor[[2, WARP_SIZE], pl.DT_UINT32]):
102 output[1, tid] = pl.simt.warp_ballot(lane < warp_size // 2)102 output[1, tid] = pl.simt.warp_ballot(lane < warp_size // 2)
103 103 
104 104 
105-@pl.jit(arch="a5")105+@pl.jit(arch="3510")
106def simt_warp_ballot(output: pl.Tensor[[2, WARP_SIZE], pl.DT_UINT32]):106def simt_warp_ballot(output: pl.Tensor[[2, WARP_SIZE], pl.DT_UINT32]):
107 with pl.section_vector():107 with pl.section_vector():
108 write_warp_ballot[WARP_SIZE](output)108 write_warp_ballot[WARP_SIZE](output)
@@ -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)
44def make_tuple_chain_attr_kernel(44def 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.v65# 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)
69def make_tuple_chain_three_level_kernel(69def 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)
94def make_tuple_chain_tile_group_next_kernel(94def 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)
122def make_tuple_chain_tile_group_current_kernel(122def 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.d147# 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)
151def make_tuple_chain_four_level_kernel(151def 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.y173# 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)
177def make_tuple_chain_arithmetic_kernel(177def 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.v197# 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)
201def make_tuple_chain_struct_array_elem_kernel(201def 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)
226def make_tuple_chain_tile_group_previous_kernel(226def 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 loop250# 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)
254def make_tuple_chain_double_buffer_loop_kernel(254def 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 slots279# 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)
283def make_tuple_chain_ring_buffer_loop_kernel(283def 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 loop308# 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)
312def make_tuple_chain_loop_accum_kernel(312def 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 branch335# 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)
339def make_tuple_chain_if_branch_kernel(339def 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.
28import re28import re
29 29 
30import pypto_pro.language as pl30import pypto_pro.language as pl
31+from pypto_pro.runtime.platform import NpuArch
31import pytest32import pytest
32 33 
33ROWS = 6434ROWS = 64
@@ -37,7 +38,7 @@ COLS = 64
37def _compile_to_cce(kernel) -> str:38def _compile_to_cce(kernel) -> str:
38 from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets39 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).content42 return _assemble_cv_source(cube, vector).content
42 43 
43 44 
@@ -13,6 +13,7 @@
13import subprocess13import subprocess
14 14 
15import pypto_pro.language as pl15import pypto_pro.language as pl
16+from pypto_pro.runtime.platform import NpuArch
16import pytest17import pytest
17 18 
18 19 
@@ -354,7 +355,7 @@ def control_flow_binary(request, tmp_path_factory):
354 kernel, expected = request.param355 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
14from textwrap import dedent14from textwrap import dedent
15 15 
16import pypto_pro.language as pl16import pypto_pro.language as pl
17+from pypto_pro.runtime.platform import NpuArch
17import pytest18import pytest
18 19 
19 20 
20def _compile_to_cce(kernel) -> str:21def _compile_to_cce(kernel) -> str:
21 from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets22 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).content25 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 
13import pypto_pro.language as pl13import pypto_pro.language as pl
14+from pypto_pro.runtime.platform import NpuArch
14 15 
15 16 
16def _compile_to_cce(kernel) -> str:17def _compile_to_cce(kernel) -> str:
17 from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets18 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).content21 return _assemble_cv_source(cube, vector).content
21 22 
22 23 
@@ -14,12 +14,13 @@
14import re14import re
15 15 
16import pypto_pro.language as pl16import pypto_pro.language as pl
17+from pypto_pro.runtime.platform import NpuArch
17 18 
18 19 
19def _compile_to_cce(kernel) -> str:20def _compile_to_cce(kernel) -> str:
20 from pypto_pro.runtime.jit import _add_kernel_header, _assemble_cv_source, _parse_and_codegen_targets21 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)).content24 return _add_kernel_header(_assemble_cv_source(cube, vector)).content
24 25 
25 26 
@@ -22,6 +22,7 @@ parser hands codegen the scalar exactly as it was written, and the truncation is
22from pypto_pro import ir22from pypto_pro import ir
23import pypto_pro.language as pl23import pypto_pro.language as pl
24from pypto_pro.language import Vf as vf # noqa: N81324from pypto_pro.language import Vf as vf # noqa: N813
25+from pypto_pro.runtime.platform import NpuArch
25import pytest26import pytest
26 27 
27_N, _M = 1, 6428_N, _M = 1, 64
@@ -30,7 +31,7 @@ _N, _M = 1, 64
30def _compile_to_cce(kernel) -> str:31def _compile_to_cce(kernel) -> str:
31 from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets32 from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets
32 33 
33- cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "")34+ cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "")
34 return _assemble_cv_source(cube, vector).content35 return _assemble_cv_source(cube, vector).content
35 36 
36 37 
@@ -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 
14import pypto_pro.language as pl14import pypto_pro.language as pl
15+from pypto_pro.runtime.platform import NpuArch
15 16 
16 17 
17def _compile_to_cce(kernel) -> str:18def _compile_to_cce(kernel) -> str:
18 from pypto_pro.runtime.jit import _add_kernel_header, _assemble_cv_source, _parse_and_codegen_targets19 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)).content22 return _add_kernel_header(_assemble_cv_source(cube, vector)).content
22 23 
23 24 
@@ -22,12 +22,13 @@ import logging
22 22 
23from pypto_pro import ir23from pypto_pro import ir
24import pypto_pro.language as pl24import pypto_pro.language as pl
25+from pypto_pro.runtime.platform import NpuArch
25 26 
26 27 
27def _compile_to_cce(kernel) -> str:28def _compile_to_cce(kernel) -> str:
28 from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets29 from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets
29 30 
30- cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "")31+ cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "")
31 return _assemble_cv_source(cube, vector).content32 return _assemble_cv_source(cube, vector).content
32 33 
33 34 
@@ -18,10 +18,11 @@ import pypto_pro.language as pl
18import pytest18import 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_targets22 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).content26 return _assemble_cv_source(cube, vector).content
26 27 
27 28 
@@ -588,5 +589,5 @@ def test_simt_auto_mutex_emits_pipe_v_lock_unlock_around_launch():
588 589 
589 590 
590def test_simt_codegen_rejects_pre_a5_architecture():591def test_simt_codegen_rejects_pre_a5_architecture():
591- with pytest.raises(NotSupported, match="requires arch='a5'"):592+ with pytest.raises(NotSupported, match="requires arch='3510'"):
592 _compile_to_cce(_simt_tile_codegen_kernel, arch="a3")593 _compile_to_cce(_simt_tile_codegen_kernel, arch="a3")
@@ -12,12 +12,13 @@
12from textwrap import dedent12from textwrap import dedent
13 13 
14import pypto_pro.language as pl14import pypto_pro.language as pl
15+from pypto_pro.runtime.platform import NpuArch
15 16 
16 17 
17def _compile_cube(kernel) -> str:18def _compile_cube(kernel) -> str:
18 from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets19 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).content22 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 
@@ -29,6 +29,7 @@ import re
29 29 
30from pypto_pro._errors import InvalidShape30from pypto_pro._errors import InvalidShape
31import pypto_pro.language as pl31import pypto_pro.language as pl
32+from pypto_pro.runtime.platform import NpuArch
32import pytest33import pytest
33 34 
34DIM = 1635DIM = 16
@@ -38,7 +39,7 @@ TILE = 64
38def _compile_to_cce(kernel) -> str:39def _compile_to_cce(kernel) -> str:
39 from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets40 from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets
40 41 
41- cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), "a5", "")42+ cube, vector = _parse_and_codegen_targets(kernel.to_kernel_def(), NpuArch.DAV_3510, "")
42 return _assemble_cv_source(cube, vector).content43 return _assemble_cv_source(cube, vector).content
43 44 
44 45 
@@ -22,13 +22,14 @@ import subprocess
22from textwrap import dedent22from textwrap import dedent
23 23 
24import pypto_pro.language as pl24import pypto_pro.language as pl
25+from pypto_pro.runtime.platform import NpuArch
25import pytest26import pytest
26 27 
27 28 
28def _compile_to_cce(kernel) -> str:29def _compile_to_cce(kernel) -> str:
29 from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets30 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).content33 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 
13import pypto_pro.language as pl13import pypto_pro.language as pl
14+from pypto_pro.runtime.platform import NpuArch
14 15 
15 16 
16def _compile_to_cce(kernel) -> str:17def _compile_to_cce(kernel) -> str:
17 from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets18 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).content21 return _assemble_cv_source(cube, vector).content
21 22 
22 23 
@@ -21,6 +21,7 @@ coverage.
21import re21import re
22 22 
23import pypto_pro.language as pl23import pypto_pro.language as pl
24+from pypto_pro.runtime.platform import NpuArch
24from pypto_pro.runtime.tilingkey import TilingKeyField25from pypto_pro.runtime.tilingkey import TilingKeyField
25import pytest26import pytest
26 27 
@@ -38,7 +39,7 @@ class _ManualSyncTilingKey:
38def _compile_to_cce(kernel_def) -> str:39def _compile_to_cce(kernel_def) -> str:
39 from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets40 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).content43 return _assemble_cv_source(cube, vector).content
43 44 
44 45 
@@ -14,6 +14,7 @@ from dataclasses import dataclass
14import logging14import logging
15 15 
16import pypto_pro.language as pl16import pypto_pro.language as pl
17+from pypto_pro.runtime.platform import NpuArch
17 18 
18 19 
19def _codegen_result(kernel):20def _codegen_result(kernel):
@@ -21,7 +22,7 @@ def _codegen_result(kernel):
21 from pypto_pro.runtime.kernel import KernelDef22 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.
18import logging18import logging
19 19 
20import pypto_pro.language as pl20import pypto_pro.language as pl
21+from pypto_pro.runtime.platform import NpuArch
21 22 
22 23 
23def _compile_to_cce(kernel) -> str:24def _compile_to_cce(kernel) -> str:
24 from pypto_pro.runtime.jit import _assemble_cv_source, _parse_and_codegen_targets25 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).content28 return _assemble_cv_source(cube, vector).content
28 29 
29 30 
@@ -514,7 +514,7 @@ def test_acc_to_mat_insert_with_scaling_tile_preserves_operand():
514 514 
515@pytest.mark.parametrize("layout", [pl.ND, pl.DN])515@pytest.mark.parametrize("layout", [pl.ND, pl.DN])
516def test_a5_acc_to_mat_move_accepts_supported_destination_layouts(monkeypatch, layout):516def test_a5_acc_to_mat_move_accepts_supported_destination_layouts(monkeypatch, layout):
517- monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "a5")517+ monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "3510")
518 518 
519 @pl.jit(auto_mutex=False)519 @pl.jit(auto_mutex=False)
520 def main(_jit_entry: pl.DT_INT64):520 def main(_jit_entry: pl.DT_INT64):
@@ -1070,7 +1070,7 @@ def test_make_tile_addr_from_constant_expression():
1070@pytest.mark.parametrize("memory", [pl.MemorySpace.Left, pl.MemorySpace.Right, pl.MemorySpace.Acc])1070@pytest.mark.parametrize("memory", [pl.MemorySpace.Left, pl.MemorySpace.Right, pl.MemorySpace.Acc])
1071@pytest.mark.parametrize("layout", [pl.ZZ, pl.NN])1071@pytest.mark.parametrize("layout", [pl.ZZ, pl.NN])
1072def test_a5_rejects_zz_nn_for_cube_buffers(monkeypatch, memory, layout):1072def test_a5_rejects_zz_nn_for_cube_buffers(monkeypatch, memory, layout):
1073- monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "a5")1073+ monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "3510")
1074 1074 
1075 with pytest.raises(InvalidVal, match="do not support"):1075 with pytest.raises(InvalidVal, match="do not support"):
1076 1076 
@@ -1088,7 +1088,7 @@ def test_a5_rejects_zz_nn_for_cube_buffers(monkeypatch, memory, layout):
1088 1088 
1089 1089 
1090def test_a5_allows_regular_cube_buffer_layouts(monkeypatch):1090def test_a5_allows_regular_cube_buffer_layouts(monkeypatch):
1091- monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "a5")1091+ monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "3510")
1092 1092 
1093 @pl.jit(auto_mutex=False)1093 @pl.jit(auto_mutex=False)
1094 def create_tile(_jit_entry: pl.DT_INT64):1094 def create_tile(_jit_entry: pl.DT_INT64):
@@ -1128,7 +1128,7 @@ def test_high_dimensional_nz_load_store_use_last_two_axes_by_default():
1128 1128 
1129 1129 
1130def test_store_and_store_tile_with_scaling_tile_use_store_op(monkeypatch):1130def test_store_and_store_tile_with_scaling_tile_use_store_op(monkeypatch):
1131- monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "a5")1131+ monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "3510")
1132 1132 
1133 @pl.jit(auto_mutex=False)1133 @pl.jit(auto_mutex=False)
1134 def main(out: pl.Tensor[[64, 64], pl.DT_INT8]):1134 def main(out: pl.Tensor[[64, 64], pl.DT_INT8]):
@@ -300,7 +300,7 @@ def test_matmul_mx_acc_rejects_invalid_phase():
300)300)
301def test_mx_scale_tile_defaults_to_fractal_32(target_memory, layout, shape, monkeypatch):301def 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=layout305 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)
319def test_mx_scale_tile_rejects_non_32_fractal(target_memory, layout, shape, monkeypatch):319def 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,
@@ -19,6 +19,7 @@ so a non-innermost column axis would quietly transfer the wrong elements.
19 19 
20from pypto_pro._errors import InvalidArgument, InvalidFormat, InvalidShape, InvalidType20from pypto_pro._errors import InvalidArgument, InvalidFormat, InvalidShape, InvalidType
21import pypto_pro.language as pl21import pypto_pro.language as pl
22+from pypto_pro.runtime.platform import NpuArch
22import pytest23import pytest
23 24 
24B, S, N, G, D = 1, 64, 3, 2, 12825B, S, N, G, D = 1, 64, 3, 2, 128
@@ -31,7 +32,7 @@ def _codegen(kernel):
31 from pypto_pro.runtime.kernel import KernelDef32 from pypto_pro.runtime.kernel import KernelDef
32 33 
33 kernel_def = kernel if isinstance(kernel, KernelDef) else kernel.to_kernel_def()34 kernel_def = kernel if isinstance(kernel, KernelDef) else kernel.to_kernel_def()
34- cube, vector = _parse_and_codegen_targets(kernel_def, "a5", "")35+ cube, vector = _parse_and_codegen_targets(kernel_def, NpuArch.DAV_3510, "")
35 return _assemble_cv_source(cube, vector).content36 return _assemble_cv_source(cube, vector).content
36 37 
37 38 
@@ -32,13 +32,13 @@ from pypto_pro._errors import (
32 NotSupported,32 NotSupported,
33)33)
34import pypto_pro.language as pl34import pypto_pro.language as pl
35-from pypto_pro.runtime.platform import get_platform_info35+from pypto_pro.runtime.platform import NpuArch, get_platform_info
36import pytest36import pytest
37import torch37import torch
38 38 
39pytestmark = pytest.mark.skipif(39pytestmark = 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 
@@ -16,6 +16,7 @@ from types import SimpleNamespace
16from pypto_pro._errors import CommonInner, InvalidArgument, InvalidOperation, InvalidType16from pypto_pro._errors import CommonInner, InvalidArgument, InvalidOperation, InvalidType
17import pypto_pro.language as pl17import pypto_pro.language as pl
18from pypto_pro.language.parser._ast_parser import ASTParser18from pypto_pro.language.parser._ast_parser import ASTParser
19+from pypto_pro.runtime.platform import NpuArch
19import pytest20import pytest
20 21 
21from pypto.pypto_impl import ir22from pypto.pypto_impl import ir
@@ -107,7 +108,7 @@ def test_jit_parses_each_target_once_when_auto_is_present(monkeypatch):
107 lambda program, arch, build_dir, *, target, **kwargs: SimpleNamespace(target=target, sanitizer=False),108 lambda program, arch, build_dir, *, target, **kwargs: SimpleNamespace(target=target, sanitizer=False),
108 )109 )
109 110 
110- cube, vector = jit_runtime._parse_and_codegen_targets(kernel_def, "a5", "")111+ cube, vector = jit_runtime._parse_and_codegen_targets(kernel_def, NpuArch.DAV_3510, "")
111 112 
112 assert kernel_def.parse_targets == [ir.SectionKind.Cube, ir.SectionKind.Vector]113 assert kernel_def.parse_targets == [ir.SectionKind.Cube, ir.SectionKind.Vector]
113 assert cube.target == ir.SectionKind.Cube114 assert cube.target == ir.SectionKind.Cube
@@ -126,7 +127,7 @@ def test_jit_skips_mutex_id_resolution_without_auto_tile_group(monkeypatch):
126 lambda program, arch, build_dir, *, target, **kwargs: SimpleNamespace(target=target, sanitizer=False),127 lambda program, arch, build_dir, *, target, **kwargs: SimpleNamespace(target=target, sanitizer=False),
127 )128 )
128 129 
129- cube, vector = jit_runtime._parse_and_codegen_targets(_kernel_def(k), "a5", "")130+ cube, vector = jit_runtime._parse_and_codegen_targets(_kernel_def(k), NpuArch.DAV_3510, "")
130 131 
131 assert cube.target == ir.SectionKind.Cube132 assert cube.target == ir.SectionKind.Cube
132 assert vector.target == ir.SectionKind.Vector133 assert vector.target == ir.SectionKind.Vector
@@ -144,7 +145,7 @@ def test_jit_preserves_different_manual_ids_in_manual_only_alias_component(monke
144 lambda program, arch, build_dir, *, target, **kwargs: SimpleNamespace(target=target, sanitizer=False),145 lambda program, arch, build_dir, *, target, **kwargs: SimpleNamespace(target=target, sanitizer=False),
145 )146 )
146 147 
147- cube, vector = jit_runtime._parse_and_codegen_targets(_kernel_def(k), "a5", "")148+ cube, vector = jit_runtime._parse_and_codegen_targets(_kernel_def(k), NpuArch.DAV_3510, "")
148 149 
149 assert cube.target == ir.SectionKind.Cube150 assert cube.target == ir.SectionKind.Cube
150 assert vector.target == ir.SectionKind.Vector151 assert vector.target == ir.SectionKind.Vector
@@ -164,7 +165,7 @@ def test_jit_rejects_multi_id_manual_tile_in_alias_component(monkeypatch):
164 )165 )
165 166 
166 with pytest.raises(InvalidArgument, match="must have exactly one manual mutex ID"):167 with pytest.raises(InvalidArgument, match="must have exactly one manual mutex ID"):
167- jit_runtime._parse_and_codegen_targets(_kernel_def(k), "a5", "")168+ jit_runtime._parse_and_codegen_targets(_kernel_def(k), NpuArch.DAV_3510, "")
168 169 
169 170 
170def test_jit_rejects_crossing_addresses_in_auto_alias_component():171def test_jit_rejects_crossing_addresses_in_auto_alias_component():
@@ -245,7 +245,7 @@ def test_auto_mutex_single_tile():
245 245 
246 246 
247def test_auto_mutex_locks_scale_kwarg_tile(monkeypatch):247def test_auto_mutex_locks_scale_kwarg_tile(monkeypatch):
248- monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "a5")248+ monkeypatch.setenv("PYPTOPRO_JIT_ARCH", "3510")
249 249 
250 @pl.jit(auto_mutex=True)250 @pl.jit(auto_mutex=True)
251 def k(out: pl.Tensor[[64, 64], pl.DT_INT8]):251 def k(out: pl.Tensor[[64, 64], pl.DT_INT8]):
@@ -277,7 +277,7 @@ def test_sync_rejects_aic_only_path_in_vector_section():
277 event_id=0,277 event_id=0,
278 )278 )
279 279 
280- with pytest.raises(NotSupported, match="unsupported A5 synchronization path on AIV"):280+ with pytest.raises(NotSupported, match="unsupported 3510 synchronization path on AIV"):
281 func.to_kernel_def().parse_target_program(ir.SectionKind.Vector)281 func.to_kernel_def().parse_target_program(ir.SectionKind.Vector)
282 282 
283 283 
@@ -291,7 +291,7 @@ def test_sync_rejects_aiv_only_path_in_cube_section():
291 event_id=0,291 event_id=0,
292 )292 )
293 293 
294- with pytest.raises(NotSupported, match="unsupported A5 synchronization path on AIC"):294+ with pytest.raises(NotSupported, match="unsupported 3510 synchronization path on AIC"):
295 func.to_kernel_def().parse_target_program(ir.SectionKind.Cube)295 func.to_kernel_def().parse_target_program(ir.SectionKind.Cube)
296 296 
297 297 
@@ -305,7 +305,7 @@ def test_sync_rejects_unsupported_aic_pipe_path():
305 event_id=0,305 event_id=0,
306 )306 )
307 307 
308- with pytest.raises(NotSupported, match="unsupported A5 synchronization path on AIC"):308+ with pytest.raises(NotSupported, match="unsupported 3510 synchronization path on AIC"):
309 func.to_kernel_def().parse_target_program(ir.SectionKind.Cube)309 func.to_kernel_def().parse_target_program(ir.SectionKind.Cube)
310 310 
311 311 
@@ -89,7 +89,7 @@ def test_tile_type_bias_single_row_allowed():
89 89 
90 90 
91def test_tile_type_bias_non_nd_layout_rejected():91def 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.DN95 shape=[1, 128], dtype=pl.DT_FP32, target_memory=pl.MemorySpace.Bias, layout=pl.DN
@@ -22,6 +22,7 @@ import sys
22from unittest.mock import MagicMock22from unittest.mock import MagicMock
23 23 
24from pypto_pro._errors import InvalidShape24from pypto_pro._errors import InvalidShape
25+from pypto_pro.runtime.platform import NpuArch
25import pytest26import 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_ = 0xDEAD704 _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
16from pypto_pro._errors import InvalidVal, RuntimeFailure16from pypto_pro._errors import InvalidVal, RuntimeFailure
17import pypto_pro.language as pl17import pypto_pro.language as pl
18from pypto_pro.runtime.compile_config import JitCompileConfig, KernelTarget, get_jit_compile_config18from pypto_pro.runtime.compile_config import JitCompileConfig, KernelTarget, get_jit_compile_config
19+from pypto_pro.runtime.platform import NpuArch, normalize_arch
19import pytest20import pytest
20 21 
21jit = importlib.import_module("pypto_pro.runtime.jit")22jit = importlib.import_module("pypto_pro.runtime.jit")
@@ -23,22 +24,21 @@ jit = importlib.import_module("pypto_pro.runtime.jit")
23 24 
24@pytest.fixture25@pytest.fixture
25def future_config():26def 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 
79def test_simt_launcher_bakes_inferred_dynamic_ub_into_generated_caller():79def 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 caller87 assert "uint32_t dynamicUbSize" not in caller
88 assert 'call_kernel(uint32_t blockDim, void* stream)' in caller88 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 
94def test_architecture_specific_mixed_geometry_is_independent(future_config):94def 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 
103def test_missing_architecture_is_not_assumed_to_use_a5_geometry():103def 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 
109def test_missing_kernel_mode_is_not_replaced_with_mixed_target(future_config):111def 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 
115def test_empty_kernel_is_rejected_before_selecting_flags():117def 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")])
122def test_cross_sync_still_requires_both_engines(cube, vector, missing):124def 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))])
130def test_shared_library_and_caller_use_the_same_resolved_target(monkeypatch, tmp_path, future_config, arch, cores):132def 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 
192def test_debug_command_reuses_compiled_target_without_resolving(monkeypatch, tmp_path):194def 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
22from pathlib import Path22from pathlib import Path
23import subprocess23import subprocess
24 24 
25+from pypto_pro.runtime.platform import NpuArch
25import pytest26import pytest
26 27 
27jit = importlib.import_module("pypto_pro.runtime.jit")28jit = 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 target85+ # 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 
27def _snippet(kernel_name, specs, dims):28def _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 vector54 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.Input56 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 vector74 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.Input76 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 vector95 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.SCALAR97 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 vector117 cg = cube or vector
117 assert cg.param_specs[0].direction is pl.Input118 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_config187 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 vector191 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_config225 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 vector229 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 
252def test_native_metadata_gate(tmp_path):253def 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
14import struct14import struct
15import subprocess15import subprocess
16 16 
17+from pypto_pro.runtime.platform import NpuArch
17import pytest18import pytest
18 19 
19jit = importlib.import_module("pypto_pro.runtime.jit")20jit = 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 
14from pypto_pro._errors import OutOfRange14from pypto_pro._errors import OutOfRange
15import pypto_pro.language as pl15import pypto_pro.language as pl
16+from pypto_pro.runtime.platform import NpuArch
16import pytest17import pytest
17 18 
18from pypto.pypto_impl import ir19from 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,
@@ -35,6 +35,7 @@ from pypto_pro.runtime.opc.pypto_compile import (
35 prepare_binary_headers,35 prepare_binary_headers,
36 pypto_compile_op,36 pypto_compile_op,
37)37)
38+from pypto_pro.runtime.platform import NpuArch
38from pypto_pro.runtime.tilingkey import TilingKeyField39from pypto_pro.runtime.tilingkey import TilingKeyField
39import pytest40import pytest
40 41 
@@ -85,8 +86,8 @@ def test_generate_binary_headers_emits_only_tiling_headers(monkeypatch, tmp_path
85 "_codegen",86 "_codegen",
86 lambda *args, **kwargs: pytest.fail("generate_binary_headers must not run full codegen"),87 lambda *args, **kwargs: pytest.fail("generate_binary_headers must not run full codegen"),
87 )88 )
88- binary_dir = Path(generate_binary_headers(header_generation_kernel, "a5"))89+ binary_dir = Path(generate_binary_headers(header_generation_kernel, "3510"))
89- assert os.environ["PYPTOPRO_JIT_ARCH"] == "a5"90+ assert os.environ["PYPTOPRO_JIT_ARCH"] == "3510"
90 assert binary_dir.is_dir(), f"binary dir not created: {binary_dir}"91 assert binary_dir.is_dir(), f"binary dir not created: {binary_dir}"
91 92 
92 tiling_header = binary_dir / "HeaderTiling_tiling.h"93 tiling_header = binary_dir / "HeaderTiling_tiling.h"
@@ -113,7 +114,7 @@ def test_prepare_binary_headers_loads_the_kernel_file(monkeypatch, tmp_path):
113 114 
114 binary_dir = Path(prepare_binary_headers(__file__))115 binary_dir = Path(prepare_binary_headers(__file__))
115 116 
116- assert os.environ["PYPTOPRO_JIT_ARCH"] == "a5"117+ assert os.environ["PYPTOPRO_JIT_ARCH"] == "3510"
117 assert (binary_dir / "HeaderTiling_tiling.h").is_file()118 assert (binary_dir / "HeaderTiling_tiling.h").is_file()
118 assert (binary_dir / "HeaderTilingKey_tilingkey.h").is_file()119 assert (binary_dir / "HeaderTilingKey_tilingkey.h").is_file()
119 assert not list(binary_dir.glob("*_pypto_infer.cpp"))120 assert not list(binary_dir.glob("*_pypto_infer.cpp"))
@@ -132,9 +133,9 @@ def test_pypto_compile_op_sets_up_explicit_arch(monkeypatch):
132 monkeypatch.setattr(compile_module, "_setup_options", stop_after_arch_setup)133 monkeypatch.setattr(compile_module, "_setup_options", stop_after_arch_setup)
133 134 
134 with pytest.raises(RuntimeError, match="stop after arch setup"):135 with pytest.raises(RuntimeError, match="stop after arch setup"):
135- pypto_compile_op("unused.py", "kernel", {"kernel_name": "kernel"}, arch="a5")136+ pypto_compile_op("unused.py", "kernel", {"kernel_name": "kernel"}, arch="3510")
136 137 
137- assert received_arch == ["a5"]138+ assert received_arch == [NpuArch.DAV_3510]
138 139 
139 140 
140@pytest.mark.parametrize(141@pytest.mark.parametrize(
@@ -163,7 +164,7 @@ def test_kernel_type_from_target_uses_configured_core_ratio(aic_per_block, aiv_p
163def test_kernel_type_from_codegen_reuses_a5_target_config(has_cube, has_vector, expected):164def test_kernel_type_from_codegen_reuses_a5_target_config(has_cube, has_vector, expected):
164 codegen_result = SimpleNamespace(has_cube=has_cube, has_vector=has_vector)165 codegen_result = SimpleNamespace(has_cube=has_cube, has_vector=has_vector)
165 166 
166- assert _kernel_type_from_codegen(codegen_result, "a5") is expected167+ assert _kernel_type_from_codegen(codegen_result, NpuArch.DAV_3510) is expected
167 168 
168 169 
169@pytest.mark.parametrize(170@pytest.mark.parametrize(
@@ -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")
47def static_dynamic_kernel(47def 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 return50 return
51 51 
52 52 
53-@pl.jit(arch="a5")53+@pl.jit(arch="3510")
54def dynamic_dynamic_kernel(54def 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")
34def mixed_policy_kernel(34def 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 return37 return
38 38 
39 39 
40-@pl.jit(arch="a5")40+@pl.jit(arch="3510")
41def ellipsis_policy_kernel(41def ellipsis_policy_kernel(
42 x: pl.Tensor[[pl.DYNAMIC, ...], pl.DT_FP32],42 x: pl.Tensor[[pl.DYNAMIC, ...], pl.DT_FP32],
43):43):
44 return44 return
45 45 
46 46 
47-@pl.jit(arch="a5")47+@pl.jit(arch="3510")
48def call_style_policy_kernel(48def 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)
41def kernel_permutation(41def 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 
33def _make_kernel(tiling_key_cls):33def _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)
37import pypto_pro.language as pl37import pypto_pro.language as pl
38from pypto_pro.language import Vf as vf # noqa: N81338from pypto_pro.language import Vf as vf # noqa: N813
39+from pypto_pro.runtime.platform import NpuArch
39import pytest40import pytest
40 41 
41from pypto.pypto_impl import ir42from 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.