| Files | Last commit | Last update |
|---|---|---|
fix(machine): Use PyptoRtError for Python runtime errors Co-authored-by: anyangle<anyangle@huawei.com> # message auto-generated for no-merge-commit merge: !7627 merge error_code into master fix(machine): Use PyptoRtError for Python runtime errors Created-by: quadrate Commit-by: anyangle Merged-by: cann-robot Description: 修复 Machine 相关 Python 接口直接抛出原生异常、报错信息缺少组件错误码的问题。 See merge request: cann/pypto!7627 | 10 days ago | |
fix(exported_custom_op): Annotate output types and discover pypto nodes in nested onnx graphs Co-authored-by: Nikita Larichev<nikita.larichev@h-partners.com> # message auto-generated for no-merge-commit merge: !6848 merge prototype/nested-graph-discovery-3502 into master fix(exported_custom_op): Annotate output types and discover pypto nodes in nested onnx graphs Created-by: Nikita17 Commit-by: Nikita Larichev Merged-by: cann-robot Description: Fixes #3502. The filed defect is one of four seams that break the export of a scripted model with a pypto op inside a conditional: 1. **Root-only discovery.** find_pypto_nodes returns **0** on a nested model before and **1** after; zero nodes means no .so, so atc fails with E13010. Still root-only at node_reader.py:44 on master. 2. **onnx.checker rejects the nested export** — the synthesized output declares no type. 3. **A second root-only scan** in the GE standard-domain rewrite, leaving 2 empty-domain nodes in the subgraphs — the GE mixed-domain failure condition. 4. **Silently skipped opset stamping**, masked because torch writes ('pypto', 1) and our default is also 1. ## Why seam 2 needs the whole type Torch stamps the root output's type from the trace, so flat exports were always complete. Nested, it becomes a subgraph output nothing stamps, and the model output's type is merged from the If branch types — where a standard-op branch supplies the shape and no element type, so neither half suffices alone. Both nested topologies fail on the base commit. The annotation reads the op's own infer funcs, asking infer_shape twice under dynamic_axes and declaring only the dimensions that hold still. ## Changes 17 files, +1385 / -84. Four production files: - onnx/node_reader.py — one shared walk, iter_all_onnx_nodes, recursing on **attribute type** rather than op_type, so it covers containers nobody has enumerated yet. - onnx/export.py — annotate each output from the op's own infer funcs; warn rather than raise when an operand defeats it. - common/discovery.py and export/onnx_export.py — reuse that walk instead of a second root-only scan. - A demo at examples/03_advanced/exported_custom_op_litenpu/onnx/nested_control_flow/, shaped if A then add else if B then sub else mul. ## Verification of the exported behaviour A 6-topology by 2-axes matrix exports under onnx.checker — flat through depth 3, all-pypto branches included, static and dynamic_axes: **12 of 12 pass**, discovered-node count correct in every cell, nested cells failing on the base commit. Both UT suites pass with nothing lost by name: extension 339 to 342, tools 275 unchanged. On a 910B3 box with CANN 9.2.0, through a fresh build_ci.py install of this tip: the demo reaches ATC run success, markers balanced 3 of 3, .omc 62,450 bytes, and GE dispatches all 3 ops from below the root graph, 2 of them two levels down. The flat add floor still passes. A 3-cell A/B there shows GE never reads the declared shape: it is declared for onnx.checker, which gates whether a file is written. Related Issues: [#3502](https://gitcode.com/cann/pypto/issues/3502) See merge request: cann/pypto!6848 | 18 days ago | |
refactor(frontend): Keep new logical tensors on for jit Co-authored-by: zhaojunhan<zhaojunhan1@huawei.com> # message auto-generated for no-merge-commit merge: !7718 merge jit_keep_new_logical_tensor into master refactor(frontend): Keep new logical tensors on for jit Created-by: nanguag Commit-by: zhaojunhan Merged-by: cann-robot Description: @pypto.frontend.jit 不再接受 create_new_logical_tensor。调用方不能通过 jit 参数把 assemble 新 logical tensor 开关关掉。 JitCallableWrapper.compile_new 仍保留该参数,默认 True。@jit 的执行路径经 compile() 进入 compile_new,因此固定开启。需要关闭时直接调用 compile_new(..., create_new_logical_tensor=False)。 compile_new_ir 和 pil.compile 的参数没有改,其它调用方仍可自行传入。 同步去掉测试里已经无效的 @jit(create_new_logical_tensor=True)。 See merge request: cann/pypto!7718 | 6 days 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 | 10 days ago | |
fix(pil): Report undefined symbolic branch values Co-authored-by: zhaojunhan<zhaojunhan1@huawei.com> # message auto-generated for no-merge-commit merge: !7711 merge fix_config_replay_undefined_branch into master fix(pil): Report undefined symbolic branch values Created-by: nanguag Commit-by: zhaojunhan Merged-by: cann-robot Description: ### 问题1 symbolic if 的变量只在一侧分支定义时,若分支后使用该变量,编译可能发生段错误;若变量没有被使用,则应允许编译。 ##### 修复方案: PIL 构建 symbolic if 时,会收集两个分支的同名变量并生成合并后的 IR 变量。现在如果发现变量在一侧有值、另一侧为 NoneType,就将其在 Python 作用域中的值设为 _Poison,表示“分支结束后可能未定义”。 _Poison 不会在创建 if 时立即报错。只有后续代码对该变量做运算、索引或属性访问时,才报出变量名;因此分支内定义但之后未使用的变量可以正常编译。 对于嵌套 if 和循环,构建 IR 时仍让这个变量以空值占位,并在分支或循环结束后保留 _Poison 标记,避免经过一层控制流就丢失未定义状态。 ### 问题2: ApplyConfigOps 遇到已生成的后端 Function 时直接复用,保留原有配置。 See merge request: cann/pypto!7711 | 6 days ago | |
refactor(ir): drop the unused INDEX dtype Co-authored-by: HuYiSheng01<hys123456aaa@163.com> # message auto-generated for no-merge-commit merge: !7713 merge feat/io_text_drop_index_dtype into master refactor(ir): drop the unused INDEX dtype Created-by: HuYiSheng01 Commit-by: HuYiSheng01 Merged-by: cann-robot Description: ## 一、背景 DataType::INDEX(kIndexCode = 0x15)是历史上为"索引型 64 位整数"保留的占位类型,实际语义与 INT64 完全重复: - 与 INT64 共用同一个 C 类型串:DataType::GetDataTypeCTypeStringDict() 里同时有 {kInt64Code, "int64_t"} 和 {kIndexCode, "int64_t"}; - BiMap 的反查是 str2typeDict[s] = i(后写覆盖),导致 Find("int64_t") 返回的是 INDEX 而不是 INT64; - 为此在文本 load 和 kwarg 读取侧被迫加了特判: - io_text_loader.cpp 的 TryDTypeFromCTypeString(text, preferInt64)(pro/v0 门控); - AnyCastFromIR<DataType> 里的 if (text == "int64_t") return kInt64Code;; - 反向不唯一还带出另一个坑:{kHf4Code, "unknown"} 使 "unknown" 反查到 HF4。 评审确认 INDEX 已无真实使用点(所有出现都是"等价于 INT64"的类型标注),因此整体删除。 ## 二、改动 ### 1)dtype 定义(framework/include/core/dtype.h) - 删除 kIndexCode、DataType::INDEX 声明与定义; - 删除 BiMap 中的 {kIndexCode, IR_KW_TYPE_INT64}(反查恢复唯一,"int64_t" → INT64); - 删除 GetBit() 的 case kIndexCode、ToString() 的 "index" 分支、DTypeToString() 的 "INDEX" 分支。 ### 2)结构性去重(structural_hash.cpp / structural_equal.cpp) - 删除 CanonicalizeForSyntaxScalarDtype() / AreForSyntaxScalarDtypesEquivalent(); - 删除仅为该归一化存在的上下文机制:fieldNameStack_、IsLoopVarFieldContext()、IsConstIntTypeContext(); - structural_hash 的 nodeTypeStack_ 一并移除(仅该归一化使用);structural_equal 保留 nodeTypeStack_(assert 模式错误路径仍在用)。 ### 3)消费侧去掉冗余判断 - scalar_expr_ops.h:删除 INDEX↔INT64 免 Cast 分支; - atomic.cpp / sync.cpp / ptr_ops.cpp:dtype_.IsInt() || == INDEX → dtype_.IsInt(); - debug_ops.cpp:删除 IsPrintfIndexType() 及 6 处引用,同步精简报错文案; - backend_cce_ops.cpp / backend_cce_vf_ops.cpp / backend_cce_block_out_ops.cpp:删除 == INDEX 分支与注释里的 INDEX 说明。 ### 4)Python 侧 - bindings/ir/ir.cpp:删除 DataType.INDEX 只读属性; - python/pypto/ir.py:删除 INDEX = DataType.INDEX 别名,tuple_get_item() 内部改用 DataType.INT64; - python/pypto_pro/ir/op/debug_ops.py:删除 _is_index_dtype() 及其引用; - python/pypto_pro/language/parser/_gemm_lowering.py:类型校验改为 dtype.is_int(); - python/pypto_pro/runtime/jit.py:删除 (DataType.INDEX, "int64") 与 str(DataType.INDEX): ctypes.c_int64(INT64 已有对应项)。 ### 5)测试 - 14 个 Python 用例文件:ir.INDEX / DataType.INDEX → INT64; - 18 个 C++ UT 文件:DataType::INDEX → DataType::INT64; - 删除只验证"INDEX 存在"的用例: - test_structural_equal_ext.cpp:TestLoopVarInt64IndexNotEquivalent、TestConstIntTypeInt64IndexNotEquivalent; - test_dtype.py:test_limits_of_index_matches_int64; - test_scalar_range.py:test_explicit_legacy_index_dtype_is_preserved; - test_backend_cce_vf_ops.cpp:删除重复的 IndexVal 用例,测试更名为 MulsAcceptsInt64ScalarConvertedToSrcType。 ### 6)文档 - docs/zh|en/.../basic_data_structures/DataType.md:删除 static const DataType INDEX; 行(中英同步,保持原 CRLF 行尾)。 ## 三、行为变化(对外可见) | 场景 | 改动前 | 改动后 | |---|---|---| | GetDataTypeCTypeStringDict().Find("int64_t") | INDEX | INT64 | | v0 文本 incast(int64_t %a) 的 dtype | INDEX | INT64 | | DataType.INDEX / ir.INDEX | 存在 | **不存在**(调用方需改用 INT64) | | str(DataType.INDEX) | "index" | 类型已删除 | | structural hash/equal 的 INT64≡INDEX 归一化 | 存在 | 不再需要(两者本就是一个类型) | | debug.printf/assert 的 index 标量 | 单独归类 | 按 INT64 处理(行为等价) | **兼容性**:IR 文本不变(int64_t 前后一致);不涉及序列化格式;只影响直接使用 DataType.INDEX 的 C++/Python 调用点,本 PR 已全部迁移。 See merge request: cann/pypto!7713 | 6 days ago | |
feat(pypto): add __version__ for package introspection Co-authored-by: HuYiSheng01<hys123456aaa@163.com> # message auto-generated for no-merge-commit merge: !6413 merge master into master feat(pypto): add __version__ for package introspection Created-by: HuYiSheng01 Commit-by: HuYiSheng01 Merged-by: cann-robot Description: 问题 pypto 包未定义 __version__ 属性,访问 pypto.__version__ 直接抛 AttributeError。开发者只能通过 pip show pypto 绕路获取版本号,影响诊断效率。 修复 在 python/pypto/__init__.py 的包级属性区定义 __version__,通过 importlib.metadata.version("pypto") 动态获取安装版本号,含安全降级。风格与 torch、numpy 等主流包对齐:__version__ 返回 str。 Related Issue: #3325 See merge request: cann/pypto!6413 | 2 months ago | |
fix(build_ci): auto-derive job_num from CPU count and cgroup memory Co-authored-by: chen_chenn<chenchen167@huawei.com> # message auto-generated for no-merge-commit merge: !5721 merge fix_build_ci_job_num into master fix(build_ci): auto-derive job_num from CPU count and cgroup memory Created-by: chen_chenn Commit-by: chen_chenn Merged-by: cann-robot Description: 修复 1. build_ci默认并发度过高导致高核低内存环境编译OOM 2. [文档] 编译(pip install .)未说明内存/并行度要求,默认并行在 32Gi 内存仍 OOM(exit 137) See merge request: cann/pypto!5721 | 3 months ago | |
feat(pass): Gate VF cluster fusion on unroll branch id Co-authored-by: Catherie<mayuan33@huawei.com> # message auto-generated for no-merge-commit merge: !7693 merge feat/vf-unroll-branch-gating into master feat(pass): Gate VF cluster fusion on unroll branch id Created-by: Catherie Commit-by: Catherie Merged-by: cann-robot Description: ## 背景 跨 unroll 分支的 VF 融合会让簇闸门同时持有全部分支的输入链,顺序驻留峰值被推过片上池上限,触发本可避免的 spill。本 PR 为 op 标注一个调度提示属性(unroll 分支号),并据此门控 VF 簇的形成。 ## 修改点 - 前端(pypto.loop / loop_unroll / static_for)在分发每个编译期循环体拷贝时,经新增的 SetUnrollBranchId / GetUnrollBranchId 绑定分配新的 unroll 分支号;循环退出时恢复外层分支号(嵌套循环保持外层分支) - Function::AddRawOperation 在分支上下文激活时为新建 op 盖章 UNROLL_BRANCH_ID 属性;ExpandFunction 将该属性继承到展开产生的 tile op - VFFusionClusterIdentify 在 consumer-merge 与 cluster-merge 两条合并路径上拒绝跨不同分支号的融合;未展开循环内记录的 op(无分支号,-1)视为通配,不受限 - 该属性是纯调度提示,不参与 CommonOperationEliminate 等价哈希,并在 op JSON dump 中提为一等字段 unrollBand 便于排查 - 测试:新增 6 个 C++ UT 用例(盖章、簇分支号分类、两条门控路径、通配融合)与 4 个 Python UT 用例(TLS 回读、循环 band 生命周期、嵌套循环恢复外层 band、loop_unroll 每次分发独立 band) See merge request: cann/pypto!7693 | 8 days ago | |
feat(pass): Gate VF cluster fusion on unroll branch id Co-authored-by: Catherie<mayuan33@huawei.com> # message auto-generated for no-merge-commit merge: !7693 merge feat/vf-unroll-branch-gating into master feat(pass): Gate VF cluster fusion on unroll branch id Created-by: Catherie Commit-by: Catherie Merged-by: cann-robot Description: ## 背景 跨 unroll 分支的 VF 融合会让簇闸门同时持有全部分支的输入链,顺序驻留峰值被推过片上池上限,触发本可避免的 spill。本 PR 为 op 标注一个调度提示属性(unroll 分支号),并据此门控 VF 簇的形成。 ## 修改点 - 前端(pypto.loop / loop_unroll / static_for)在分发每个编译期循环体拷贝时,经新增的 SetUnrollBranchId / GetUnrollBranchId 绑定分配新的 unroll 分支号;循环退出时恢复外层分支号(嵌套循环保持外层分支) - Function::AddRawOperation 在分支上下文激活时为新建 op 盖章 UNROLL_BRANCH_ID 属性;ExpandFunction 将该属性继承到展开产生的 tile op - VFFusionClusterIdentify 在 consumer-merge 与 cluster-merge 两条合并路径上拒绝跨不同分支号的融合;未展开循环内记录的 op(无分支号,-1)视为通配,不受限 - 该属性是纯调度提示,不参与 CommonOperationEliminate 等价哈希,并在 op JSON dump 中提为一等字段 unrollBand 便于排查 - 测试:新增 6 个 C++ UT 用例(盖章、簇分支号分类、两条门控路径、通配融合)与 4 个 Python UT 用例(TLS 回读、循环 band 生命周期、嵌套循环恢复外层 band、loop_unroll 每次分发独立 band) See merge request: cann/pypto!7693 | 8 days ago | |
fix(interface): Unify PYPTO log macros and add level check Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !3118 merge pypto_log into master fix(interface): Unify PYPTO log macros and add level check Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: 1. 修复通用日志接口 缺少日志级别检查的问题 2. 重构PYPTO_LOG宏,减少重复代码 3. 补充python前端错误码使用 See merge request: cann/pypto!3118 | 6 months ago | |
style(all): Fix ruff-check lint errors across the codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4934 merge style-python-format into master style(all): Fix ruff-check lint errors across the codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Fix ruff-check lint errors across the codebase See merge request: cann/pypto!4934 | 4 months ago | |
fix: Correct lrelu arguments, source location cleanup, directory retention and argsort docs Co-authored-by: Aiden<linking_sky@outlook.com> # message auto-generated for no-merge-commit merge: !7206 merge fix/consolidate-four-prs into master fix: Correct lrelu arguments, source location cleanup, directory retention and argsort docs Created-by: linking_sky Commit-by: Aiden Merged-by: cann-robot Description: ## 描述 Tensor.lrelu 多声明了一个 other 参数,调用 pypto.lrelu 时传入多余参数,导致默认调用和显式传入斜率时失败。pypto.lrelu 的输入参数名 other 与文档中的 input、注释中的 a 不一致,使用 input= 关键字调用会失败。 op_wrapper 和 source_location 在被包装函数抛出异常时未清理源码位置状态,导致后续算子使用错误的源码位置。 RemoveOldDirectories 按目录修改时间升序排序后删除超出保留数量的目录,实际保留旧目录、删除新目录。 argsort 文档中的 descending 默认值为 True,与实际实现的 False 不一致。 ## 修复 移除 Tensor.lrelu 中多余的 other 参数,正确传递当前张量和 negative_slope。将 pypto.lrelu 的输入参数名统一为 input,同步更新实现和注释。 在 op_wrapper 和 source_location 中使用 try/finally,确保异常发生后仍清理源码位置状态。 将历史目录按修改时间降序排序,保留最新目录,并补充目录保留顺序、保留数量边界及前缀过滤测试。 修正 argsort 文档中的默认值,明确默认按升序返回索引,并同步更新 docstring。 ## 测试 - Tensor.lrelu 通过 A3 环境测试,验证默认调用、位置参数、关键字参数和 native graph。 ### 关联ISSUE ISSUE:[#3685](https://gitcode.com/cann/pypto/issues/3685) See merge request: cann/pypto!7206 | 1 month ago | |
fix(pil): Preserve source location for tensor ops Co-authored-by: zhaojunhan<zhaojunhan1@huawei.com> # message auto-generated for no-merge-commit merge: !7432 merge fix_op_source_span into master fix(pil): Preserve source location for tensor ops Created-by: zhaojunhan Commit-by: zhaojunhan Merged-by: cann-robot Description: ## 背景 dump 出来的 tensor op(例如 MUL)没有 file / line。dump_source_location 是打开的,缺的是 span_。 dispatch_call 直接调用 pypto_impl.SetSpan,只改了 C++ 的 Span::Current(),没有加入 _source_location_depth。pypto.mul 接着走进 @op_wrapper,包装器看到计数仍是 0,用 sys._getframe(2) 再写一次 span,位置变成 op_registry.py 里的 dispatch()。返回时 clear_source_location() 在 emit_tensor_stmts() 之前执行 ClearSpan(),写进 IR 的 span 是 unknown。后续 CloneTensorOpStmt 把这个空 span 带到 hidden function,program.json 里就没有 file / line。 嵌套调用还有第二处丢失:外层 dispatch_call 已经把计数加到 1 之后,内层即使传入了自己的文件名和行号,旧逻辑也因为 depth != 0 不再 SetSpan。循环里调用 helper、helper 里再 pypto.mul 时,MUL 会沿用外层调用行。 ## 修改 - dispatch_call 改用 set_source_location / clear_source_location,和 @op_wrapper 共用计数。emit_tensor_stmts() 在 ClearSpan() 之前执行。 - 显式传入的文件名和行号不受计数限制,嵌套调用可以记下自己的位置。从栈上推断位置的逻辑不变,仍然只有最外层生效。 See merge request: cann/pypto!7432 | 20 days ago | |
feat(pass): Remove slice false label Co-authored-by: 2501_92924845<niulinkai@huawei.com> # message auto-generated for no-merge-commit merge: !7696 merge slice1120 into master feat(pass): Remove slice false label Created-by: 2501_92924845 Commit-by: 2501_92924845 Merged-by: cann-robot Description: 背景 Slice 已默认开启。为让示例、测试和用户代码使用一致的编译路径,本 PR 下架 Python 侧及cpp侧的 enable_slice 开关,并清理用例中显式开启或关闭 Slice 的配置。 主要改动 - 移除 Python set_pass_options() 中的 enable_slice 参数及 get_pass_options() 中的对应字段。通过通用配置字典传入该选项时会报错。 - 清理示例、PyPTO Pro 和测试中的 Slice 覆盖配置,移除 pytest 启动时的强制开启逻辑。Gather、Matmul、TransData 和 Distributed ST 等用例恢复使用框架默认配置。 - 修复 ReplaceTensor 在 DDR VIEW 重绑定后未同步更新 COPY_IN 偏移的问题。将写入同一输出的 ASSEMBLE 之间的依赖 token 转移到实际写操作,保留 Conv1D 权重补零与有效权重写入的顺序。补充偏移回归测试,以及 token 搬移成功和拒绝分支的 UT。 See merge request: cann/pypto!7696 | 6 days ago | |
style(all): Fix ruff-check lint errors across the codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4934 merge style-python-format into master style(all): Fix ruff-check lint errors across the codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Fix ruff-check lint errors across the codebase See merge request: cann/pypto!4934 | 4 months ago | |
fix(simulation): Relax capture mode during device-to-host data transfer Co-authored-by: zhiweiyuan<zhiweiyuan@huawei.com> # message auto-generated for no-merge-commit merge: !5303 merge fix/capture-mode-relax into master fix(simulation): Relax capture mode during device-to-host data transfer Created-by: zhiweiyuan Commit-by: zhiweiyuan Merged-by: cann-robot Description: fix(simulation): Relax capture mode during device-to-host data transfer In A3 simulation mode, executing capture test cases fails with RT_MEMCPY_FAILED (F7B002) during CopyFromDev. The root cause is that device-to-host memory copy is restricted in capture mode. This change calls ExchangeCaptureModeRelax before the data transfer to relax the capture mode constraint, allowing the memcpy to succeed. Changes: - Add ExchangeCaptureModeRelax call in cost_model.py before device-to-host tensor transfer - Bind ExchangeCaptureModeRelax function in cost_model.cpp - Add ExchangeCaptureModeRelax declaration in __init__.pyi Related Issues: #2887 See merge request: cann/pypto!5303 | 3 months ago | |
fix(docs): Update enum documentation and index_add examples Co-authored-by: dingsinuo<dingsinuo@huawei.com> # message auto-generated for no-merge-commit merge: !7510 merge d into master fix(docs): Update enum documentation and index_add examples Created-by: dingsinuo Commit-by: dingsinuo Merged-by: cann-robot Description: 新增DequantScaleRoundingMode文档,补充目录索引及quant_mx参数引用。 删除不被用户感知的OutType、ReduceMode、ScatterMode文档及目录索引。 补充index_add、index_add_ub调用示例,与对应原地版本的文档保持一致。 See merge request: cann/pypto!7510 | 16 days ago | |
style(all): Fix ruff-check lint errors across the codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4934 merge style-python-format into master style(all): Fix ruff-check lint errors across the codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Fix ruff-check lint errors across the codebase See merge request: cann/pypto!4934 | 4 months ago | |
fix(pass): Fix nested-loop InferMultiIterOverlap and refine local-tensor create detection Co-authored-by: songyangyang18<songyangyang18@huawei.com> # message auto-generated for no-merge-commit merge: !6555 merge cell-resolve into master fix(pass): Fix nested-loop InferMultiIterOverlap and refine local-tensor create detection Created-by: songyangyang18 Commit-by: songyangyang18 Merged-by: cann-robot Description: ## Background(背景信息) 当前InferMultiIterOverlap PASS只考虑了最内层循环变量的判重,对于循环嵌套场景以及内部创建tensor的场景存在判定不精准的问题。 ## 算法更新 1. 增加每一轮PASS前的clear清空操作,避免多轮之间的影响。 2. 增加outcast过滤,局部非outcast应该直接跳过。 3. 由最内层向外层循环逐一检测重叠,每一层按照当前层的循环变量与步长校验,只有全部非重叠,才进行标记; 4. 额外增加内部创建判定,创建的标识统一以path的constructAssembleSlotList为主,识别到当前循环层创建,当前层直接判定非重叠。 ## 用例看护 新增python UT场景看护。 | # | 用例 | 场景 | 期望 IterNoOverlapWaw | |---|------|------|-------------------------| | 1 | test_assemble_disjoint_marked | 单层 loop,assemble 偏移 i*TILE 邻接 | 有 Mark:[6](i 对应 hiddenfunc) | | 2 | test_assemble_overlap_unmarked | 单层 loop,偏移 i*(TILE//2) 半窗重叠 | 空 | | 3 | test_nested_disjoint_marked | 嵌套 i/j,i*TILE / j*TILE_N 均邻接 | 有 Mark:[6](内层 j) | | 4 | test_nested_overlap_unmarked | 嵌套,列步长 j*(TILE_N//2) 重叠 | 空 | | 5 | test_fixed_offset_unmarked | 每轮 assemble 到固定 [0,0] | 空 | | 6 | test_same_idx_diff_step_attrs | 兄弟 loop 同 idx_name=i:半窗 / step=2 邻接 | 仅 DJ 侧 Mark:[16] | | 7 | test_nested_inner_immediate_offset_unmarked | 内层 j 不进 assemble 偏移(对 j 不变) | 空 | | 8 | test_nested_outer_overlap_inner_disjoint_unmarked | 外层半窗重叠、内层邻接(任一层失败) | 空 | | 9 | test_tensor_create_outer_inner_overlap_attrs | 外层 tensor(buf);内层半窗写 buf;buf→out 邻接 | 仅外层 Mark:[14] | | 10 | test_full_create_disjoint_marked | 每轮 full + assemble i*TILE 邻接 | 有 Mark:[3] | | 11 | test_tensor_create_outer_inner_disjoint_attrs | 外层 buf;内层 j*TILE 与 buf→out i*TILE 均邻接 | 双 Mark:[14] + [7] | | 12 | test_multiround_disjoint_then_overlap_clears_marks | 同进程 5×:disjoint→overlap,验 Infer ClearMarks | disjoint 同 #1;overlap 始终空 | See merge request: cann/pypto!6555 | 2 months ago | |
refactor(ir): drop the unused INDEX dtype Co-authored-by: HuYiSheng01<hys123456aaa@163.com> # message auto-generated for no-merge-commit merge: !7713 merge feat/io_text_drop_index_dtype into master refactor(ir): drop the unused INDEX dtype Created-by: HuYiSheng01 Commit-by: HuYiSheng01 Merged-by: cann-robot Description: ## 一、背景 DataType::INDEX(kIndexCode = 0x15)是历史上为"索引型 64 位整数"保留的占位类型,实际语义与 INT64 完全重复: - 与 INT64 共用同一个 C 类型串:DataType::GetDataTypeCTypeStringDict() 里同时有 {kInt64Code, "int64_t"} 和 {kIndexCode, "int64_t"}; - BiMap 的反查是 str2typeDict[s] = i(后写覆盖),导致 Find("int64_t") 返回的是 INDEX 而不是 INT64; - 为此在文本 load 和 kwarg 读取侧被迫加了特判: - io_text_loader.cpp 的 TryDTypeFromCTypeString(text, preferInt64)(pro/v0 门控); - AnyCastFromIR<DataType> 里的 if (text == "int64_t") return kInt64Code;; - 反向不唯一还带出另一个坑:{kHf4Code, "unknown"} 使 "unknown" 反查到 HF4。 评审确认 INDEX 已无真实使用点(所有出现都是"等价于 INT64"的类型标注),因此整体删除。 ## 二、改动 ### 1)dtype 定义(framework/include/core/dtype.h) - 删除 kIndexCode、DataType::INDEX 声明与定义; - 删除 BiMap 中的 {kIndexCode, IR_KW_TYPE_INT64}(反查恢复唯一,"int64_t" → INT64); - 删除 GetBit() 的 case kIndexCode、ToString() 的 "index" 分支、DTypeToString() 的 "INDEX" 分支。 ### 2)结构性去重(structural_hash.cpp / structural_equal.cpp) - 删除 CanonicalizeForSyntaxScalarDtype() / AreForSyntaxScalarDtypesEquivalent(); - 删除仅为该归一化存在的上下文机制:fieldNameStack_、IsLoopVarFieldContext()、IsConstIntTypeContext(); - structural_hash 的 nodeTypeStack_ 一并移除(仅该归一化使用);structural_equal 保留 nodeTypeStack_(assert 模式错误路径仍在用)。 ### 3)消费侧去掉冗余判断 - scalar_expr_ops.h:删除 INDEX↔INT64 免 Cast 分支; - atomic.cpp / sync.cpp / ptr_ops.cpp:dtype_.IsInt() || == INDEX → dtype_.IsInt(); - debug_ops.cpp:删除 IsPrintfIndexType() 及 6 处引用,同步精简报错文案; - backend_cce_ops.cpp / backend_cce_vf_ops.cpp / backend_cce_block_out_ops.cpp:删除 == INDEX 分支与注释里的 INDEX 说明。 ### 4)Python 侧 - bindings/ir/ir.cpp:删除 DataType.INDEX 只读属性; - python/pypto/ir.py:删除 INDEX = DataType.INDEX 别名,tuple_get_item() 内部改用 DataType.INT64; - python/pypto_pro/ir/op/debug_ops.py:删除 _is_index_dtype() 及其引用; - python/pypto_pro/language/parser/_gemm_lowering.py:类型校验改为 dtype.is_int(); - python/pypto_pro/runtime/jit.py:删除 (DataType.INDEX, "int64") 与 str(DataType.INDEX): ctypes.c_int64(INT64 已有对应项)。 ### 5)测试 - 14 个 Python 用例文件:ir.INDEX / DataType.INDEX → INT64; - 18 个 C++ UT 文件:DataType::INDEX → DataType::INT64; - 删除只验证"INDEX 存在"的用例: - test_structural_equal_ext.cpp:TestLoopVarInt64IndexNotEquivalent、TestConstIntTypeInt64IndexNotEquivalent; - test_dtype.py:test_limits_of_index_matches_int64; - test_scalar_range.py:test_explicit_legacy_index_dtype_is_preserved; - test_backend_cce_vf_ops.cpp:删除重复的 IndexVal 用例,测试更名为 MulsAcceptsInt64ScalarConvertedToSrcType。 ### 6)文档 - docs/zh|en/.../basic_data_structures/DataType.md:删除 static const DataType INDEX; 行(中英同步,保持原 CRLF 行尾)。 ## 三、行为变化(对外可见) | 场景 | 改动前 | 改动后 | |---|---|---| | GetDataTypeCTypeStringDict().Find("int64_t") | INDEX | INT64 | | v0 文本 incast(int64_t %a) 的 dtype | INDEX | INT64 | | DataType.INDEX / ir.INDEX | 存在 | **不存在**(调用方需改用 INT64) | | str(DataType.INDEX) | "index" | 类型已删除 | | structural hash/equal 的 INT64≡INDEX 归一化 | 存在 | 不再需要(两者本就是一个类型) | | debug.printf/assert 的 index 标量 | 单独归类 | 按 INT64 处理(行为等价) | **兼容性**:IR 文本不变(int64_t 前后一致);不涉及序列化格式;只影响直接使用 DataType.INDEX 的 C++/Python 调用点,本 PR 已全部迁移。 See merge request: cann/pypto!7713 | 6 days ago | |
fix(config|logging): Validate int64 options and correct internal check docstring Co-authored-by: zhaojunhan<zhaojunhan1@huawei.com> # message auto-generated for no-merge-commit merge: !7547 merge fix/python-config-int64-validation into master fix(config|logging): Validate int64 options and correct internal check docstring Created-by: nanguag Commit-by: zhaojunhan Merged-by: cann-robot Description: Python 整型数值可超出 int64_t 范围。此前在 pybind11 类型转换阶段,配置绑定就已失败,还没等到选项校验逻辑识别出非法值;同时 internal_check 的文档字符串里标注的异常类型也是错的。 变更内容: - 在调用绑定接口前,对配置值做 int64 范围校验,支持嵌套列表、字典场景 - 修正 internal_check 文档字符串,改为标注 InternalError - 为对外配置入口、正负两个溢出方向补充参数化测试覆盖 See merge request: cann/pypto!7547 | 12 days ago | |
fix(front): fix issue #3272 and #3274 add assemble parameter validation Co-authored-by: HuYiSheng01<hys123456aaa@163.com> # message auto-generated for no-merge-commit merge: !6098 merge fix/assemble-param-validation into master fix(front): fix issue #3272 and #3274 add assemble parameter validation Created-by: HuYiSheng01 Commit-by: HuYiSheng01 Merged-by: cann-robot Description: 额外修复了一个之前提交的文档的问题#3245 本 PR 包含 issue #3272 与 #3274 的两项配套修复: pypto.assemble 前端实现(operation.py)对参数数量与类型零校验,用户按 @overload 签名调用时,任何偏差都会泄露 Python 内部解包/迭代错误(无函数名、无签名提示、无源码位置)。 - #3272:参数顺序/类型传错(如 offsets 位置传 Tensor)时,深层调用链报 FeError: Tensor is not iterable 等内部错误,与用户实际意图完全脱节; - #3274:模块级 assemble 声明了 @overload 签名但运行时零校验,且缺少 @source_location 装饰器(对比 Tensor.assemble 方法),错误无法定位到用户调用点。 - assemble() 入口显式校验参数数量(单源 3 参 / 多源 2 参),其余情况抛出语义化错误; - 校验 src/dst 为 pypto.Tensor、offsets 为 list/tuple、srcs 为序列,错误信息包含函数名、参数位置、期望类型与实际类型; - 2 参形式且首参为 Tensor 时,附加提示"可能想使用单源形式但缺少 offsets 参数"。 Related Issue: #3272, #3274 #3245 See merge request: cann/pypto!6098 | 2 months ago | |
feat(codegen): Support Kirin9050 (NCH) LiteNPU codegen and tests Co-authored-by: m0_71310678<lizhexun2@huawei.com> # message auto-generated for no-merge-commit merge: !6988 merge kirin9050-feature-branch-part2 into master feat(codegen): Support Kirin9050 (NCH) LiteNPU codegen and tests Created-by: m0_71310678 Commit-by: m0_71310678 Merged-by: cann-robot Description: Add LiteNPU codegen support for the Kirin9050 (NCH) platform, including static codegen UT cases and single-op python tests. Changes: - Add LiteNPU codegen implementation for Kirin9050 (NCH) - Add codegen static tests for 31 single ops (abs, add, amax, amin, assemble, cast, compare, concat, div, exp, full, index_put_, matmul, maximum, minimum, mul, neg, reciprocal, reshape, rsqrt, sigmoid, sqrt, sub, sum, transpose, unsqueeze, view, where) - Add kernel entry uniqueness driver and single-op tests in python UT - Register kirin9050 operations in python/pypto/operator.py Related Issue: #3600 See merge request: cann/pypto!6988 | 1 month ago | |
style(all): Fix ruff-check lint errors across the codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4934 merge style-python-format into master style(all): Fix ruff-check lint errors across the codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Fix ruff-check lint errors across the codebase See merge request: cann/pypto!4934 | 4 months ago | |
style(all): Fix ruff-check lint errors across the codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4934 merge style-python-format into master style(all): Fix ruff-check lint errors across the codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Fix ruff-check lint errors across the codebase See merge request: cann/pypto!4934 | 4 months ago | |
style(all): Fix ruff-check lint errors across the codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4934 merge style-python-format into master style(all): Fix ruff-check lint errors across the codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Fix ruff-check lint errors across the codebase See merge request: cann/pypto!4934 | 4 months ago | |
style(all): Fix ruff-check lint errors across the codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4934 merge style-python-format into master style(all): Fix ruff-check lint errors across the codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Fix ruff-check lint errors across the codebase See merge request: cann/pypto!4934 | 4 months ago | |
fix(frontend): Reject reversed slice bounds instead of negative extent Co-authored-by: HuYiSheng01<hys123456aaa@163.com> # message auto-generated for no-merge-commit merge: !7647 merge fix/reject-reversed-slice into master fix(frontend): Reject reversed slice bounds instead of negative extent Created-by: HuYiSheng01 Commit-by: HuYiSheng01 Merged-by: cann-robot Description: Python 中并不存在“反向切片”的语义。对于正步长的 x[3:1],其区间本身就是空的,但 PyPTO 目前会把边界归一化为 (3, 1, 1),再用 stop - start 计算 view 维度,得到 -2,导致 pypto.view 以 Invalid shape -2 报错(issue #3831)。 本次修改不再把负维度静默夹紧为 0,而是显式拒绝反向切片边界,使不支持的输入得到明确报错,而不是被赋予额外语义。 Changes: - 当计算出的 view 维度为具体负数时抛出 FeError,并在报错信息中给出对应的 start/stop - 新增回归用例,断言 x[3:1] 会被拒绝 See merge request: cann/pypto!7647 | 10 days ago |
| Files | Last commit | Last update |
|---|---|---|
| 10 days ago | ||
| 18 days ago | ||
| 6 days ago | ||
| 10 days ago | ||
| 6 days ago | ||
| 6 days ago | ||
| 2 months ago | ||
| 3 months ago | ||
| 8 days ago | ||
| 8 days ago | ||
| 6 months ago | ||
| 4 months ago | ||
| 1 month ago | ||
| 20 days ago | ||
| 6 days ago | ||
| 4 months ago | ||
| 3 months ago | ||
| 16 days ago | ||
| 4 months ago | ||
| 2 months ago | ||
| 6 days ago | ||
| 12 days ago | ||
| 2 months ago | ||
| 1 month ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 10 days ago |