Merged
fix(codegen): Fix operandWithMagic out-of-bounds initialization #5678
anyangleAdd on Aug 25
fix(codegen): Fix operandWithMagic out-of-bounds initialization #5678
Merged
anyangleAdd on Aug 25
anyangle
anyangleCollaborators
Aug 25
  1. PyPTO codegen 模块日志整改
  2. Issue:2824问题修改
  3. Issue:3020问题修改
likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for anyangle's contribution.)
anyangleanyangleCollaborators
Aug 25 Created pull request, commit b9a7ac5a
atomgit-bot
atomgit-bot
Aug 25 Comments:

变更摘要

本 PR 修复了 framework/src/codegen/codegen_op.h 中 operandWithMagic 的越界初始化问题。此前的写法使用 reserve(MAX_OPERANDS) 仅预留容量而不改变向量大小,随后循环中直接对 operandWithMagic[i] 赋值可能产生越界访问;本改动改为使用 resize(MAX_OPERANDS, INVALID_TENSOR_MAGIC),一次性将向量扩展为 MAX_OPERANDS 个元素并统一初始化为 INVALID_TENSOR_MAGIC,从而消除了越界风险。

主要改动

  • 改用 resize 初始化: 将 operandWithMagic.reserve(MAX_OPERANDS) 替换为 operandWithMagic.resize(MAX_OPERANDS, INVALID_TENSOR_MAGIC),使向量真正分配并填充 MAX_OPERANDS 个默认元素,避免后续按索引赋值时越界。
  • 移除循环内的重复赋值: 删除构造函数循环中的 operandWithMagic[i] = INVALID_TENSOR_MAGIC;,因 resize 已用 INVALID_TENSOR_MAGIC 完成初始化,无需在循环中再次赋值。
  • 保留其余初始化逻辑: 循环中对 operandType[i]、operandDtype[i] 的初始化保持不变,仅调整了 operandWithMagic 相关的初始化方式。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Aug 25 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Aug 25 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Aug 25 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
docs ✅ 尹杰, lululu40888, lyz0328 (3/2) ✅ lyz0328, 尹杰 (2/1)
framework/src/codegen ✅ lululu40888, 尹杰 (2/2) ✅ 尹杰, lululu40888 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
63 messages are collapsed here。 See more
anyangle
anyangleCollaborators
Aug 27 Comments:

/check-pr

likedislike
CANN-robot
CANN-robotCollaborators
Aug 27 Comments:

The following labels are not ready.

lgtm: Please wait for reviewers to review the code.

approved: Please wait for committers to review the code.

likedislike
Jie Yin
Jie YinCollaborators
Aug 27 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Aug 27 Added label: lgtmapproved
CANN-robotCANN-robotCollaborators
Aug 27 Merged pull request