Skip to content

Commit

Permalink
Create exceptions for spec.const in verify_graph_input_output (pytorc…
Browse files Browse the repository at this point in the history
…h#4083)

Summary:
Pull Request resolved: pytorch#4083

The ASR model triggered an edge case where when we run constant_prop_pass it creates a constant in the placeholders which is then directly returned as an output of the model. When this is done the check in `verify_graph_input_output` fails because for the placeholder constant that is returned as an output we have no mem_offset (as expected). In order to handle this case we'll filter out specs from this list that are constants and then do the checks.

Reviewed By: larryliu0820

Differential Revision: D59140916

fbshipit-source-id: 9a2fc99d36a1c53b06130c3bdef7f5ee2cd7c769
  • Loading branch information
tarun292 authored and facebook-github-bot committed Jul 12, 2024
1 parent e453652 commit f9efb05
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions exir/memory_planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ def verify_graph_input_output(self) -> None:
if _is_mutable_buffer(nd, self.graph_signature):
continue
assert len(specs) > 0, "Expect tensor specs"
specs = list(filter(lambda spec: not spec.const, specs))
if len(specs) == 0:
continue
allocated = any(
spec is None or spec.mem_offset is not None for spec in specs
)
Expand Down

0 comments on commit f9efb05

Please sign in to comment.