Repository navigation
[Core:Bugfix] 修复循环子模块输入复制缓存未刷新导致的 CIF 错误 - #5014
Merged
Merged
Conversation
vklonghml
force-pushed
the
feature/seaco-cif-shapes
branch
from
October 21, 2026 09:56
092454d to
ec3dd6a
Compare
wangzhaode
approved these changes
Oct 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
在 ARM64 CPU 的 low 精度模式下,SeACoParaformer 完整图对相同音频连续推理时,第一轮正常,第二轮 CIF 输出帧数可能从 14 变为 11,随后 decoder 报
Broad cast error, dim1 = 14, dim2 = 11。定位到 CIF 循环内部:累计权重为
0.994140625时,比较算子正确输出条件0,但后续 Select 的后端输入副本仍为上一轮的1,导致错误减去 1。encoder 和 predictor 两轮输出一致。StaticModule::_resize原来仅在输入Tensor*地址变化时将输入复制缓存标脏。同一输入对象内容更新,或循环临时对象释放后地址被复用,都不能通过地址比较可靠地检测。顶层 NetModule 每轮clearCache()掩盖了简单独立调用中的问题,而 WhileModule 连续调用内部子模块时会触发。修改
expr/ModuleInputCopyRefresh:构造Select(condition, 2, 3),模拟循环直接连续调用内部子模块,对同一输入对象交替写入 0/1,检查输出交替为 3/2。用固定对象复现,避免测试依赖分配器偶然复用地址。验证
基于 master
d662ce36175956038cfd6ed13f84cb3343a287d2,启用 ARM82、LOW_MEMORY、TRANSFORMER_FUSE 和 MNN 线程池;实际模型测试未开启 Session_Debug。expr/ModuleInputCopyRefresh、expr/ModuleShapeInfer、op/select、op/binary:normal/low 合计 90 次测试全部通过。单测命令:
./run_test.out expr/ModuleInputCopyRefresh 0 2 4 ./run_test.out expr/ModuleShapeInfer 0 2 4 ./run_test.out op/select 0 2 4 ./run_test.out op/binary 0 2 4 # 将 precision 参数 2 换为 0,重复 normal 对照。与已有修复的关系
本问题是输入内容变化但复制副本未更新,与 #4974 的 shape 输入内容缓存、#5006 的输入布局变化缓存失效不同。实际应用 #4974,或同时应用 #4974/#5006,均不能解决原始 CIF 重复调用失败。
本 PR 单独应用后,交替不同长度音频仍会遇到已有的 encoder 动态形状问题(94/132 帧,normal 也触发)。与 #4974 组合后,1/4 线程 × normal/low × 固定/交替长度共 8 组、80 次推理全部通过,相同音频的帧数、token 数和 token IDs 保持一致。本 PR 不重复纳入 #4974 的修改。