| Files | Last commit | Last update |
|---|---|---|
fix(api | profiling): Correct profiling usage and API documentation inconsistencies Co-authored-by: Approach1999<2196572507@qq.com> # message auto-generated for no-merge-commit merge: !7205 merge fix/combined-profiling-docs-topk into master fix(api | profiling): Correct profiling usage and API documentation inconsistencies Created-by: Approach1999 Commit-by: Approach1999 Merged-by: cann-robot Description: **说明** 按活动提交要求,将三个独立缺陷修复合并为单个 PR。三个问题的根因相互独立、改动文件互不重叠,可按下列三节分别评审;如需回退,可按对应文件路径单独回退。本 PR 已 squash 为单个提交 b13a247c7。 **提交清单** | 原 PR | 原提交 | 提交标题 | 改动文件 | |---|---|---|---| | !7031 | f337a17a2 | fix(profiling): Correct pipeline usage calculations | tools/profiling/draw_swim_lane.py、tools/tests/test_draw_swim_lane.py | | !7032 | bb3aaf6e4 | docs(api): Correct tensor shapes and outputs in examples | 8 个算子文档页面 | | !7033 | 63a7d59ff | docs(api): Align topk return annotations with list results | topk 文档、python/pypto/op/comparison.py、python/pypto/tensor.py | --- ## 一、泳道图管线利用率计算错误 **场景** 用户为泳道图工具启用可选的管线利用率报告(gen_exe_topo_json),并提供合法的 leaf pipe 执行时间 JSON,进入 calculate_pipe_usage 生成报告。 **问题** TaskInfo.func_name 是字符串字段,消费端却写为 entry.func_name(),只要进入正常任务遍历即抛出 TypeError: 'str' object is not callable,功能完全无法完成。同路径上还存在多处连带缺陷: - 任务未匹配到 leaf 时 leaf_total_cycles == 0,trans_cycles_to_time 中除零崩溃; - 仅存在单一核类型(纯 AIC 或纯 AIV)时,汇总表按对应核数为 0 除法崩溃; - 某核无某 pipe 数据时 pipe_exec_time[pipe] 抛 KeyError; - fake 任务/零时长核破坏 get_total_time 的哨兵值逻辑。 **影响范围** 改动完全收敛在 --gen_exe_topo_json 可选开关下的代码路径,泳道图主流程不受影响;get_total_time / trans_cycles_to_time / calculate_pipe_usage 全仓库无其他调用方,CSV 无外部消费方。 **复现方式** 构造 1 个 AIC 任务(func_name="cube",0→10)与 1 个 AIV 任务(vec,2→10),提供 leaf JSON: json [{"FuncName": "cube", "FuncHash": 1, "TotalCycles": 1800, "pipes": {"CUBE": 900}}] master 上调用 calculate_pipe_usage: text TypeError: 'str' object is not callable 修复后正常产出 CSV(CUBE = 900 cycles / 1800 MHz = 0.5,0.5 ÷ 1 核 ÷ 10 总时长 = 5.0%)。 **改动内容** - func_name = entry.func_name() 改为属性读取 entry.func_name - trans_cycles_to_time / get_total_time / calculate_pipe_usage 跳过 fake 任务并防护零周期、零时长场景 - 每核行的 TotalTime 列与利用率分母改用每核自身总时长 - 所有除法增加零分母防护;pipe 时间改用 .get(pipe, 0) **回归验证** 新增仅依赖标准库的主机侧单测 tools/tests/test_draw_swim_lane.py(5 个用例,全部通过),覆盖 AIC/AIV 混合、单一核类型分母、匹配与未匹配 leaf 名、空数据与零时长、fake 任务不遮挡真实任务。 --- ## 二、8 个 API 示例 Shape 构造错误 **场景** 用户复制 hypot、prelu(1D/2D)、pad、remainder(3 种模式)、relu、lrelu、signbit、unpack 共 8 个算子页面的调用示例来构建计算图。 **问题** pypto.tensor 的首参是 **Shape**,但这些示例传入的是数据列表。对照运行时行为已验证: - 浮点/嵌套数据列表在建图时直接被拒:FeError: ErrCode F00002, ValueError: Invalid value type; - 整型数据列表被静默当作 shape 维度——例如 unpack 示例把 8 个 UINT8 数值传进去,实际构造出 **8 维** Tensor(shape 为 [6, 5, 4, 3, 8, 6, 5, 1]),而页面明确要求一维 [8] 输入。 照抄示例均无法按文档预期运行,属于“描述和软件不一致”的正确性问题。 **影响范围** 仅影响上述 8 个算子文档页面的调用示例与说明,不改变 API 行为或实现;修正后的示例已按文档输入数据完成端到端验证。 **复现方式**(图构建层即可复现,无需上板) python import pypto pypto.tensor([3.0, 5.0], pypto.DT_FP32) # FeError: ErrCode: F00002, ValueError: Invalid value type t = pypto.tensor([6, 5, 4, 3, 8, 6, 5, 1], pypto.DT_UINT8) print(t.shape) # [6, 5, 4, 3, 8, 6, 5, 1] —— 8 维,文档要求一维 [8] **改动内容** - 全部示例改为用文档声明的 Shape 构造:[2]、[1,3]、[1,1,2,2]、[4]/[1]、[2,3]/[3]、[3]、[5]、[8] - TileShape 说明与示例维度对齐(如 1D 用 set_vec_tile_shapes(16),pad 用 (1,1,4,16)),并说明 pypto.tensor 首参为 Shape、运行数据由调用方在执行时绑定 - 补充示例上下文说明;数值结果示例保持不变 **回归验证** 8 个修正后的示例全部在 **Ascend 910(CANN 9.2.0)** 上按文档输入数据端到端执行,输出与各页“结果示例”逐项一致,包括 hypot [5, 13]、remainder 负除数 [-2, -1, 0]、unpack 小端拼包 [0x03040506, 0x01050608]、pad 输出 [1,1,3,3] 填充矩阵等。 --- ## 三、topk 返回类型描述与实现不一致 **场景** 用户按 topk 文档“返回命名元组 (values, indices)”的说明,以 result.values / result.indices 方式访问结果。 **问题** 统一包装层 _from_base(python/pypto/_op_wrapper.py)对 tuple/list 一律通过列表推导式返回普通 list,因此 pypto.topk 实际返回包含两个 Tensor 的**列表**;result.values 抛 AttributeError。文档与注解声明的 Tuple[Tensor, Tensor] 与软件行为不一致。 **影响范围** 影响 pypto.topk / Tensor.topk 的返回类型文档与类型注解;运行时行为不变(改动前后行为零差异),将文档和注解对齐到实际的 List[Tensor],并在 comparison.py 中显式 list(...) 固化契约。 **复现方式**(需在合法建图上下文内) python import pypto with pypto.options(pass_options={"enable_slice": True}): x = pypto.tensor([2, 3], pypto.DT_FP32, "x") with pypto.function("TOPK", x): r = pypto.topk(x, 2, -1, True, pypto.TopKAlgo.MERGE_SORT) type(r) # <class 'list'> r.values # AttributeError: 'list' object has no attribute 'values' values, indices = pypto.topk(x, 2, -1, True) # 序列解包可用 **改动内容** - pypto-topk.md、pypto-Tensor-topk.md、op/comparison.py、tensor.py 四处返回类型统一改为 List[Tensor] - op/comparison.py 的 topk 返回改为显式 return list(pypto_impl.TopK(...)),行为不变,仅固化公开 API 的 list 契约 - 返回值说明改写为“包含两个 Tensor 的列表,依次为 values 和 indices,可通过序列解包获取” - 示例改为 values, indices = pypto.topk(...),输出标签同步更新(y[0]/y[1] → values/indices) **回归验证** - 在 **Ascend 910(CANN 9.2.0)** 实机执行:解包结果 values [[3, 2], [3, 2]]、indices [[2, 1], [2, 1]],与文档示例输出完全一致;Tensor.topk 方法路径同样验证通过 - 注解改动经 13 个算子冒烟差分(op/comparison.py 全部 11 个公开算子 + 控制组)验证与改动前**行为零差异**;pypto 命名空间表面逐项一致 - comparison.py 显式 list(...) 改动后按同一 topk 脚本复核,输出与改动前一致 --- **合并验证** - 基于官方 master 480eef718,单提交 b13a247c7,14 文件、+238/−77 - tools/tests/test_draw_swim_lane.py:5 个用例全部通过 - git diff --check:通过 - 原 PR:!7031、!7032、!7033(已关闭) **原 PR 链接** - !7031 https://gitcode.com/cann/pypto/merge_requests/7031 - !7032 https://gitcode.com/cann/pypto/merge_requests/7032 - !7033 https://gitcode.com/cann/pypto/merge_requests/7033 See merge request: cann/pypto!7205 | 29 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 | |
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 |
| Files | Last commit | Last update |
|---|---|---|
| 29 days ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 4 months ago |