MCPcopy Create free account
hub / github.com/pytorch/executorch / _convolution_handler

Function _convolution_handler

backends/mlx/ops.py:2573–2617  ·  view source on GitHub ↗

Handle aten.convolution.default — the unified convolution op. Args layout: convolution(input, weight, bias, stride, padding, dilation, transposed, output_padding, groups) This op appears when PyTorch doesn't decompose to specific conv ops (e.g. grouped conv

(P: MLXProgramBuilder, n: Node)

Source from the content-addressed store, hash-verified

2571
2572@REGISTRY.register(target=[torch.ops.aten.convolution.default])
2573def _convolution_handler(P: MLXProgramBuilder, n: Node) -> Slot:
2574 """Handle aten.convolution.default — the unified convolution op.
2575
2576 Args layout: convolution(input, weight, bias, stride, padding, dilation,
2577 transposed, output_padding, groups)
2578
2579 This op appears when PyTorch doesn't decompose to specific conv ops
2580 (e.g. grouped conv_transpose).
2581 """
2582 raw_args = n.args
2583 x_node, w_node = raw_args[0], raw_args[1]
2584 bias_node = raw_args[2] if len(raw_args) > 2 else None
2585 transposed = raw_args[6] if len(raw_args) > 6 else False
2586 groups = raw_args[8] if len(raw_args) > 8 else 1
2587
2588 if not transposed:
2589 raise ValueError(
2590 "aten.convolution with transposed=False: use aten.conv{1,2,3}d instead"
2591 )
2592
2593 x_meta = x_node.meta.get("val")
2594 if x_meta is None:
2595 raise ValueError("aten.convolution: input shape metadata required")
2596 ndim = len(x_meta.shape) - 2
2597
2598 stride = _normalize_conv_param(raw_args[3] if len(raw_args) > 3 else 1, ndim, 1)
2599 padding = _normalize_conv_param(raw_args[4] if len(raw_args) > 4 else 0, ndim, 0)
2600 dilation = _normalize_conv_param(raw_args[5] if len(raw_args) > 5 else 1, ndim, 1)
2601 output_padding = _normalize_conv_param(
2602 raw_args[7] if len(raw_args) > 7 else 0, ndim, 0
2603 )
2604
2605 return _emit_conv_transpose(
2606 P,
2607 n,
2608 x_node,
2609 w_node,
2610 bias_node,
2611 stride,
2612 padding,
2613 dilation,
2614 output_padding,
2615 groups,
2616 ndim,
2617 )
2618
2619
2620@REGISTRY.register(target=[torch.ops.aten.conv_transpose1d.default])

Callers

nothing calls this directly

Calls 3

_normalize_conv_paramFunction · 0.85
_emit_conv_transposeFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected