Skip to content

Commit fbc183f

Browse files
JacobSzwejbkafacebook-github-bot
authored andcommitted
Dont generate a mutable segment if you ahve no mutable data (#4523)
Summary: Pull Request resolved: #4523 Forward on a None instead of a list with one elem Reviewed By: lucylq Differential Revision: D60678833 fbshipit-source-id: 6f6ca3999ea644a13c3374d9e60dd387499bea15
1 parent 738842d commit fbc183f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

exir/emit/_emit_program.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class EmitterOutput:
4545
str, Dict[int, Dict[str, Union[str, _DelegateDebugIdentifierMap]]]
4646
]
4747

48-
mutable_data: List[Buffer]
48+
mutable_data: Optional[List[Buffer]]
4949

5050

5151
def _remove_non_user_outputs(exported_program: ExportedProgram) -> torch.fx.GraphModule:
@@ -161,5 +161,9 @@ def emit_program(
161161
constant_segment=SubsegmentOffsets(segment_index=0, offsets=[]),
162162
mutable_data_segments=None, # Will be filled in during serialization
163163
),
164-
mutable_data=program_state.mutable_buffer,
164+
mutable_data=(
165+
program_state.mutable_buffer
166+
if len(program_state.mutable_buffer) > 1
167+
else None
168+
),
165169
)

0 commit comments

Comments
 (0)