[Express:Bugfix] Fix loadMap/load output readMap returning NULL - #4751
Merged
wangzhaode merged 1 commit intoAug 12, 2026
Merged
Conversation
Collaborator
|
Thanks for the fix. Could you please make two cleanup changes before merging?
The functional fix itself looks reasonable. Thanks! |
Variable::load replaces non-INPUT tensors with Tensor::clone(allTensors[i]), which shares the source describe carrying memoryType=MEMORY_BACKEND (default), overwriting the MEMORY_HOST that Expr::create correctly set. As a result mapOutput's copy branch fails to allocate a host buffer and readMap() on the model output returns NULL. Fix: restore memoryType=MEMORY_HOST after the clone in Variable::load. Safe: the cloned tensor's host is null for non-CONST nodes (CONST/TRAIN nodes don't enter this branch), so restoring MEMORY_HOST cannot cause a double-free on destruction. Add regression test expr/LoadMapOutputReadMap. Fixes alibaba#4750
fshuang8299
force-pushed
the
fix/loadmap-output-readmap
branch
from
August 11, 2026 03:41
370542d to
316dade
Compare
Contributor
Author
|
Thanks for the review! Both cleanup changes are done:
Verified after rebase: |
wangzhaode
approved these changes
Aug 12, 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.
Description
Variable::load/Variable::loadMap加载的模型,输入可写(#4733 修复后)、推理可算,但输出
readMap返回 NULL——expressDemo修复 #4733 后不崩但仍无输出。Root cause:
Variable::load对非 INPUT 节点执行Tensor::clone(allTensors[i]),clone 共享源 describe(memoryType 默认 MEMORY_BACKEND),覆盖了
Expr::create正确设置的 MEMORY_HOST。
mapOutput拷贝分支(allocMemoryForHostTensor要求MEMORY_HOST)无法分配 host → readMap 返回 NULL。
Fix:clone 后恢复
memoryType = MEMORY_HOST(与 #4733 的 INPUT 分支同源修复)。Module
Express
Type
Checklist
[Module:Type] DescriptionformatReproduction
模型由代码生成,无需附件(完整可编译示例见 issue #4750)。核心流程:
Verification
expr/LoadMapOutputReadMap通过(独立验证)Scope
本 PR 严格限定 Express
Variable::load的输出路径(1 行修复 + 回归测试)。不影响:Module API / Session API / Const 节点 / 输入路径(#4733 已处理)。
Related