Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 8 additions & 2 deletions backends/xnnpack/_passes/fuse_batch_norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,14 @@ def can_fuse(
return False

# Check the rank of the convolutution input - only Conv1d and 2d are supported.
if is_conv and len(input_node.args[0].meta["val"].shape) not in (3, 4):
return False
if is_conv:
conv_input = input_node.args[0]
if (
not isinstance(conv_input, torch.fx.Node)
or "val" not in conv_input.meta
or len(conv_input.meta["val"].shape) not in (3, 4)
):
return False

return True

Expand Down
2 changes: 1 addition & 1 deletion backends/xnnpack/test/passes/test_batch_norm_fusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(
self,
in_features: int,
out_features: int,
kernel_size: Tuple[int, int],
kernel_size: Tuple[int, int, int],
):
super().__init__()
op = torch.nn.Conv3d
Expand Down
Loading