MCPcopy Create free account
hub / github.com/pytorch/executorch / _is_mutable_buffer

Function _is_mutable_buffer

exir/memory_planning.py:481–497  ·  view source on GitHub ↗

Check if the node is mutable buffer according to the provided graph signature.

(
    node: Node, graph_signature: Optional[ExportGraphSignature] = None
)

Source from the content-addressed store, hash-verified

479
480
481def _is_mutable_buffer(
482 node: Node, graph_signature: Optional[ExportGraphSignature] = None
483) -> bool:
484 """
485 Check if the node is mutable buffer according to the provided graph signature.
486 """
487 # graph signature is None for memory planning passes not called from EdgeProgramManager, these paths are deprecated so mutable buffers are not supported on them.
488 if graph_signature is None:
489 return False
490 if node.op == "placeholder":
491 if isinstance(node.target, str):
492 if node.target in graph_signature.inputs_to_buffers:
493 fqn = graph_signature.inputs_to_buffers[node.target]
494 # if the buffer is mutated then record that
495 if fqn in graph_signature.buffers_to_mutate.values():
496 return True
497 return False
498
499
500def _get_mutable_buffer_specs(

Callers 5

update_tensor_lifetimeFunction · 0.70
get_graph_input_tensorsFunction · 0.70
collect_specs_from_nodesFunction · 0.70

Calls 1

valuesMethod · 0.80

Tested by

no test coverage detected