Skip to content

Commit cce75a3

Browse files
mcremon-metafacebook-github-bot
authored andcommitted
Bugfixes for CadenceWakeWordQuantizer
Summary: Fixes a bug introducing empty cat operators in the quantizer, and one where the output of a pass is not serializable. Differential Revision: D95961290
1 parent 286ccef commit cce75a3

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

backends/cadence/aot/quantizer/fusion_pass.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,9 @@ def call(self, graph_module: fx.GraphModule) -> PassResult: # noqa: C901
563563
quant_node,
564564
)
565565
elif isinstance(pattern, CatPattern):
566+
# Skip fusion if inputs_inputs is empty to avoid creating cat([])
567+
if not inputs_inputs:
568+
continue
566569
args, kwargs = get_args_and_kwargs_cat(
567570
inputs_inputs, other_inputs, op_node
568571
)

backends/cadence/aot/replace_ops.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,8 +2368,16 @@ def maybe_remove_or_replace(self, node: torch.fx.Node) -> bool:
23682368
args=([1], full_arg),
23692369
kwargs={"dtype": full_output_dtype},
23702370
)
2371-
full_node.meta = node.meta
2372-
full_node.meta["val"] = [1]
2371+
full_node.meta = node.meta.copy()
2372+
# Create a proper FakeTensor for metadata instead of Python list
2373+
fake_mode = node.meta["val"].fake_mode
2374+
if fake_mode is not None:
2375+
with fake_mode:
2376+
full_node.meta["val"] = torch.full(
2377+
[1], full_arg, dtype=full_output_dtype
2378+
)
2379+
else:
2380+
full_node.meta["val"] = torch.empty([1], dtype=full_output_dtype, device="meta")
23732381
new_mul_node = node.graph.call_function(
23742382
torch.ops.aten.mul.Tensor, args=(x_arg, full_node)
23752383
)

0 commit comments

Comments
 (0)