Skip to content
Open
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
17 changes: 17 additions & 0 deletions backends/vulkan/op_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1735,13 +1735,30 @@ def register_embedding_q4gsw():
# =============================================================================


def _check_batch_norm_is_4d(node: torch.fx.Node) -> bool:
"""Only support batch norm on a 4d input.

add_native_batch_norm_node() asserts
VK_CHECK_COND(in_sizes.size() == 4, "BatchNorm only support 4d tensor") on
both the input and the output, so partitioning a batch norm whose input is
not 4d yields a .pte that lowers cleanly and then aborts at execute time.
Any conv1d model reaches here with rank-3 activations.
"""
input_node = node.args[0]
if not isinstance(input_node, torch.fx.Node):
return False
val = input_node.meta.get("val")
return val is not None and val.dim() == 4


@update_features(exir_ops.edge.aten._native_batch_norm_legit_no_training.default)
def register_native_batch_norm_legit_no_training():
return OpFeatures(
inputs_storage=utils.CHANNELS_PACKED_TEXTURE,
inputs_dtypes=utils.FP_T,
supports_prepacking=True,
supports_resize=True,
are_node_inputs_supported_fn=_check_batch_norm_is_4d,
)


Expand Down
Loading