Skip to content

#4913 - Preserve imported initializers when exporting - #4915

Open
0z5a wants to merge 1 commit into
NVIDIA:mainfrom
0z5a:fix-graphsurgeon-lazy-export
Open

0z5a wants to merge 1 commit into
NVIDIA:mainfrom
0z5a:fix-graphsurgeon-lazy-export

Conversation

@0z5a

@0z5a 0z5a commented Nov 4, 2026

Copy link
Copy Markdown

Summary

When a lazily imported constant is renamed, copy its ONNX TensorProto before applying the new name. This prevents export from mutating the initializer in the original input model while keeping values lazy. The existing fast path still reuses the protobuf when its name is unchanged.

Fixes #4913.

Validation

  • 288 non-example ONNX GraphSurgeon Python tests passed and one was skipped on CPU with ONNX 1.20.1. A regression test checks that both the original and exported models pass ONNX validation, the original bytes remain unchanged, and the value stays lazy; it fails on the original implementation.
  • The separate example tests were excluded because their subprocesses replace the environment and use a system Python without NumPy in this setup. The docs build and TensorRT sample tests were not run.

Draft while the issue awaits maintainer review under the contribution workflow.

Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
@0z5a
0z5a marked this pull request as ready for review November 5, 2026 22:00
@0z5a
0z5a requested a review from a team as a code owner November 5, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ONNX GraphSurgeon export mutates the original initializer when a constant is renamed

2 participants