| Files | Last commit | Last update |
|---|---|---|
refactor(machine): Drop execute-path RUNTIME_SlotMarkNeedAlloc covered by path marking Co-authored-by: songyangyang18<songyangyang18@huawei.com> # message auto-generated for no-merge-commit merge: !6754 merge clean into master refactor(machine): Drop execute-path RUNTIME_SlotMarkNeedAlloc covered by path marking Created-by: songyangyang18 Commit-by: songyangyang18 Merged-by: cann-robot Description: ## 问题背景: Execute 图上的 NeedAlloc 标记曾用于修复非 assemble 算子(如 pypto.full), 产出的 assemble 目标漏发 RUNTIME_SlotMarkNeedAlloc 的问题。 目前,IR builder 会把所有非 assemble 生产者记录到 tensorConstructFunc_,PATH 级标记constructAssembleSlotList已经覆盖这些 slot,Execute 图上的标记因此变得冗余。 ## 删除的安全性: - 每个 PATH 只有一个 root,PATH 级标记在 PATH 入口发出,早于该 root 的 RUNTIME_RootAlloc。Execute 图标记的非参数 slot 都已被 PATH 标记过,且该标志是幂等的。 - Execute 图额外标记的只有 kernel 参数 slot。运行时 ResolveOutcastAddress 对这些 slot走外部 IO 分支,从不读取 NeedAlloc 标志,因此这些标记本身不起作用。 - 作用:参数 slot 不再计入 constructAssembleNeedAllocRuntimeSlots,totalAssembleOutcastSlot 不再为它们多预留 InnerTemporal slot。 ## 问题样例: 下面的算子,out会被错误纳入assemble outcast内存分配,去掉excute路径,恢复正常。 @pypto.frontend.jit(**_JIT) def _k_out_compute_then_assemble(src: _T, out: _T): pypto.set_vec_tile_shapes(TILE, TILE) out[:] = pypto.mul(src.view([BS, HIDDEN], [0, 0]), 2.0) for i in pypto.loop(N_ROW, name="NA_OCA", idx_name="i"): pypto.set_vec_tile_shapes(TILE, TILE) v = src.view([TILE, HIDDEN], [i * TILE, 0]) pypto.assemble(pypto.mul(v, 4.0), [i * TILE, 0], out) See merge request: cann/pypto!6754 | 1 month ago | |
feat(machine): Support host ctrlflow cache by jit Co-authored-by: qq_52905393<liuzhen180@huawei.com> # message auto-generated for no-merge-commit merge: !5741 merge dev-host-ctrl-jit into master feat(machine): Support host ctrlflow cache by jit Created-by: qq_52905393 Commit-by: qq_52905393 Merged-by: cann-robot Description: 1、支持通过 jit ready_on_host_tensors 配置 npu_name: cpu_name 传入配对关系,算子 kernel 传入值依赖 tensor 对应的 cpu tensor 2、支持传入值依赖 tensor 场景下在 host 侧做 controlflow cache See merge request: cann/pypto!5741 | 2 months ago | |
refactor(machine): Drop execute-path RUNTIME_SlotMarkNeedAlloc covered by path marking Co-authored-by: songyangyang18<songyangyang18@huawei.com> # message auto-generated for no-merge-commit merge: !6754 merge clean into master refactor(machine): Drop execute-path RUNTIME_SlotMarkNeedAlloc covered by path marking Created-by: songyangyang18 Commit-by: songyangyang18 Merged-by: cann-robot Description: ## 问题背景: Execute 图上的 NeedAlloc 标记曾用于修复非 assemble 算子(如 pypto.full), 产出的 assemble 目标漏发 RUNTIME_SlotMarkNeedAlloc 的问题。 目前,IR builder 会把所有非 assemble 生产者记录到 tensorConstructFunc_,PATH 级标记constructAssembleSlotList已经覆盖这些 slot,Execute 图上的标记因此变得冗余。 ## 删除的安全性: - 每个 PATH 只有一个 root,PATH 级标记在 PATH 入口发出,早于该 root 的 RUNTIME_RootAlloc。Execute 图标记的非参数 slot 都已被 PATH 标记过,且该标志是幂等的。 - Execute 图额外标记的只有 kernel 参数 slot。运行时 ResolveOutcastAddress 对这些 slot走外部 IO 分支,从不读取 NeedAlloc 标志,因此这些标记本身不起作用。 - 作用:参数 slot 不再计入 constructAssembleNeedAllocRuntimeSlots,totalAssembleOutcastSlot 不再为它们多预留 InnerTemporal slot。 ## 问题样例: 下面的算子,out会被错误纳入assemble outcast内存分配,去掉excute路径,恢复正常。 @pypto.frontend.jit(**_JIT) def _k_out_compute_then_assemble(src: _T, out: _T): pypto.set_vec_tile_shapes(TILE, TILE) out[:] = pypto.mul(src.view([BS, HIDDEN], [0, 0]), 2.0) for i in pypto.loop(N_ROW, name="NA_OCA", idx_name="i"): pypto.set_vec_tile_shapes(TILE, TILE) v = src.view([TILE, HIDDEN], [i * TILE, 0]) pypto.assemble(pypto.mul(v, 4.0), [i * TILE, 0], out) See merge request: cann/pypto!6754 | 1 month ago | |
refactor(machine): Drop execute-path RUNTIME_SlotMarkNeedAlloc covered by path marking Co-authored-by: songyangyang18<songyangyang18@huawei.com> # message auto-generated for no-merge-commit merge: !6754 merge clean into master refactor(machine): Drop execute-path RUNTIME_SlotMarkNeedAlloc covered by path marking Created-by: songyangyang18 Commit-by: songyangyang18 Merged-by: cann-robot Description: ## 问题背景: Execute 图上的 NeedAlloc 标记曾用于修复非 assemble 算子(如 pypto.full), 产出的 assemble 目标漏发 RUNTIME_SlotMarkNeedAlloc 的问题。 目前,IR builder 会把所有非 assemble 生产者记录到 tensorConstructFunc_,PATH 级标记constructAssembleSlotList已经覆盖这些 slot,Execute 图上的标记因此变得冗余。 ## 删除的安全性: - 每个 PATH 只有一个 root,PATH 级标记在 PATH 入口发出,早于该 root 的 RUNTIME_RootAlloc。Execute 图标记的非参数 slot 都已被 PATH 标记过,且该标志是幂等的。 - Execute 图额外标记的只有 kernel 参数 slot。运行时 ResolveOutcastAddress 对这些 slot走外部 IO 分支,从不读取 NeedAlloc 标志,因此这些标记本身不起作用。 - 作用:参数 slot 不再计入 constructAssembleNeedAllocRuntimeSlots,totalAssembleOutcastSlot 不再为它们多预留 InnerTemporal slot。 ## 问题样例: 下面的算子,out会被错误纳入assemble outcast内存分配,去掉excute路径,恢复正常。 @pypto.frontend.jit(**_JIT) def _k_out_compute_then_assemble(src: _T, out: _T): pypto.set_vec_tile_shapes(TILE, TILE) out[:] = pypto.mul(src.view([BS, HIDDEN], [0, 0]), 2.0) for i in pypto.loop(N_ROW, name="NA_OCA", idx_name="i"): pypto.set_vec_tile_shapes(TILE, TILE) v = src.view([TILE, HIDDEN], [i * TILE, 0]) pypto.assemble(pypto.mul(v, 4.0), [i * TILE, 0], out) See merge request: cann/pypto!6754 | 1 month ago | |
feat(dfx): Runtime memory overlap check Co-authored-by: duanhaotian<duanhaotian@huawei.com> # message auto-generated for no-merge-commit merge: !5107 merge duanhaotian7 into master feat(dfx): Runtime memory overlap check Created-by: duanhaotian Commit-by: duanhaotian Merged-by: cann-robot Description: dump运行时各个op的读写信息以及每个op的读写范围大小并dump运行时整体内存使用情况统计,基于相关dump数据和topo序,设计内存重叠检测脚本,检测是否存在 内存重叠 See merge request: cann/pypto!5107 | 3 months ago | |
style(all): Apply additional clang-format corrections across codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4883 merge style-cpp into master style(all): Apply additional clang-format corrections across codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Apply additional clang-format corrections across codebase See merge request: cann/pypto!4883 | 4 months ago | |
fix(machine): Page-align ctrlflow .pypto so adrp survives AOT memcpy Co-authored-by: LordOfMysteries<duhongxiang@huawei.com> # message auto-generated for no-merge-commit merge: !6663 merge fix-ctrlflow-pypto-page-align into master fix(machine): Page-align ctrlflow .pypto so adrp survives AOT memcpy Created-by: LordOfMysteries Commit-by: LordOfMysteries Merged-by: cann-robot Description: https://gitcode.com/cann/pypto/issues/3441 # CANN包内 GCC 7升级到14 后 PyPTO 算子精度异常 ## 1. 背景 cann 包内置编译器由 gcc 7 升级到 gcc 14 后,pypto 算子精度异常 pypto的Device ctrlflow机制:跑在device上的aicpu不是完整 .so,只包含了调度大框架。支持动态shape tiling展开的源码使用了AOT技术在host编译,JIT拷贝到device上执行: 1. gcc -S / -c 2. ld -T merge.link 合成 .pypto(*(.pypto.entry) *(.pypto.func) *(.rodata.*),VMA 0x10000) 3. objcopy --dump-section .pypto= 4. memcpy 到 4K 对齐 AOT 池,CallControlFlow 当函数指针跳入(参数在 x0–x3) ## 2. 现象(Device 日志比对) CallRootFunctionStitch(源码 device_execute_context.cpp:611)通过 SchemaGetExpressionTable() 打印 expr 表(同一 gdr_bwd kernel): - **ok.log**(正确): RUid{0,1,3} expr{[0,9,3,23,22,24,16,20,6,19,21,14,4,1,8,10,15,0,7,18,17,5,11,2,0,...]} - **fail.log**(异常): RUid{0,1,3} expr{[-117395325,-117394301,-117397373,-117396349,-117399421,-117398397,-1702252313,1358955619,-1201444600,-1862140633,285473027,445136995,0,0,...]} → fail 情况下 expr 表**前若干个值被写成垃圾数据**,后续值才与 ok 一致。 ## 3. 二进制产物比对 AICPU 侧生成 expr 表的源文件 kernel_aicpu/control_flow_expr_table_*.cpp, OK 与 FAIL 两份**源码完全一致**,差异全部来自编译器生成的汇编码。 ### 3.1 关键指令(错误指令定位) GCC 7编译 000000000001d840 <_ZN3npu8tile_fwk17SetExprBatch_17_0EPvPlPPFS1_S1_mEPNS0_16DevStartArgsBaseEPmS2_>: 1d840: b4007284 cbz x4, 1e690 <_ZN3npu8tile_fwk17SetExprBatch_17_0EPvPlPPFS1_S1_mEPNS0_16DevStartArgsBaseEPmS2_+0xe50> 1d844: a9be7bfd stp x29, x30, [sp, #-32]! 1d848: d280012a mov x10, #0x9 // #9 1d84c: d2800068 mov x8, #0x3 // #3 1d850: 910003fd mov x29, sp 1d854: d28002e9 mov x9, #0x17 // #23 1d858: d28002c2 mov x2, #0x16 // #22 1d85c: d2800307 mov x7, #0x18 // #24 1d860: d2800030 mov x16, #0x1 // #1 1d864: d280008f mov x15, #0x4 // #4 1d868: d2800200 mov x0, #0x10 // #16 GCC 14编译: .arch armv8-a .file "control_flow_expr_table_0_0.cpp" .text .section .pypto.func,"ax",@progbits .align 2 .p2align 5,,15 .global _ZN3npu8tile_fwk16SetExprBatch_0_0EPvPlPPFS1_S1_mEPNS0_16DevStartArgsBaseEPmS2_ .type _ZN3npu8tile_fwk16SetExprBatch_0_0EPvPlPPFS1_S1_mEPNS0_16DevStartArgsBaseEPmS2_, %function _ZN3npu8tile_fwk16SetExprBatch_0_0EPvPlPPFS1_S1_mEPNS0_16DevStartArgsBaseEPmS2_: .LFB1627: .cfi_startproc cbz x4, .L2 adrp x0, .LC0 stp xzr, xzr, [x4, 192] ldr q30, [x0, #:lo12:.LC0] adrp x0, .LC1 ldr q29, [x0, #:lo12:.LC1] adrp x0, .LC2 ldr q31, [x0, #:lo12:.LC2] adrp x0, .LC3 stp q30, q29, [x4] FAIL 构建 kernel_aicpu/control_flow_expr_table_0_0.cpp.s 中,SetExprBatch_0_0 前段: asm ldr q30, [x0, #:lo12:.LC0] ; 从字面量池读 128-bit 常量到 NEON 寄存器 ldr q29, [x0, #:lo12:.LC1] ldr q31, [x0, #:lo12:.LC2] stp q30, q29, [x4] ; 偏移 0 → exprList[0..7] stp q31, q29, [x4, 32] ; 偏移 32 → exprList[8..15] stp q30, q29, [x4, 64] ; 偏移 64 → exprList[16..23] ... 即:gcc14 将"连续写常量到 expr 表"的标量序列**自动向量化**为 128-bit NEON (FP/SIMD q 寄存器)存取指令。写入范围 [x4, 0..160] 恰好覆盖 expr 表前 约 12~23 个被污染的值,与日志中垃圾值所在区间吻合。 ### 3.2 全表统计 | 构建 | 每个 control_flow_expr_table_*.cpp.s 中 NEON q 寄存器出现次数 | |------|:---:| | OK(带 -mgeneral-regs-only) | **0**(全部 19 个表) | | FAIL(不带该选项) | **18**(全部 19 个表) | ### 3.3 对照的 OK 生成形态(纯通用寄存器) asm stp xzr, x8, [x4] ; 使用通用寄存器 x 系列 stp x6, x7, [x4, 16] stp x0, x2, [x4, 32] ... ## 4. 根因(已依据二进制反汇编+重定位实测修正) 一句话:adrp 只负责跳到「某一页的开头」,ldr 再在这一页里加上一个不到 4KB 的偏移。链接时这两段数是按虚拟地址 0x10260 起算的,拷到内存后代码却从页的开头执行,所以加出来的地址落在常量前面。 ### 4.0 真实机制:adrp 的页差和页内偏移按链接地址写死,memcpy 到页首后指错 adrp 只算出某一页的开头,ldr 再加上页内偏移: text adrp x0, .LC0 x0 = 当前指令所在页 + imm × 0x1000 ldr q30, [x0, #lo12] 地址 = x0 + lo12 pg(x) 表示把地址低 12 位清零(一页 0x1000)。imm 和 lo12 都在链接时写进指令,运行时不再修改: | 写进指令的数 | 含义 | |---|---| | imm = 13 | pg(.LC) − pg(这条 adrp) | | lo12 = 0x350 | .LC 链接虚拟地址 0x1e350 的低 12 位 | 链接布局(.pypto 从 0x10260 开始,前面 0x260 是 .eh_frame。这段不在 dump 出的 bin 里,但占了虚拟地址): text 页 0x10000 页 0x11000 页 0x1E000 0x10000 0x10260 0x11184 0x1E350 | 空隙260 |==== .pypto 起点 ====| | adrp | | .LC | text pg(0x1e350) − pg(0x11184) = 0x1e000 − 0x11000 = 0xD000 = 13 页 按链接地址:0x11000 + 13×0x1000 + 0x350 = 0x1e350 在 ELF 里这指对 .LC。objcopy 只抽出 .pypto,bin[0] 对应虚拟地址 0x10260,不是 0x10000: text adrp 在 bin 中的偏移 = 0x11184 − 0x10260 = 0xF24 .LC 在 bin 中的偏移 = 0x1e350 − 0x10260 = 0xE0F0 0xE0F0 落在 bin 的第 14 页(0xE000),页内偏移是 0x0F0,不再是链接时的 0x350。 AOT 把 bin[0] 拷到 4K 对齐的 base(aotCodePoolCodes 为 .p2align 12),再从 base 执行。指令在 base+0xF24,仍属于第 0 页: text x0 = pg(base+0xF24) + 13×0x1000 = base + 0xD000 地址 = base + 0xD000 + 0x350 = base + 0xD350 0xD350 处是别的指令字节,读到 {17960378008443334787, 17960382406489846915}。{0,9} 在 base+0xE0F0。 text 0xE0F0 − 0xD350 = 0xDA0 页号差 1(adrp 落到第 13 页,常量在第 14 页)。字节差不是整页 0x1000,因为 lo12 仍是链接地址的 0x350,常量在 bin 里的页内偏移已经变成 0x0F0。 adrp 可以随整段代码搬家,但搬家量必须是整页的整数倍。这次把「页内第 0x260 字节」当成了新的页首,写死的页差和 lo12 就指到 0xD350。.pypto 的链接地址本身按 4K 对齐时,bin[0] 与页首是同一点,这两段数在拷贝之后仍指向常量。 ### 4.0.1 为什么恰好差一页、为什么只有 gcc14 出问题 - adrp 是 PC 相对的**页(4K)**寻址:imm 表示"PC 所在页 + n 页"。 同一 blob 被整体平移时相对地址不变,**只有当源基址(0x10260)与目标基址(页对齐) 不在同一页关系上(即源基址非页对齐、目标页对齐)时**,跨页引用会整体错一页。 - gcc 7 / OK 构建:SetExprBatch_* 用立即数 mov x8,9; stp xzr,x8,[x4], **没有任何 adrp/字面量池**(.s 中 adrp 计数=0),不存在跨页 .LC 引用 ⇒ 不受影响。 - gcc14 / FAIL 构建:把常量表放 .rodata.cst16 并用 12 条 adrp+ldr q,[x0,#imm] 访问(.s 中 adrp 计数=12),跨页引用在重定位到页对齐池后错一页 ⇒ 读脏数据。 > 更正声明:本文档早期"分发环境不维护 SIMD 寄存器堆 / 进入时 SIMD 寄存器为脏"的说法 > **不正确**。正如你所指:代码是"先 ldr q(载入字面量)再 stp q",寄存器本身没问题; > 真正错误的是 adrp 页偏移在 memcpy 重定位后差一页,导致 ldr q **取错了地址的数据**。 > 问题与 SIMD 寄存器状态无关,而与"gcc14 生成了跨页 adrp 字面量池 + 代码池页对齐重定位"有关。 ## 5 方案 改 ExprBatchGenerator::GenerateLinkScript 生成的 merge.link,让输出段 .pypto 自己落在页边界,并丢掉占位的 .eh_frame: SECTIONS { . = 0x10000; .pypto : ALIGN(4096) { *(.pypto.entry) *(.pypto.func) *(.rodata .rodata.*) } } ALIGN(4096) :即使以后又冒出别的段,.pypto 的链接地址仍然满足 vaddr % 4096 == 0。段内不要再把 .rodata 单独 ALIGN(4096),否则 bin 里会多出整页空洞;只要段起点对齐,ld 会按新地址重填 adrp 和 lo12。 运行时不用改。池子本来就是 .p2align 12,入口仍是 bin[0]。 readelf -S ori.o There are 10 section headers, starting at offset 0x1f6e8: Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 [ 1] .eh_frame PROGBITS 0000000000010000 00010000 0000000000000254 0000000000000000 A 0 0 8 [ 2] .pypto PROGBITS 0000000000010260 00010260 000000000000e110 0000000000000000 AXM 0 0 32 [ 3] .text PROGBITS 000000000001e370 0001e370 0000000000000000 0000000000000000 AX 0 0 1 [ 4] .data PROGBITS 000000000001e370 0001e370 0000000000000000 0000000000000000 WA 0 0 1 [ 5] .bss NOBITS 000000000001e370 0001e370 0000000000000000 0000000000000000 WA 0 0 1 [ 6] .comment PROGBITS 0000000000000000 0001e370 000000000000003e 0000000000000001 MS 0 0 1 [ 7] .symtab SYMTAB 0000000000000000 0001e3b0 0000000000000a08 0000000000000018 8 86 8 [ 8] .strtab STRTAB 0000000000000000 0001edb8 00000000000008e3 0000000000000000 0 0 1 [ 9] .shstrtab STRTAB 0000000000000000 0001f69b 0000000000000046 0000000000000000 0 0 1 readelf -S New.o There are 10 section headers, starting at offset 0x20488: Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 [ 1] .eh_frame PROGBITS 0000000000010000 00010000 0000000000000254 0000000000000000 A 0 0 8 [ 2] .pypto PROGBITS 0000000000011000 00011000 000000000000e110 0000000000000000 AXM 0 0 4096 [ 3] .text PROGBITS 000000000001f110 0001f110 0000000000000000 0000000000000000 AX 0 0 1 [ 4] .data PROGBITS 000000000001f110 0001f110 0000000000000000 0000000000000000 WA 0 0 1 [ 5] .bss NOBITS 000000000001f110 0001f110 0000000000000000 0000000000000000 WA 0 0 1 [ 6] .comment PROGBITS 0000000000000000 0001f110 000000000000003e 0000000000000001 MS 0 0 1 [ 7] .symtab SYMTAB 0000000000000000 0001f150 0000000000000a08 0000000000000018 8 86 8 [ 8] .strtab STRTAB 0000000000000000 0001fb58 00000000000008e4 0000000000000000 0 0 1 [ 9] .shstrtab STRTAB 0000000000000000 0002043c 0000000000000046 0000000000000000 0 0 1 ## 6 影响 对现有 ctrlflow 几乎没有体积、性能和兼容性代价。 ALIGN(4096) 只要求 .pypto 这一段的链接地址落在 4K 边界上,objcopy 抽出来的 bin 仍然从第一条指令开始,不会在 bin 前面多垫 4KB。 See merge request: cann/pypto!6663 | 2 months ago | |
perf(machine): CSE loop-invariant shape dims in SetExprBatch Co-authored-by: LordOfMysteries<duhongxiang@huawei.com> # message auto-generated for no-merge-commit merge: !5005 merge perf/expr-cse-setexprbatch into master perf(machine): CSE loop-invariant shape dims in SetExprBatch Created-by: LordOfMysteries Commit-by: LordOfMysteries Merged-by: cann-robot Description: https://gitcode.com/cann/pypto/issues/2597 perf(machine): CSE loop-invariant shape dims in SetExprBatch Hoist loop-invariant shape-dimension evaluation out of SetExprBatch emit path, and add -march=armv8-a for aarch64 AICPU compiles. Also preserves value-depend CF-cache behavior after BuildControlFlow refactor: - Still emit RUNTIME_RootStitch(RUNTIME_FUNCKEY_CACHESTOP) at DYNAMIC_LOOP / EXECUTE_GRAPH value-depend sites - Still set disableCtrlFlowCache for host launchers that skip CF cache build CACHESTOP (device stitch) and disableCtrlFlowCache (program header flag) are complementary, not interchangeable: CACHESTOP stops an in-progress recording; disableCtrlFlowCache asks host not to start/reuse CF cache. Changes: - CSE for invariant dims in backend / expr_generator / symbolic_scalar - UT for expr generator CSE behavior - Armv8-a march flag for aarch64 device compiles - Restore CACHESTOP emit in MarkValueDependDisableCache with clarifying comments Related Issues: N/A See merge request: cann/pypto!5005 | 4 months ago | |
fix(ir): Descend into symbolic scalar expr operands to keep loop-carried scalars alive Co-authored-by: seu_chang<liuchang169@huawei.com> # message auto-generated for no-merge-commit merge: !6041 merge master into master fix(ir): Descend into symbolic scalar expr operands to keep loop-carried scalars alive Created-by: seu_chang Commit-by: seu_chang Merged-by: cann-robot Description: 本 PR 修复 IR 编译链路中符号标量表达式(RawSymbolicScalar)的遍历与存活分析问题:此前循环携带标量(loop-carried scalar)的引用存在于 RawSymbolicExpression 的操作数中,活跃性(liveness)收集器不会下钻访问,导致这些标量被错误裁剪、留下悬空引用。改动为 ScalarExpr 增加通用操作数访问接口 GetOperands(),由 RawSymbolicScalar 覆写暴露其操作数,并让变量使用收集器、宿主后端控制流代码生成(ir_backend.cpp)都能识别并保留这些标量(迭代参数、if 条件、continue 携带值、返回变量),最后补充了对应的回归测试。 See merge request: cann/pypto!6041 | 2 months ago | |
feat(machine): Add yield scalar expr support for IfStmt and ForStmt Co-authored-by: gaoxingwang<camuel.gao@huawei.com> # message auto-generated for no-merge-commit merge: !5465 merge feat/if-for-yield-scalar-expr into master feat(machine): Add yield scalar expr support for IfStmt and ForStmt Created-by: gaoxingwang Commit-by: gaoxingwang Merged-by: cann-robot Description: feat(machine): Add yield scalar expr support for IfStmt and ForStmt Enhance new IR control flow codegen to generate symbolic assignment for scalar yield values in IfStmt and ForStmt branches. Previously only ForStmt loopVar was registered to symbolTable; now scalar returnVars from both IfStmt and ForStmt are registered, and YieldStmt values are converted to VALUE_xxx = expr; in controlFlow cpp. Changes: - Register scalar returnVars to symbolTable in FindExprFromIfStmt and FindExprFromForStmt - Collect yield value symbols in FindExprFromIRStmt YieldStmt case - Add currentReturnVars parameter to VisitIRStmtForControlFlow for passing returnVars through recursion - Generate VALUE_xxx = expr; in controlFlow cpp for scalar YieldStmt values - Skip tensor type returnVars and yield values via ScalarType check - Add 10 UT test cases covering symbol registration, yield codegen, nested isolation, tensor skip, backward compat - Add ST test with if/else + for loop yielding constant and symbolic expression as loop bounds Related Issues: N/A See merge request: cann/pypto!5465 | 3 months ago | |
fix(codegen): Propagate parallel task exceptions instead of swallowing them Co-authored-by: anyangle<anyangle@huawei.com> # message auto-generated for no-merge-commit merge: !5266 merge compile_fix into master fix(codegen): Propagate parallel task exceptions instead of swallowing them Created-by: quadrate Commit-by: anyangle Merged-by: cann-robot Description: 1. 多线程 Codegen 确定性 Kernel 编译 Related Issue:[https://gitcode.com/cann/pypto/issues/2913](https://gitcode.com/cann/pypto/issues/2913) 2. Issue 背景:GenCode 内的 ExecuteParallelCompile 编译失败抛出 COMPILE_CODE_FAILED 被吞掉,leafDict[hash] = leaf 未执行,leafDict不完整。下游 ConstructCodeInfo → RunCompileAicoreKernelStage → RunEncodeStage 继续访问不完整的 leafDict,触发 std::unordered_map::at() 越界,抛出 F00003 RuntimeError: _Map_base::at 二次异常,掩盖了真实的编译错误 根因:codeGen在并行编译遇到错误抛出异常时,只记录日志,并不传播异常和终止剩余task,导致报错在第二现场F00003 RuntimeError: _Map_base::at处 解决方法:修改 ParallelExecuteAndWait,使其在 task 失败时记录错误、提前终止剩余 task、并在所有线程 join 后重新抛出首个 COMPILE_CODE_FAILED异常 修改前:  修改后:  See merge request: cann/pypto!5266 | 3 months ago | |
fix(codegen): Propagate parallel task exceptions instead of swallowing them Co-authored-by: anyangle<anyangle@huawei.com> # message auto-generated for no-merge-commit merge: !5266 merge compile_fix into master fix(codegen): Propagate parallel task exceptions instead of swallowing them Created-by: quadrate Commit-by: anyangle Merged-by: cann-robot Description: 1. 多线程 Codegen 确定性 Kernel 编译 Related Issue:[https://gitcode.com/cann/pypto/issues/2913](https://gitcode.com/cann/pypto/issues/2913) 2. Issue 背景:GenCode 内的 ExecuteParallelCompile 编译失败抛出 COMPILE_CODE_FAILED 被吞掉,leafDict[hash] = leaf 未执行,leafDict不完整。下游 ConstructCodeInfo → RunCompileAicoreKernelStage → RunEncodeStage 继续访问不完整的 leafDict,触发 std::unordered_map::at() 越界,抛出 F00003 RuntimeError: _Map_base::at 二次异常,掩盖了真实的编译错误 根因:codeGen在并行编译遇到错误抛出异常时,只记录日志,并不传播异常和终止剩余task,导致报错在第二现场F00003 RuntimeError: _Map_base::at处 解决方法:修改 ParallelExecuteAndWait,使其在 task 失败时记录错误、提前终止剩余 task、并在所有线程 join 后重新抛出首个 COMPILE_CODE_FAILED异常 修改前:  修改后:  See merge request: cann/pypto!5266 | 3 months ago | |
style(all): Apply additional clang-format corrections across codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4883 merge style-cpp into master style(all): Apply additional clang-format corrections across codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Apply additional clang-format corrections across codebase See merge request: cann/pypto!4883 | 4 months ago | |
style(all): Apply additional clang-format corrections across codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4883 merge style-cpp into master style(all): Apply additional clang-format corrections across codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Apply additional clang-format corrections across codebase See merge request: cann/pypto!4883 | 4 months ago |
| Files | Last commit | Last update |
|---|---|---|
| 1 month ago | ||
| 2 months ago | ||
| 1 month ago | ||
| 1 month ago | ||
| 3 months ago | ||
| 4 months ago | ||
| 2 months ago | ||
| 4 months ago | ||
| 2 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 4 months ago | ||
| 4 months ago |