Merged
fix(operation): Add viewshape check for GatherMask last axis #5626
Wang XuAdd on Aug 24
fix(operation): Add viewshape check for GatherMask last axis #5626
Merged
Pull Request has been successfully merged by CANN-robot.
(Thank you for Wang Xu's contribution.)atomgit-bot
Aug 24 Comments:
Aug 24 Comments:
变更摘要
该 PR 为 GatherMask 操作增加了"最后一维不允许被 View 拆分"的约束校验:当 patternMode 处于 1~6 时,若输入张量的最后一维经 View 拆分后变小,则在编译/执行阶段直接报错,避免生成错误结果。改动同时覆盖 C++ 后端、pypto Python 前端以及单元/系统测试。
主要改动
View记录原始形状属性(framework/src/interface/operation/operation_impl.cpp):在View的三条实现路径中,为结果存储写入ORIGINAL_SHAPE属性,并在操作数存在动态有效形状时写入ORIGINAL_DYN_VALID_SHAPE,供后续校验使用。- 后端执行期校验(
framework/src/interface/operation/vector/indexing.cpp):在GatherMaskBuildInOperationTileFunc中,当patternMode为 1~6 时读取ORIGINAL_SHAPE,若viewShape最后一维小于原始最后一维,则通过CHECK抛出ERR_PARAM_INVALID错误,提示 "GatherMask requires the last axis of self.shape not to be split by view"。 - pypto 前端跟踪 View 与校验(
python/pypto/operation.py、python/pypto/op/indexing.py、python/pypto/frontend/parser/entry.py):view通过_view_original_shapes、_view_input_ids、_view_input_names记录视图的原始形状及输入张量信息;gathermask在pattern_mode为 1~6 时将校验信息追加到_gathermask_checks;JitCallableWrapper新增_check_gathermask_view_constraint,在编译时用实际张量形状核对,若viewshape_last小于实际最后一维则抛出FeError。 - 单元测试补充(
framework/tests/ut/operator/src/test_operation_impl.cpp):新增 4 个用例,覆盖 2D/4D 张量经View拆分最后一维后调用GatherMask期望抛错(含 mode 3 场景),以及View与输入形状相同时正常通过的场景。 - ST 测试与 golden 适配(
framework/tests/st/operation/src/test_gathermask_operation.cpp、framework/tests/st/operation/python/vector_operator_golden.py):ST 参数化用例补充单次切分执行函数;golden 生成逻辑对uint16/uint32输入先转int16/int32参与torch计算,再转回原始 dtype 输出,避免无符号整型运算出错。


Incorrect?
atomgit-bot
Aug 24 Comments:
Aug 24 Comments:
Aug 24 Added label: cann-cla/yes
CANN-robot
Aug 24 Comments:
Aug 24 Comments:
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.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/pypto | ✅ ym-HW, DCGDDD (2/2) | ✅ ym-HW (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
Apricityh, thanks for your pull request. All authors of the commits have signed the CLA. 👍


55 messages are collapsed here。 See more
Aug 24 Added label: ci-pipeline-passed
杨旭
Aug 25 Comments:
Aug 25 Comments:
/lgtm


yumeng_27
Aug 25 Comments:
Aug 25 Comments:
/approve


Aug 25 Added label: lgtmapproved
Aug 25 Merged pull request
为 GatherMask 动态场景的最后一个轴添加viewshape不可切分约束检查