Pull Request已成功合入, 合并人@CANN-robot
(感谢 huafeng793 的贡献)变更摘要
此 PR 主要修复 conv3dv2 算子在权重格式为 FRACTAL_Z_3D、输出格式为 NDHWC/DHWCN 等场景下 ops-test-kit 执行失败的问题。核心变更是为 FRACTAL_Z_3D 格式新增反向转换函数 from_fractal_z_3d,将分形 Z 3D 布局的权重数据还原为 NCDHW、NDHWC 或 DHWCN 标准格式,并注册到 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参数进一步transpose为NDHWC或DHWCN输出。 -
扩展
format_transformation_map映射表:在format_transformation_map字典中新增"FRACTAL_Z_3D"条目,将目标格式"NCDHW"、"NDHWC"、"DHWCN"统一指向from_fractal_z_3d函数,使格式转换框架能够处理从FRACTAL_Z_3D到这三种标准格式的反向转换。


代码审查
审查总结
已审查文件: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)可侥幸通过,但函数在以下场景存在确凿的逻辑缺陷:
- DHWCN 输出:
transpose轴参数写错,产生 CDHWN 而非 DHWCN; - groups > 1:
cin_ori和_calculate_group参数使用了 per-group 值而非总通道数,与正向转换to_fractal_z_3d不一致,导致 reshape 失败或计算结果错误; - NDHWC/DHWCN 目标格式:
target_shape始终按 NCDHW 解包,未使用target_format参数解释维度位置。
建议在合入前修复上述问题,尤其是 P1 的两项逻辑错误。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 2 |
| 🟡 建议 | 1 |
⛔ 需要修改


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
/approveor/lgtm- Commenting
/approveimplies 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. 👍


当前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

文档更新
不涉及
类型标签