Skip to content

Commit 1fdd466

Browse files
authored
Arm backend: Fix for tensor capture in quantization assessment. (#24279)
Fix bug in the assessment tool. cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani Signed-off-by: Elena Zhelezina <elena.zhelezina@arm.com>
1 parent e62fd44 commit 1fdd466

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎backends/arm/vgf/quantization_assessment.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
from torch.export import ExportedProgram
3333
from torch.fx import GraphModule, Interpreter, Node
3434

35+
from torch.utils._pytree import tree_map
36+
3537

3638
GraphInput = ExportedProgram | GraphModule
3739

@@ -187,8 +189,13 @@ def __init__(self, module: GraphModule, capture_node_names: set[str]) -> None:
187189

188190
def run_node(self, node: Node) -> Any:
189191
value = super().run_node(node)
192+
190193
if node.name in self._capture_node_names:
191-
self.captured[node.name] = value
194+
self.captured[node.name] = tree_map(
195+
lambda x: (x.detach().clone() if isinstance(x, torch.Tensor) else x),
196+
value,
197+
)
198+
192199
return value
193200

194201

0 commit comments

Comments
 (0)