Skip to content

Fix optional graph_signature access in memory planning #9325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions exir/memory_planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,7 @@ def verify_graph_input_output(self) -> None:
has_dynamic_unbound_output |= has_dynamic_unbound_tensor

# only check if inputs are allocated if there are user inputs:
user_inputs_exist = (
len(
list(
filter(
lambda input: input.kind == InputKind.USER_INPUT,
self.graph_signature.input_specs,
)
)
)
) > 0
user_inputs_exist = _do_user_inputs_exist(graph_signature=self.graph_signature)

if "placeholder" in check_list and user_inputs_exist:
assert graph_input_allocated is not None, "graph_input_allocated not set"
Expand Down Expand Up @@ -339,6 +330,22 @@ def _is_mutable_buffer(
return False


def _do_user_inputs_exist(graph_signature: Optional[ExportGraphSignature]) -> bool:
if graph_signature is None:
return False

return (
len(
list(
filter(
lambda input: input.kind == InputKind.USER_INPUT,
graph_signature.input_specs,
)
)
)
) > 0


def get_graph_input_tensors(
nodes: Iterable[Node], graph_signature: Optional[ExportGraphSignature] = None
) -> Set[TensorSpec]:
Expand Down
Loading