Check if the node is mutable buffer according to the provided graph signature.
(
node: Node, graph_signature: Optional[ExportGraphSignature] = None
)
| 479 | |
| 480 | |
| 481 | def _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 | |
| 500 | def _get_mutable_buffer_specs( |
no test coverage detected