已合并
fix bug: fractal_z_3d格式转成ncdhw、ndhwc、dhwcn格式 #101
huafeng793创建于 8 天前
fix bug: fractal_z_3d格式转成ncdhw、ndhwc、dhwcn格式 #101
已合并
huafeng793创建于 8 天前
huafeng793
8 天前

当前PR是否有AI参与:

[ ] 否
[x] 是
__1. AI Agent 平台: cannbot
__2. AI 模型: glm-5.2
__3. Prompt上下文 : NA

PR功能描述 / 为什么需要这个合入**:

适配conv3dv2算子某些format场景下ops-test-kit执行通过:
输入format:('NCDHW', 'FRACTAL_Z_3D', 'ND', 'ND', None, None)
输出format:NDHWC

该PR关联的issue

#91

希望检视人员了解:

ttk_kernel_yel_conv3dv2_weight_fz_005,conv3dv2,"((1, 512, 5, 124, 56), (16, 16, 16,32), (256,), (256,), None, None)","((1, 512, 5, 124, 56), (256, 512, 1, 1, 1), (256,), (256,), None, None)","('int8', 'int8', 'bfloat16', 'float32', None, None)","((1, 5, 124, 56, 256),)","('bfloat16',)","('NCDHW', 'NCDHW', 'ND', 'ND',None,None)","('NCDHW', 'FRACTAL_Z_3D', 'ND', 'ND',None,None)","('NDHWC',)","('NDHWC',)","{'strides': [1, 1, 1, 1, 1], 'dilations': [1, 1, 1, 1, 1], 'pads': [0, 0, 0, 0, 0, 0], 'groups': 1, 'data_format': 'NCDHW', 'offset_x': 0, 'pad_mode': 'SPECIFIC', 'enable_hf32': False}","((-5, 5),)","((0.001, 0.001),)",0.005,,,

ttk_kernel_yel_conv3dv2_weight_fz_006,conv3dv2,"((1, 512, 5, 26, 120), (432, 32, 16,32), (512,), (512,), None, None)","((1, 512, 5, 26, 120), (512, 512, 3, 3, 3), (512,), (512,), None, None)","('int8', 'int8', 'float16', 'float32', None, None)","((1, 3, 26, 120, 512),)","('float16',)","('NCDHW', 'NCDHW', 'ND', 'ND',None,None)","('NCDHW', 'FRACTAL_Z_3D', 'ND', 'ND',None,None)","('NDHWC',)","('NDHWC',)","{'strides': [1, 1, 1, 1, 1], 'dilations': [1, 1, 1, 1, 1], 'pads': [0, 0, 1, 1, 1, 1], 'groups': 1, 'data_format': 'NCDHW', 'offset_x': 0, 'pad_mode': 'SPECIFIC', 'enable_hf32': False}","((-5, 5),)","((0.001, 0.001),)",0.005,,,

测试

python3 -m ttk kernel -i xxx.csv --plugin xxx -b release -d false --no-memory-check --run=1 --dump-on-fail --compare close -t=case_name
image.png

文档更新

不涉及

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 huafeng793 的贡献)
Hhuafeng793
8 天前 创建了 pull request,commit 473a42b8
atomgit-bot
atomgit-bot
8 天前 评论:

变更摘要

此 PR 主要修复 conv3dv2 算子在权重格式为 FRACTAL_Z_3D、输出格式为 NDHWC/DHWCN 等场景下 ops-test-kit 执行失败的问题。核心变更是为 FRACTAL_Z_3D 格式新增反向转换函数 from_fractal_z_3d,将分形 Z 3D 布局的权重数据还原为 NCDHWNDHWCDHWCN 标准格式,并注册到 format_transformation_map 映射表中,使格式转换模块具备完整的双向转换能力。

主要改动

  • 新增 from_fractal_z_3d 函数:在 format_transformation_map.py 中新增反向转换函数,支持将 FRACTAL_Z_3D 格式的数据按分组(groups)和块大小(BLOCK_SIZE / c0 / n0)还原为 (N, C_in, D, H, W) 标准布局,并根据 target_format 参数进一步 transposeNDHWCDHWCN 输出。

  • 扩展 format_transformation_map 映射表:在 format_transformation_map 字典中新增 "FRACTAL_Z_3D" 条目,将目标格式 "NCDHW""NDHWC""DHWCN" 统一指向 from_fractal_z_3d 函数,使格式转换框架能够处理从 FRACTAL_Z_3D 到这三种标准格式的反向转换。

likedislike
atomgit-bot
atomgit-bot
8 天前 评论:

代码审查

审查总结

已审查文件ttk/core_modules/infershape/format_transformation.py(+44 行,新增 from_fractal_z_3d 函数及 format_transformation_map 中对应的逆向映射条目)

发现问题

优先级 数量 说明
P1 2 DHWCN 格式 transpose 轴参数错误;groups > 1 时 cin_ori 和 _calculate_group 参数计算错误
P2 1 target_shape 未按 target_format 解释,NDHWC/DHWCN 格式下维度解包错误
P3 1 target_shape 默认为 None 但函数体未处理

整体风险评估:当前 PR 测试用例(groups=1,权重逆向目标格式为 NCDHW)可侥幸通过,但函数在以下场景存在确凿的逻辑缺陷:

  1. DHWCN 输出transpose 轴参数写错,产生 CDHWN 而非 DHWCN;
  2. groups > 1cin_ori_calculate_group 参数使用了 per-group 值而非总通道数,与正向转换 to_fractal_z_3d 不一致,导致 reshape 失败或计算结果错误;
  3. NDHWC/DHWCN 目标格式target_shape 始终按 NCDHW 解包,未使用 target_format 参数解释维度位置。

建议在合入前修复上述问题,尤其是 P1 的两项逻辑错误。

类型 数量
🔴 阻塞 2
🟡 建议 1

⛔ 需要修改

likedislike
CANN-robotCANN-robot成员
8 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
8 天前 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here
You can get sig-info at here


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/ops-test-kit wangrui_, 陈琦 (2/2) wangrui_, 陈琦 (2/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

huafeng793, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
此处折叠了41条消息 查看更多
RRuiWang_成员
7 天前 解决了最后一个问题
chenqi317成员
7 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
7 天前 添加了label:lgtm
CANN-robotCANN-robot成员
7 天前 关闭了关联的issue
CANN-robotCANN-robot成员
7 天前 合入了pull request