| Files | Last commit | Last update |
|---|---|---|
feat(operation): Addressing precision issues Co-authored-by: yang-fulai-3<yangfulai3@huawei.com> # message auto-generated for no-merge-commit merge: !7525 merge fz2 into master feat(operation): Addressing precision issues Created-by: yangfulai Commit-by: yang-fulai-3 Merged-by: cann-robot Description: feat(operation): Addressing precision issues 更多描述信息见:[Commit Message 规范](../docs/zh/contribute/pull-request.md#commit-message) See merge request: cann/pypto!7525 | 10 days ago | |
feat(Operation): Add pypto.conv_backward_filter and its 2D implementation on A2/A3 Co-authored-by: Zehai<wangzehai3@huawei.com> Co-authored-by: hongyiliu111<liuhongyi1@huawei.com> Co-authored-by: yuxin5<yuxin5@huawei.com> Co-authored-by: xutianlong1<xutianlong1@huawei.com> Co-authored-by: zhouxuan78<zhouxuan78@huawei.com> # message auto-generated for no-merge-commit merge: !6752 merge dev into master feat(Operation): Add pypto.conv_backward_filter and its 2D implementation on A2/A3 Created-by: yuxin5 Commit-by: Zehai;yuxin5;zhouxuan78;xutianlong1;royccc;hongyiliu111 Merged-by: cann-robot Description: feat(Operation): Add pypto.conv_backward_filter and its 2D implementation on A2/A3 Add pypto.conv_backward_filter interface to compute the gradient of convolution with respect to the weight tensor, and implement its 2D support spanning the frontend interface, backend operation implementation and MTE codegen Changes: - Add pypto.conv_backward_filter frontend interface with parameter validation - Implement ConvBackwardFilter 2D backend operation and codegen - Add UT/ST test cases for the 2D implementation See merge request: cann/pypto!6752 | 29 days ago | |
refactor(interface): Remove UpdateTensorDataUsage() Co-authored-by: tsungl4<lidongsheng4@huawei.com> # message auto-generated for no-merge-commit merge: !5451 merge test_data/1 into master refactor(interface): Remove UpdateTensorDataUsage() Created-by: tsungl4 Commit-by: tsungl4 Merged-by: cann-robot Description: Remove per function importDict Related Issue: #2559 See merge request: cann/pypto!5451 | 3 months ago | |
fix(operation): Update Signbit and BitwiseShift Co-authored-by: dingsinuo<dingsinuo@huawei.com> # message auto-generated for no-merge-commit merge: !7772 merge issues into master fix(operation): Update Signbit and BitwiseShift Created-by: dingsinuo Commit-by: dingsinuo Merged-by: cann-robot Description: 删除文件中 UTF-8 BOM framework/tests/st/operation/test_case/Signbit_st_test_cases.json framework/tests/st/operation/test_case/ScatterTensor_st_test_cases.csv framework/tests/st/operation/test_case/Scatter_st_test_cases.csv 加Reduce 空输入拦截 See merge request: cann/pypto!7772 | 3 days ago | |
fix(ir): Dump attr support map Co-authored-by: zhaojunhan<zhaojunhan1@huawei.com> # message auto-generated for no-merge-commit merge: !4577 merge fix_ir_dump into master fix(ir): Dump attr support map Created-by: zhaojunhan Commit-by: zhaojunhan Merged-by: cann-robot Description: Dump operation attributes with support for map-type data. See merge request: cann/pypto!4577 | 4 months ago | |
feat(Conv): conv support L0C2Ub mix Co-authored-by: xinweiliu<xinweiliu@huawei.com> Co-authored-by: xinweiliu<liuxinwei12@huawei.com> # message auto-generated for no-merge-commit merge: !6583 merge Conv_L0C_2_UB_Mix_support into master feat(Conv): conv support L0C2Ub mix Created-by: xinweiliu Commit-by: xinweiliu Merged-by: cann-robot Description: Conv新增L0C2Ub通路mix能力 See merge request: cann/pypto!6583 | 1 month ago | |
refactor(ir): Split io_text attr dump/load and separate static/dynamic offsets Co-authored-by: Immutable01<gaoqiancheng@huawei.com> # message auto-generated for no-merge-commit merge: !6932 merge 1014_attr into master refactor(ir): Split io_text attr dump/load and separate static/dynamic offsets Created-by: Immutable01 Commit-by: Immutable01 Merged-by: cann-robot Description: refactor(ir): Split io_text attr dump/load and separate static/dynamic offsets Move the io_text attribute dump/load logic out of io_text_dumper.cpp and io_text_loader.cpp into dedicated attr files sharing a private parser base, and make assemble/view offsets round-trip unambiguous by separating their static and dynamic parts. Changes: - Split attr dump/load logic into io_text_dumper_attr.cpp and io_text_loader_attr.cpp with private header io_text_parser.h - Dump offsets as static #toOffset/#fromOffset (vector<int64_t>) and dynamic #toDynOffset/#fromDynOffset (vector<SymbolicScalar>); all-immediate dyn lists are filtered to avoid duplicate output - Apply tensor op attrs symmetrically on load via ApplyTensorOpAttrs (VIEW/SLICE -> ViewOpAttribute, ASSEMBLE/CONTRACT -> AssembleOpAttribute); legacy text carrying dynamic values under #toOffset/#fromOffset is still accepted - Remove unused OpAttribute::CollectAttrs and refresh golden .pypto snapshots for the new dump format Related Issues: #3555 See merge request: cann/pypto!6932 | 1 month ago | |
fix(conv): clamp img2col symbolic padding to valid output extent to avoid AICore exception Co-authored-by: liyouhui<liyouhui1@huawei.com> # message auto-generated for no-merge-commit merge: !7588 merge bugfix into master fix(conv): clamp img2col symbolic padding to valid output extent to avoid AICore exception Created-by: rhineriver23 Commit-by: liyouhui Merged-by: cann-robot Description: # 描述 SetImg2ColSymPadAttr中 symPaddingBottom/symPaddingRight 按“补齐整个L1 tile”计算(fullH - l1ValidH - symPadTop),未考虑tile内有效输出行/列的实际范围。当有效输出范围小于tile尺寸是padding被过度放大,Load3D依据过大的padding计算访问范围,导致越界访问,触发AICore exception。 # 修改内容 - framework/src/interface/operation/conv_operation_impl.cpp:SetImg2ColSymPadAttr新增convTileInfo参数,基于动态有效输出尺寸计算实际所需的bottom/right padding,用Min对原padding值钳位,消除过度补边。 - framework/src/interface/tileop/conv/impl/conv_load2d_load3d_impl.h:TLoad3D增加防御性检查,根据fmap尺寸与padding/dilation/stride推导有效输出M维总数,mPos完全落在有效输出区域之外时直接返回,避免越界访问。 See merge request: cann/pypto!7588 | 9 days ago | |
feat(Operation): Add pypto.conv_backward_filter and its 2D implementation on A2/A3 Co-authored-by: Zehai<wangzehai3@huawei.com> Co-authored-by: hongyiliu111<liuhongyi1@huawei.com> Co-authored-by: yuxin5<yuxin5@huawei.com> Co-authored-by: xutianlong1<xutianlong1@huawei.com> Co-authored-by: zhouxuan78<zhouxuan78@huawei.com> # message auto-generated for no-merge-commit merge: !6752 merge dev into master feat(Operation): Add pypto.conv_backward_filter and its 2D implementation on A2/A3 Created-by: yuxin5 Commit-by: Zehai;yuxin5;zhouxuan78;xutianlong1;royccc;hongyiliu111 Merged-by: cann-robot Description: feat(Operation): Add pypto.conv_backward_filter and its 2D implementation on A2/A3 Add pypto.conv_backward_filter interface to compute the gradient of convolution with respect to the weight tensor, and implement its 2D support spanning the frontend interface, backend operation implementation and MTE codegen Changes: - Add pypto.conv_backward_filter frontend interface with parameter validation - Implement ConvBackwardFilter 2D backend operation and codegen - Add UT/ST test cases for the 2D implementation See merge request: cann/pypto!6752 | 29 days ago | |
feat(Operation): Add pypto.conv_backward_filter and its 2D implementation on A2/A3 Co-authored-by: Zehai<wangzehai3@huawei.com> Co-authored-by: hongyiliu111<liuhongyi1@huawei.com> Co-authored-by: yuxin5<yuxin5@huawei.com> Co-authored-by: xutianlong1<xutianlong1@huawei.com> Co-authored-by: zhouxuan78<zhouxuan78@huawei.com> # message auto-generated for no-merge-commit merge: !6752 merge dev into master feat(Operation): Add pypto.conv_backward_filter and its 2D implementation on A2/A3 Created-by: yuxin5 Commit-by: Zehai;yuxin5;zhouxuan78;xutianlong1;royccc;hongyiliu111 Merged-by: cann-robot Description: feat(Operation): Add pypto.conv_backward_filter and its 2D implementation on A2/A3 Add pypto.conv_backward_filter interface to compute the gradient of convolution with respect to the weight tensor, and implement its 2D support spanning the frontend interface, backend operation implementation and MTE codegen Changes: - Add pypto.conv_backward_filter frontend interface with parameter validation - Implement ConvBackwardFilter 2D backend operation and codegen - Add UT/ST test cases for the 2D implementation See merge request: cann/pypto!6752 | 29 days ago | |
feat(operation|pass)Adapt pre-stage quant for Kirin9030/KirinX90 Co-authored-by: fangrui_32<fangrui30@h-partners.com> # message auto-generated for no-merge-commit merge: !7180 merge master into master feat(operation|pass)Adapt pre-stage quant for Kirin9030/KirinX90 Created-by: fangrui_32 Commit-by: fangrui_32 Merged-by: cann-robot Description: Related issues:[[Requirement|需求建议]: Adapt pre-stage quant for Kirin9030/KirinX90](https://gitcode.com/cann/pypto/issues/3663) See merge request: cann/pypto!7180 | 3 days ago | |
fix(Operation): modify cleancode Co-authored-by: chenbl<chenbinglin7@huawei.com> # message auto-generated for no-merge-commit merge: !5748 merge fix/docs into master fix(Operation): modify cleancode Created-by: chenbl Commit-by: chenbl Merged-by: cann-robot Description: cleancode修改: - 拆分过长的 Operation 和 TileOp 文件 - 重构过长函数并提取重复代码 - 使用公共常量替换 Magic Number - 修复报错日志的拼写和语法问题 - 补充报错日志中的实际参数值 - 删除自定义调试打印 - 清理无用变量和重复实现 - 迁移并补充 Vector Operation 单元测试 See merge request: cann/pypto!5748 | 2 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 | |
refactor(quant_mx): Remove the redundant scale reshape Co-authored-by: bynshard<zhangbingshuai@huawei.com> # message auto-generated for no-merge-commit merge: !7609 merge mxquant-reshape into master refactor(quant_mx): Remove the redundant scale reshape Created-by: bynshard Commit-by: bynshard Merged-by: cann-robot Description: QuantMX 原先先按内部存储形状生成 scale,再插入一个 Reshape,将 scale 转成 scaled_matmul 所需的尾维为 2 的形状。本次修改让尾轴和次尾轴量化都直接生成这个形状,省去 QuantMX 自动插入的 Reshape,保持对外的 scale 形状和值不变。 当 scale 的所有消费者都直接写回 GM,且目标布局支持紧凑写入时,编译器给 COPY_OUT 打标,codegen 按标记将两个 scale 元素成对写出。如果 scale 还接了显式 reshape,或写回目标是尾轴更宽的 GM 切片,QuantMX 就在 UB 中生成带 padding 的布局,供后续操作按普通布局读取。 See merge request: cann/pypto!7609 | 3 days ago | |
fix(pass): Avoid null pointer errors. Co-authored-by: wangqun23<wangqun23@huawei.com> # message auto-generated for no-merge-commit merge: !7445 merge master into master fix(pass): Avoid null pointer errors. Created-by: wangqun23 Commit-by: wangqun23 Merged-by: cann-robot Description: ## 背景 由于框架的修改,在Token开启的情况下,存在与Assemble输出同RawMagic的Incast不与其他op相连接的情况,目前仅限于Incast存在类似情况,即Incast游离在其他连接关系之外。导致ReplaceTensor里的map的value存储空指针,后续使用空指针导致段错误。 ## 方案 针对map可能访问不存在的key做补充和校验。 对可能的空指针使用新增校验。 Related Issue: [#3806](https://gitcode.com/cann/pypto/issues/3806) See merge request: cann/pypto!7445 | 17 days ago | |
refactor(quant_mx): Remove the redundant scale reshape Co-authored-by: bynshard<zhangbingshuai@huawei.com> # message auto-generated for no-merge-commit merge: !7609 merge mxquant-reshape into master refactor(quant_mx): Remove the redundant scale reshape Created-by: bynshard Commit-by: bynshard Merged-by: cann-robot Description: QuantMX 原先先按内部存储形状生成 scale,再插入一个 Reshape,将 scale 转成 scaled_matmul 所需的尾维为 2 的形状。本次修改让尾轴和次尾轴量化都直接生成这个形状,省去 QuantMX 自动插入的 Reshape,保持对外的 scale 形状和值不变。 当 scale 的所有消费者都直接写回 GM,且目标布局支持紧凑写入时,编译器给 COPY_OUT 打标,codegen 按标记将两个 scale 元素成对写出。如果 scale 还接了显式 reshape,或写回目标是尾轴更宽的 GM 切片,QuantMX 就在 UB 中生成带 padding 的布局,供后续操作按普通布局读取。 See merge request: cann/pypto!7609 | 3 days ago | |
feat(Operation): Add DivMod implementation Co-authored-by: YuYangYang_<yuyangyang13@huawei.com> # message auto-generated for no-merge-commit merge: !7561 merge DivMod into master feat(Operation): Add DivMod implementation Created-by: YuYangYang_ Commit-by: YuYangYang_ Merged-by: cann-robot Description: DivMod 简介: - 支持 dtype:int8/uint8/int16/uint16/int32(A3/A5),int64/uint32/uint64(仅 A5) - 除数为 0 属于未定义行为 - 本次同步补齐 Tensor API、tileop、NPU codegen、interpreter golden、C++/Python UT/ST 及 API 文档 - ST 覆盖 1D~4D、广播、非对齐尾块、A3/A5 不同实现路径等关键场景 [#3842](https://gitcode.com/cann/pypto/issues/3842) See merge request: cann/pypto!7561 | 10 days ago | |
refactor(quant_mx): Remove the redundant scale reshape Co-authored-by: bynshard<zhangbingshuai@huawei.com> # message auto-generated for no-merge-commit merge: !7609 merge mxquant-reshape into master refactor(quant_mx): Remove the redundant scale reshape Created-by: bynshard Commit-by: bynshard Merged-by: cann-robot Description: QuantMX 原先先按内部存储形状生成 scale,再插入一个 Reshape,将 scale 转成 scaled_matmul 所需的尾维为 2 的形状。本次修改让尾轴和次尾轴量化都直接生成这个形状,省去 QuantMX 自动插入的 Reshape,保持对外的 scale 形状和值不变。 当 scale 的所有消费者都直接写回 GM,且目标布局支持紧凑写入时,编译器给 COPY_OUT 打标,codegen 按标记将两个 scale 元素成对写出。如果 scale 还接了显式 reshape,或写回目标是尾轴更宽的 GM 切片,QuantMX 就在 UB 中生成带 padding 的布局,供后续操作按普通布局读取。 See merge request: cann/pypto!7609 | 3 days ago | |
feat(ir): Harden io_text resume for fusion kernels Co-authored-by: HuYiSheng01<hys123456aaa@163.com> # message auto-generated for no-merge-commit merge: !7820 merge feat/io_text_resume_ab_issue4 into master feat(ir): Harden io_text resume for fusion kernels Created-by: HuYiSheng01 Commit-by: HuYiSheng01 Merged-by: cann-robot Description: ## 一、背景 融合算子(moe、attention 等)在 checkpoint → load → resume 场景下出现三类问题: 1. dumper 会为掩码元素写出 inf/nan 浮点字面量,而 loader 的词法规则只接受十进制/科学计数法,导致 **load 直接失败**; 2. 文本加载时创建的 Operation 对象没有挂到宿主 function 的 operations_ 中,后续 pass 重建语句后,tensor 的 producer/consumer 集合可能保留悬空指针,触发 **CompareOp use-after-free**; 3. resume 一致性校验缺少“与历史编号无关”的文本比较能力,@id、!opid、派生名后缀、#memId 等历史相关标签会导致同一结构文本不相等,难以判断 resume 是否真正一致。 本 PR 对应其中的 A(非有限字面量)、B(文本 op 所有权)以及 ISSUE-4 的比较接口,不包含 tile scope、token/alias/inplace 等后续改动。 ## 二、改动 ### A. 非有限浮点字面量(io_text_loader.cpp / io_text_dumper_attr.cpp) - loader 的 TokFloat 正则支持 inf、-inf、+inf、nan(含符号); - dumper 仅在 std::isfinite(value) 为真时补 .0,避免把 inf/nan 写成 inf.0 之类不可回读的形式。 效果:dumper 写出的非有限字面量可以被 loader 原样读回,round-trip 稳定。 ### B. 文本 op 所有权(function.h / io_text_loader.cpp) - Function 新增 AddOperationPtr(std::shared_ptr<Operation>); - ParseStmtV0TensorOp 创建 Operation 后立即挂到 hostFunc_。 效果:文本加载的 op 生命周期由宿主 function 持有,pass 重建语句时不再留下悬空 producer/consumer,消除 CompareOp use-after-free。 ### ISSUE-4 比较接口(python/pypto/ir.py) 新增两个公开接口: - ir.normalize_ir_text(text):仅归一化历史相关标签 - @id、!opid 重编号; - 派生名数字后缀(如 f_1 / f_9、%x_0_1)折叠; - #memId(n) 归一为 #memId(*); - 不改结构、不改属性值。 - ir.text_equal(lhs, rhs):对两份文本先归一化再比较。 推荐用法: 用 ir.text_equal(direct_text, resume_text) 替换 ==; 说明:该接口用于 resume/round-trip 的一致性判定,不改变 IR 本身的编号生成规则(ISSUE-4 的编号策略仍按既定方案延后)。 See merge request: cann/pypto!7820 | 1 day ago | |
feat(ops): Add NaN propagation control to extrema operators Co-authored-by: bynshard<zhangbingshuai@huawei.com> # message auto-generated for no-merge-commit merge: !7435 merge codex/propagate-nan-current into master feat(ops): Add NaN propagation control to extrema operators Created-by: bynshard Commit-by: bynshard Merged-by: cann-robot Description: 为 amax、 amin、argmax、argmin、maximum 和 minimum 增加编译期参数 propagate_nan,默认值为 True。 默认模式及显式 True 沿用原生实现,包括索引选择行为、类型转换和临时空间。浮点输入显式指定 False 时忽略 NaN,全 NaN 的数值规约返回 NaN,索引规约返回 0。 See merge request: cann/pypto!7435 | 9 days ago | |
refactor(pypto_pro): address codecheck warnings Co-authored-by: fa<yangzf993@163.com> # message auto-generated for no-merge-commit merge: !7683 merge bugfix into master refactor(pypto_pro): address codecheck warnings Created-by: fafafafafa Commit-by: fa Merged-by: cann-robot Description: PR 应该避免没有描述信息,描述信息的最重要的作用是描述修改意图,应该清晰明了。例如:标题中包含了 fix 标签,如果没有描述信息,就需要Review人员猜测PR具体修复了哪些内容,或者怀疑修改的必要性。如果PR和特定的Issue相关,可以单独包含一行 Related Issue: 放到描述信息最后。 下面是一个典型的PR描述信息: The origin issue template brings too many noise, it's not suitable for git message. eg: comments are not removed, labels are redundant as the PR tile already contains the tag. The guide gives a clear suggestion on how to write the PR body. Related Issue: #1234,#5678 更多描述信息见:[Commit Message 规范](../docs/zh/contribute/pull-request.md#commit-message) See merge request: cann/pypto!7683 | 4 days ago | |
fix(interface): Attach input tokens on tiled view contracts Co-authored-by: zhaojunhan<zhaojunhan1@huawei.com> # message auto-generated for no-merge-commit merge: !7775 merge fix_view_expand_input_tokens into master fix(interface): Attach input tokens on tiled view contracts Created-by: nanguag Commit-by: zhaojunhan Merged-by: cann-robot Description: ## 背景:修复kirin算子的特殊token连接 kirin的算子会把静态的loop展开,就是把loop里面的op重复多次。会出现读后写场景,这个写是view的输出,当前view展开时没有处理view的输入token ## 修改 读后写场景,这个写是view的输出。在对view展开时,需要把view的输入token,和contract相连接 See merge request: cann/pypto!7775 | 3 days ago | |
feat(matmul): Remove reshape from batchmatmul by direct 3D/4D tensor flow Co-authored-by: li_qingyan<liqingyan10@h-partners.com> # message auto-generated for no-merge-commit merge: !7094 merge feat/batchmatmul-remove-reshape into master feat(matmul): Remove reshape from batchmatmul by direct 3D/4D tensor flow Created-by: li_qingyan Commit-by: li_qingyan Merged-by: cann-robot Description: ## 变更说明 删除 batchmatmul 链路中的冗余 Reshape:A_MUL_B 直接接受 3D/4D 参数输入,全链路支持带 batch 轴的多维 tile。 ### 变更原因 {1,m,k} 与 {m,k} 内存布局相同,逐 batch 拆解插入的 Reshape 涉及 Pass 层做特判,耦合严重,问题高发,且会放大 TensorGraph/TileGraph 规模、增加 pass 处理量与编译耗时。 旧: View{b,m,k}→{1,m,k} → Reshape→{m,k} ─┐ View{b,k,n}→{1,k,n} → Reshape→{k,n} ─┤→ A_MUL_B(2D){m,n} → Reshape→{1,m,n} → Assemble 新: View{b,m,k}→{1,m,k} ─┐ View{b,k,n}→{1,k,n} ─┴→ A_MUL_B(3D/4D){1,m,n} → Assemble ### 方案 各层统一 batch 轴约定:shape 恒 1、offset 恒 0。修改归为三类: 1. tile/offset 在 batch 轴补 1/0,与输入同 rank(规避 LogicalTensor::View / GetViewValidShape 的 rank 硬校验) 2. GM 搬运侧 batch 轴 offset 按 stride 线性化累加进 gmOffset;L1/L0 内部保持纯 2D 语义,batch 轴 offset 恒 0 See merge request: cann/pypto!7094 | 15 days ago | |
fix(operation): Transpose 尾轴不对齐时临时空间分配错误并重构增加可读性 Co-authored-by: Crayon_112<taojianlong1@huawei.com> # message auto-generated for no-merge-commit merge: !7127 merge hotfix/transpose into master fix(operation): Transpose 尾轴不对齐时临时空间分配错误并重构增加可读性 Created-by: Crayon_112 Commit-by: Crayon_112 Merged-by: cann-robot Description: PR 应该避免没有描述信息,描述信息的最重要的作用是描述修改意图,应该清晰明了。例如:标题中包含了 fix 标签,如果没有描述信息,就需要Review人员猜测PR具体修复了哪些内容,或者怀疑修改的必要性。如果PR和特定的Issue相关,可以单独包含一行 Related Issue: 放到描述信息最后。 下面是一个典型的PR描述信息: The origin issue template brings too many noise, it's not suitable for git message. eg: comments are not removed, labels are redundant as the PR tile already contains the tag. The guide gives a clear suggestion on how to write the PR body. Related Issue: #1234,#5678 更多描述信息见:[Commit Message 规范](../docs/zh/contribute/pull-request.md#commit-message) See merge request: cann/pypto!7127 | 30 days ago | |
feat(Operation): Add pypto.conv_backward_filter and its 2D implementation on A2/A3 Co-authored-by: Zehai<wangzehai3@huawei.com> Co-authored-by: hongyiliu111<liuhongyi1@huawei.com> Co-authored-by: yuxin5<yuxin5@huawei.com> Co-authored-by: xutianlong1<xutianlong1@huawei.com> Co-authored-by: zhouxuan78<zhouxuan78@huawei.com> # message auto-generated for no-merge-commit merge: !6752 merge dev into master feat(Operation): Add pypto.conv_backward_filter and its 2D implementation on A2/A3 Created-by: yuxin5 Commit-by: Zehai;yuxin5;zhouxuan78;xutianlong1;royccc;hongyiliu111 Merged-by: cann-robot Description: feat(Operation): Add pypto.conv_backward_filter and its 2D implementation on A2/A3 Add pypto.conv_backward_filter interface to compute the gradient of convolution with respect to the weight tensor, and implement its 2D support spanning the frontend interface, backend operation implementation and MTE codegen Changes: - Add pypto.conv_backward_filter frontend interface with parameter validation - Implement ConvBackwardFilter 2D backend operation and codegen - Add UT/ST test cases for the 2D implementation See merge request: cann/pypto!6752 | 29 days ago | |
refactor(pypto_pro): address codecheck warnings Co-authored-by: fa<yangzf993@163.com> # message auto-generated for no-merge-commit merge: !7683 merge bugfix into master refactor(pypto_pro): address codecheck warnings Created-by: fafafafafa Commit-by: fa Merged-by: cann-robot Description: PR 应该避免没有描述信息,描述信息的最重要的作用是描述修改意图,应该清晰明了。例如:标题中包含了 fix 标签,如果没有描述信息,就需要Review人员猜测PR具体修复了哪些内容,或者怀疑修改的必要性。如果PR和特定的Issue相关,可以单独包含一行 Related Issue: 放到描述信息最后。 下面是一个典型的PR描述信息: The origin issue template brings too many noise, it's not suitable for git message. eg: comments are not removed, labels are redundant as the PR tile already contains the tag. The guide gives a clear suggestion on how to write the PR body. Related Issue: #1234,#5678 更多描述信息见:[Commit Message 规范](../docs/zh/contribute/pull-request.md#commit-message) See merge request: cann/pypto!7683 | 4 days ago | |
feat(Operation): Add input tile shape resolver. Co-authored-by: Immutable01<gaoqiancheng@huawei.com> # message auto-generated for no-merge-commit merge: !5126 merge 0727_viewtile into master feat(Operation): Add input tile shape resolver. Created-by: Immutable01 Commit-by: Immutable01 Merged-by: cann-robot Description: # TileShapeResolver:算子输入/输出 Tile 形状解析器 ## 1. 背景与目标 PyPTO 的 tensor-graph 算子在展开( ExpandFunction)前只携带一个 **op 级 TileShape**(描述"输出怎么切")。但算子的**每个输入/输出 tensor 实际被切成的第一刀 tile 形状**并不等于 op 级 TileShape: - 广播算子的输入要按自身 shape 做 min clamp; - reduce 算子的 reduce 轴保持 full、非 reduce 轴按 vecTile 切; - gather/scatter/sort/topk/matmul/transdata 等各有专属切法; - 输出侧 cube 算子按 CubeTile 切、transdata 输出维度与输入不同…… 下游(内存估算、调度、合轴等)需要在不真正展开的前提下,**直接从一个 Operation 推断其每个输入/输出的真实 tile 形状**。TileShapeResolver 就是提供这个能力的单例工具类。 ## 2. 整体设计 framework/src/interface/operation/tile_shape_resolver.h cpp class TileShapeResolver { public: static TileShapeResolver& Instance(); // 由 op 的 opcode + op 级 TileShape + 各 operand 自身 shape,推算第 index 个输入的真实 tile 形状 TileShape GetInputTileShape(const Operation& op, int index) const; // 由 op 的 opcode + op 级 TileShape + 各 operand 自身 shape,推算第 index 个输出的真实 tile 形状 TileShape GetOutputTileShape(const Operation& op, int index) const; private: TileShapeResolver() = default; TileShapeResolver(const TileShapeResolver&) = delete; TileShapeResolver& operator=(const TileShapeResolver&) = delete; }; - **单例 + 无状态**:所有信息从 Operation 现取,线程安全。 - **只覆盖 tensor op**:只对有 REGISTER_OPERATION_TILED_FUNC(即有 tile 展开的 tensor op)的 opcode 给出语义;tile op 不在本解析器职责内。 - **返回 TileShape**:当前只填 VecTile(cube 算子填 CubeTile),其余 sub-tile 保持默认。 ## 3. 实现侧:GetInputTileShape framework/src/interface/operation/tile_shape_resolver.cpp ### 3.1 公共辅助 | 辅助 | 作用 | |---|---| | ElementwiseInputVecTile(inShape, opVecTile) | 逐轴 min(inShape, vecTile),超出 vecTile 维数的轴保持 full。elementwise 默认。 | | VecTileAxisFull(inShape, clampShape, opVecTile, fullAxis) | 指定轴保持 full,其余轴 min(clampShape, vecTile)。用于 reduce/gather/scatter 的"轴 full"语义。 | | TransDataInputVecTile(inShape, opVecTile, group, groupAxis) | groupAxis 按 inShape/group 切,其余 elementwise。用于 TransData 系列。 | | MakeTileShapeFromVec(vec) | 把 vector<int64_t> 包成 TileShape(只设 VecTile)。 | ### 3.2 分支策略 按 opcode switch,**默认分支**为 ElementwiseInputVecTile(覆盖所有 elementwise 算子:Add/Div/Cast/Expand/Axpy/Where/OneHot/PReLU…)。特殊分支: | 类别 | opcode | 输入 tile 规则 | |---|---|---| | **轴 full 类** | OP_ROW*_SINGLE(Sum/Amax/Amin/Prod/ArgMax/ArgMin) | reduce 轴 full,其余 min。axis 取 OP_ATTR_PREFIX+"AXIS"(缺失回退 0)。 | | | OP_ROWEXPMAX / OP_ROWEXPSUM | 2-D 专用,axis=1 full,axis0 min。 | | | OP_BITSORT / OP_MRGSORT | sort 轴(OP_ATTR_PREFIX+"axis")full,其余 min。 | | | OP_ARGSORT | sort 轴 full;axis 取**裸键 "axis"**(与 ArgSortOperationTileFunc 实际读取一致,非注册声明的带前缀键)。 | | | OP_EXTRACT | 末轴 full,其余 min。 | | | OP_SORT_UB | sort 轴 full。 | | | OP_INDEX_ADD / OP_INDEX_ADD_UB | self(index 0)轴 full;src(index 1)elementwise;indices full。 | | **gather/scatter 类** | OP_GATHER | params:axis full,其余按输出轴映射 min;indices:按 axis+j 映射 min。 | | | OP_GATHER_ELEMENT | params 轴 full;indices elementwise。 | | | OP_SCATTER / OP_SCATTER_ELEMENT | self 与 idx 都按 idx.shape 在 axis full、其余 min。 | | | OP_INDEX_OUTCAST | [src, index, dst]:src/dst 轴 full、非轴 min;index(2-D)axis full,**字面 axis 0 仅当 axis!=0 时按 vecTile[0] 切**,其余非轴 full(对齐 TiledScatterUpdate)。axis 取**裸键 "axis"**。 | | | OP_INDEX_PUT | self 前导轴 full、尾部按 values 轴 min;values elementwise;其余输入按 {min(in[0], vecTile[0])}。 | | **topk** | OP_TOPK | 非轴 elementwise;axis 按 32 对齐 chunk(复刻 TopkOperationTileFunc 的 align 逻辑:maxNumValue=8192、kBlockSize=32 阈值)。 | | **where** | OP_WHERE_TT/TS/ST/SS | cond(index 0)若为 DT_UINT8 末轴按 vecTile/8 切(mask 位宽);其余 elementwise。 | | **transdata** | OP_NCHW2NC1HWC0 等 6 个 | TransDataInputVecTile,groupAxis 按输入 layout 定(NCHW 系列为 1,NCDHW 系列为 2)。 | | **pack** | OP_PACK | 输出 1-D,输入 tile = {min(in[0], ∏vecTile)}。 | | **prelu** | OP_PRELU | input elementwise;weight 取 {min(weight[0], vecTile[1])}(channel 轴)。 | | **cube matmul** | OP_A_MUL_B / A_MUL_BT / A_MULACC_B / A_MULACC_BT | A={m[0],k[0]}(transA 反转),B={k[0],n[0]}(transB 反转);MX/bias/scale 等附加输入按 Matrix::CopyInMode::DN2NZ 等属性决定 scale 的 NZ 排布与 ceil(k/64)。属性键统一用 Matrix:: 限定。 | | 其它 | OP_RANGE / OP_UNIFORM / OP_VEC_DUP / OP_CUBE_CONV_D2S / OP_CUBE_CONCAT_C | 无 tensor 输入或非 vec 切,直接返回 op 级 TileShape。 | > **属性键一致性**:解析器严格对齐各 TileFunc 实际读取的键。OP_INDEX_OUTCAST/OP_ARGSORT 用裸 "axis"(与 TileFunc 一致),OP_BITSORT/OP_MRGSORT/OP_GATHER/... 用 OP_ATTR_PREFIX+"axis",reduce 单算子用 OP_ATTR_PREFIX+"AXIS"。 ## 4. 实现侧:GetOutputTileShape 与输入侧对称,按 opcode switch,**默认分支**为 ElementwiseInputVecTile(outShape, opVecTile)(逐轴 min(outShape, vecTile))。默认分支正确的前提:① op 级 VecTile 维数 == 输出维数;② 输出按 VecTile 逐轴 elementwise 切("必须 full 的轴"在合法展开下 vecTile[fullAxis] >= shape[fullAxis],min 自然得 full,故 scatter/sort/indexadd/inplace 等无需专门分支)。 需要专门分支的输出: | opcode | 输出 tile 规则 | |---|---| | OP_A_MUL_B / A_MUL_BT / A_MULACC_B / A_MULACC_BT | 输出 C 按 CubeTile 的 L0 {m[0], n[0]} 切,clamp 到真实 {M, N}(参考 SetVecTileBasedOnUbSize)。 | | TransData 6 个 | 输出是变换后 layout(C0/N0/group),输出维数 ≠ 输入维数,op 级 VecTile 维数跟输入走,逐轴 min 对不上。Handle*Format 把**整张 dstTensor** 作为 tile op 的 oOperand(非切片 View),即每个 tile op 写整份输出,故 first-cut 输出 tile = **完整 outShape**。 | | OP_PACK | 输出 1-D 字节流:outShape[0] = inShape[0]*byte。PackOperationTileFunc 产 outputShape{ min(inShape[0], tile)*byte }(tile = ∏vecTile),故 first-cut 输出 tile = {min(outShape[0], tile*byte)},byte = BytesOf(input[0])。 | | OP_PERMUTE / OP_PERMUTE_ELEMENT | 输出轴 i ← 输入轴 perm[i],op 级 VecTile 跟输入轴序,故输出 tile = **VecTile 按 perm 重排**后逐轴 clamp 到 outShape(TiledPermuteOperation:resultTileShape = PermuteTileVector(inputTile.shape, perm))。 | | OP_TRANSPOSE_MOVEOUT / MOVEIN / VNCHWCONV | 二轴转置:输出 tile = op 级 VecTile 的 shape[0]/shape[1] 两轴**互换**后 clamp 到 outShape(TiledInnerTranspose:resultTileShape = inputTile.shape 交换 shape[0]/shape[1])。 | | OP_UNPACK | 输出 1-D:outShape[0] = inShape[0]/dstByte。UnPackOperationTileFunc 产 outputShape{ min(inShape[0], vecTile[0]) / dstByte },dstByte = BytesOf(output)。 | | OP_DEINTERLEAVE_SINGLE | 末轴减半:outShape[last] = inShape[last]/2,末轴 tile = min(outShape[last], vecTile[last]/2),其余 min(两输出同形)。 | | OP_EXTRACT | 末轴不切(full),其余 min(TiledExtract 跳过末轴)——与输入侧一致。 | | OP_BITSORT / OP_MRGSORT | sort 轴(OP_ATTR_PREFIX+"axis")不切(full),其余 min(TiledBitSort/TiledMrgSort 跳过 sort 轴)——与输入侧一致。 | | OP_GATHER_MASK_BUILDIN | 末轴按 patternMode 缩:mode 1/2 → vecTile/2,mode 3-6 → vecTile/4,其余 vecTile;其它轴 min。 | | OP_CUBE_CONV_D2S / OP_CUBE_CONCAT_C | OpCalcType::CONV 且无注册 TileFunc,不被 ExpandFunction 展开,tiling 由 ConvTile 驱动——**不在本解析器职责内**,返回 op 级 TileShape 作安全占位(tensor-graph 路径不会调到)。 | **走默认分支的代表性类目**(已逐一核对 TileFunc 源码): - **elementwise**:Add/Div/Cast/Expand/Axpy/Where/OneHot/PReLU … - **reduction**:tensor-graph reduce 算子恒把 reduce 轴置为 dim 1(ProcessResultShape 把 keepDim=false 的 squeeze 放到**独立的 OP_RESHAPE** 里做,而 OP_RESHAPE 不是 tensor op),故 min(1, vecTile[axis]) = 1,默认分支正确——**keepDim=false 不是缺口**。 - **gather/scatter/topk**:op 级 VecTile 维数已与输出维数对齐,默认 min 即可。 - **cumsum/cumprod/interleave/pad/fillpad/quantize/dequantize/expand_exp_dif**:输出按 min(outShape, vecTile) 逐轴切,默认即可。 - **生成型 1-D 算子 OP_RANGE / OP_UNIFORM / OP_VEC_DUP**:TiledRange/TiledUniformBuildIn/TiledFull 各自按 vecTile[0] 切 1-D 输出,正是 min(outShape[0], vecTile[0])——**归入默认分支**(原先误放到"返回 op 级"分支,已修正)。 ## 5. 测试方案 framework/tests/ut/interface/src/operation/test_tile_shape_resolver.cpp **核心思想**:用 DSL 在 FUNCTION{} 里建**单算子** tensor graph,让算子吃 TileShape::Current();展开前用 resolver 算"期望"的 per-input/per-output tile,展开后扫 tile op 找首个消费/产出对应 RawTensor 的 View 取"实际"first-cut tile,逐 operand 比对。 **harness 关键点**: 1. **输出 Tensor 提到 FUNCTION{} 外持有**——其底层 LogicalTensor 因此存活,可被 harness 捕获身份。 2. **oOperand 补挂**:本 harness 语境下 tensor-graph 算子的 oOperand 在展开前还是空的(输出要等展开流水线里才挂上)。harness 在 op->GetOOperands() 为空时把 fixture 提供的输出 LogicalTensor 挂上去——这正是 ExpandFunction/TileFunc 实际消费的输出;inplace 算子(oOperand 已非空 {self})则不动。 3. **展开失败显式断言**:ASSERT_NE(expandFunction.RunOnFunction(*fn), Status::FAILED),避免展开失败被后续扫描误判为 tile 形状不匹配。 4. **RawTensor 身份匹配**:LogicalTensor::View 共享底层 RawTensor,故输入/输出身份用 GetRawTensor().get() 唯一标识。 **覆盖 26 个 representative fixture**:elementwise(Div/Where/OneHot/Cast/Expand/Axpy)、permute(Permute_AxisSwap,**判别性** fixture:默认分支会产 {2,4,8},正确分支产 {4,2,8})、gather/scatter(Gather/Scatter/GatherElements/ScatterElement)、index(IndexAdd/IndexAddUb)、reduce 单算子(Sum/Amax/Amin/Prod/ArgMax/ArgMin 6 个)、rowexp(RowExpMax/RowExpSum,手动构建)、sort(MrgSort/BitSort/Extract)、topk(TopK 双输出)、prelu。多输出用 std::tie,inplace 用 self 作输出,手动构建用外部 Tensor out。 See merge request: cann/pypto!5126 | 3 months ago | |
fix(frontend): Reject unsupported syntax and dynamic tile shapes clearly Co-authored-by: HuYiSheng01<hys123456aaa@163.com> # message auto-generated for no-merge-commit merge: !7532 merge fix/syntax-param-validation into master fix(frontend): Reject unsupported syntax and dynamic tile shapes clearly Created-by: HuYiSheng01 Commit-by: HuYiSheng01 Merged-by: cann-robot Description: ## 背景 语法参数易用性测试(114 条 Case_SyntaxParam.json)反馈:几类**本就不支持**的写法在失败时抛出的 是内部实现细节(AttributeError / 内部错误码 / pybind 签名 dump),而不是可操作的提示: | 用例 | 写法 | 修复前报错 | |---|---|---| | SYN-N03 | match-case | 'Parser' object has no attribute 'visit_match' | | SYN-N04 | 海象表达式 := | 'Parser' object has no attribute 'visit_named_expr' | | SYN-N22 | set_vec_tile_shapes(动态维) | FE_INNER_ERROR concrete value is not valid | | — | set_cube_tile_shapes(动态维) | pybind incompatible constructor arguments(签名 dump) | 这些写法全部不受支持,因此本 PR **只改诊断信息**,不引入新能力。 ## 改动 - python/pypto/pil/parser.py - 新增 visit_match:match-case 抛 SyntaxError: Unsupported syntax <ast.Match>: match statements are not supported; use if/elif - 新增 visit_named_expr:海象表达式抛 SyntaxError: ... assignment expressions (:=) are not supported; assign before use - visit() 的 visitor 查找补 getattr(..., None) 默认值——修复“未支持语法节点抛 AttributeError 而非 SyntaxError”的根因(原 if visitor is None 分支是不可达死代码) - python/pypto/_controller.py - 新增 _concrete_tile_dims():set_vec_tile_shapes / set_cube_tile_shapes 统一校验 - 非具体 SymbolicScalar → TypeError: tile shape dimension N must be concrete at trace time, got SymbolicScalar; tile shapes drive static tiling and cannot be dynamic - 具体符号量(如 SymbolicScalar(16))与 int 保持放行 - python/tests/ut/ir/test_parser.py - 新增 4 个用例:match 拒绝、walrus 拒绝、vec tile 动态维拒绝(含具体符号量放行的正向断言)、cube tile 动态维拒绝 ## 验证 - pytest python/tests/ut/ir/test_parser.py python/tests/ut/ir/test_pil.py → **114 passed** - pre-commit run --files <改动文件> → 全部 hook 通过 - 手工验证:while/for 等既有语法不受影响;set_vec_tile_shapes(SymbolicScalar(16), 16) 正常 See merge request: cann/pypto!7532 | 11 days ago |
| Files | Last commit | Last update |
|---|---|---|
| 10 days ago | ||
| 29 days ago | ||
| 3 months ago | ||
| 3 days ago | ||
| 4 months ago | ||
| 1 month ago | ||
| 1 month ago | ||
| 9 days ago | ||
| 29 days ago | ||
| 29 days ago | ||
| 3 days ago | ||
| 2 months ago | ||
| 4 months ago | ||
| 3 days ago | ||
| 17 days ago | ||
| 3 days ago | ||
| 10 days ago | ||
| 3 days ago | ||
| 1 day ago | ||
| 9 days ago | ||
| 4 days ago | ||
| 3 days ago | ||
| 15 days ago | ||
| 30 days ago | ||
| 29 days ago | ||
| 4 days ago | ||
| 3 months ago | ||
| 11 days ago |