已合并
fix: 修复 FFT 算子 host 侧缓冲区尺寸计算的整数溢出 #33
Tian_1122创建于 12 天前
fix: 修复 FFT 算子 host 侧缓冲区尺寸计算的整数溢出 #33
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 Tian_1122 的贡献)atomgit-bot
12 天前 评论:
12 天前 评论:
变更摘要
本 PR 主要修复 FFT 系列算子 host 侧缓冲区尺寸计算中的整数溢出问题。原先 inputSize、outputSize、workspaceSize 等尺寸变量使用 uint32_t 保存,且在 n * batches * sizeof(float) * 2 这类连乘中先按 32 位整型计算,导致较大尺寸下发生溢出。此次改动将相关尺寸变量统一改为 size_t(个别改为 uint64_t),并在首个乘数上通过 static_cast<size_t>(...) 或 static_cast<uint64_t>(...) 强制提升为 64 位运算,从而保证缓冲区尺寸计算正确。
主要改动
- 一维 FFT 基础/混合/N 点算子尺寸计算提升为 64 位: 在
fft1_d_b.cpp、fft1_d_mix.cpp、fft1_d_n.cpp中,将inputSize、outputSize由uint32_t改为size_t,并用static_cast<size_t>(n) * batches * sizeof(float) * 2避免中间结果溢出。 - 带 stride 的一维 FFT 算子扩大 workspace 尺寸类型: 在
fft1_d_stride.cpp中,除inputSize、outputSize外,还将kernelWorkspaceSize与totalWorkspaceSize改为size_t,并对n使用static_cast<size_t>(...)。 - 二维 FFT 算子 workspace 尺寸改为
uint64_t: 在fft2_d_dd.cpp中,inputSize、outputSize改为size_t,workspaceSize改为uint64_t并通过static_cast<uint64_t>(batches)强制 64 位计算。 - 实数/逆实数 FFT 算子缓冲区尺寸改为
size_t: 在rfft1_d_r2c_fft.cpp、irfft1_d_c2r_fft.cpp、irfft1_d_fft.cpp中,将inputSize、outputSize及workspaceSize改为size_t,并对n或batches使用static_cast<size_t>(...)防止 32 位溢出。


atomgit-bot
12 天前 评论:
12 天前 评论:
12 天前 添加了label:cann-cla/yes
CANN-robot
12 天前 评论:
12 天前 评论:
CANN-robot
12 天前 评论:
12 天前 评论:
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.
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/ops-fft | ✅ 张浩, east_yang (2/2) | ✅ 张浩, east_yang (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)


12 天前 修改了pull request 的描述
此处折叠了19条事件消息 查看更多
12 天前 添加了label:cann-cla/yes
Tian_1122
12 天前 评论:
12 天前 评论:
compile


12 天前 添加了label:ci-pipeline-running
CANN-robot
12 天前 评论:
12 天前 评论:
流水线任务触发成功
任务链接 [878a2497ee164fb2aecc850e7bc9fdb7][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| Check_Pr | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| precommit | ✅ SUCCESS | >>>>> | |
| codecheck_codestyle | ✅ SUCCESS | >>>>> |
[2026-08-17 16:32:52] CI执行结束


12 天前 删除了label:ci-pipeline-running
12 天前 添加了label:ci-pipeline-passed
demoauguste
12 天前 评论:
12 天前 评论:
/lgtm
/approve


12 天前 添加了label:approved
12 天前 添加了label:lgtm
12 天前 关闭了关联的issue
12 天前 合入了pull request
当前PR是否有AI参与:
[x] 否
[ ] 是
__1. AI Agent 平台:
__2. AI 模型:
__3. Prompt上下文 :
PR功能描述 / 为什么需要这个合入**:
本 PR 修复 FFT 算子 host 侧缓冲区尺寸计算的整数溢出缺陷(9 处,8 文件,19±19 行)。
该PR关联的issue
(格式为fixes #<issue号>, 或者resolves #<issue号>): fixes #
fixes #22
fixes #23
fixes #24
fixes #25
fixes #26
fixes #31
fixes #32
fixes #33
fixes #34
希望检视人员了解:
改动类型 / Change Type
测试信息 / Testing
检查清单 / Checklist