Skip to content

[mkldnn][11/N] Port ideep convolution backward ops into ATen - #201229

Closed
frost-intel wants to merge 6 commits into
pytorch:mainfrom
frost-intel:ideep-removal/12-port-conv-backward
Closed

frost-intel wants to merge 6 commits into
pytorch:mainfrom
frost-intel:ideep-removal/12-port-conv-backward

Conversation

@frost-intel

@frost-intel frost-intel commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Linked issue or supporting maintainer

Part of #154444

BC-breaking?

No

Summary (human written only)

Port of the convolution backward ops from ideep to ATen. Unused params and functions were dropped, but otherwise this is a line-for-line port with identical functionality, verified by tests and onednn_verbose log checking.

Depends on #201224

Fake stack

Agent details (if applicable)

Developed with assistance from Claude Opus 5.5.

Ports the floating-point convolution backward operators that ATen uses from ideep (ideep::convolution_backward_data, ideep::convolution_backward_weights) into aten/src/ATen/native/mkldnn/detail/Conv.{h,cpp} (namespace at::native::mkldnn), based on #201224 (conv forward). The port is line-for-line and changes no behavior: it still takes ideep::tensor / ideep::attr_t and uses ideep's engine and stream.

This is one of the convolution PRs (split for size). It builds on the forward PR, #201224, and adds the backward functions to the same detail/Conv.{h,cpp}.

Ported

Public (detail/Conv.h):

  • convolution_backward_data_compute_v2 (ideep::attr_t op_attr by value, as in ideep)
  • convolution_backward_weights_compute_v2: with and without bias

File-local (detail/Conv.cpp):

  • backward_weights_compute_impl<with_diff_bias>: ideep's convolution_backward_weights::compute_impl, renamed to avoid clashing with the forward helpers.

Both functions keep ideep's aarch64 and x86 primitive-descriptor variants.

The forward primitive descriptor used as a hint comes from the ported get_primitive_desc, exactly as ideep's backward does. On x86 that lookup goes through ideep's forward primitive cache, as before.

Call sites switched

  • mkldnn/Conv.cpp: mkldnn_convolution_backward_input (backward data) and mkldnn_convolution_backward_weights (with and without bias).

Dropped (no ATen callers / unused)

  • The algorithm parameter of both functions; it was always convolution_direct, which is now fixed locally.
  • The engine parameters.
  • Backward weights: diff_weight_type and the branch that only ran with a non-default value.

Other changes

  • IDEEP_CHECK (bf16/f16 on avx2_vnni_2) becomes an unconditional dnnl::error::wrap_c_api, as in ideep. IDEEP_ENFORCE becomes debug-only (#ifndef NDEBUG), as in ideep.
  • Called directly from ideep for now: ideep::utils::get_compatible_dilates.

Testing

oneDNN verbose logs (ONEDNN_VERBOSE=1, timings stripped, sorted counts) are identical before and after:

  • test_mkldnn.py plus test_freezing.py -k mkldnn: 6,572 distinct lines, 1,494 of them convolution backward.
  • quantization/core/test_quantized_op.py -k "qconv and pt2e and not fp8": 257 distinct lines.
  • nn/test_convolution.py -k mkldnn and the Inductor mkldnn pattern tests: covered by the whole-series A/B comparison against main in [mkldnn][22/22] Remove the ideep submodule #204808, with identical per-test outcomes and identical oneDNN primitive logs. (test_mkldnn_fusion.py no longer exists upstream.)

(test/jit/test_freezing.py was later deleted upstream by #203621. The final A/B comparison of the whole series against main, described in #204808, re-checks these paths without it.)

cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @aditew01

@pytorch-bot pytorch-bot Bot added module: cpu CPU specific problem (e.g., perf, algorithm) release notes: quantization release notes category labels Oct 16, 2026
@frost-intel frost-intel changed the title Port ideep convoluiton backward ops into ATen [mkldnn][11/N] Port ideep convoluiton backward ops into ATen Oct 16, 2026
@pytorch-bot

pytorch-bot Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/201229

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure

As of commit 947ea10 with merge base 780bf8e (image):

NEW FAILURE - The following job has failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

Part of pytorch#154444.

Replace ideep type aliases with the oneDNN (or std) types they name.
Each is a plain `using` in ideep, so this is a pure spelling change
with no effect on generated code. It removes about a third of the
remaining ideep references from ATen CPU code.
Part of pytorch#154444. Move ideep::eltwise_forward/backward into aten.
Switch all CPU callers (relu, sigmoid, tanh, gelu, scalar mul,
dense GELU, JIT frozen scalar mul). Line-for-line port.
Part of pytorch#154444. Depends on pytorch#201055.

Port the floating-point convolution forward, backward-data and
backward-weights operators ATen uses from ideep into
aten/src/ATen/native/mkldnn/detail/Conv.{h,cpp}. The port is
line-for-line, still takes ideep::tensor/attr_t, and shares ideep's
primitive cache, so behavior is unchanged.

Switch the call sites in mkldnn/Conv.cpp, ConvPrepack.cpp,
MKLDNNConversions.cpp and quantized/cpu/qconv_prepack.cpp
(expected_weights_desc only). Quantized prepare/compute and transposed
convolution remain on ideep for now.

Drop code ATen never reaches: use_gemm, unused overloads/parameters,
backward_weights' diff_weight_type, and the fixed algorithm parameter on
backward. Remove an unused variable and fix sign-compare loop indices
that surface outside ideep's system-header include.
Keep only the fp32 forward port (compute_v3, compute_binary,
expected_weights_desc and their helpers) to stay under the PR size limit.
Backward data/weights and compute_v2 with its int8 prepare_parameters /
compute_dispatch path move to separate PRs; their call sites in
mkldnn/Conv.cpp and ConvPrepack.cpp go back to ideep until those land.
Part of pytorch#154444. Depends on pytorch#201055.

Port convolution_backward_data::compute_v2 and
convolution_backward_weights::compute_v2 (with its compute_impl) into
aten/src/ATen/native/mkldnn/detail/ConvBackward.{h,cpp}. The port is
line-for-line and still takes ideep::tensor/attr_t. As in ideep, the
forward hint comes from ideep::convolution_forward::get_primitive_desc.

Switch the backward call sites in mkldnn/Conv.cpp. Drop the fixed
algorithm parameter, the engine parameters, and backward_weights'
unused diff_weight_type branch.
…rimitive_desc

Base this PR on the conv forward port (pytorch#201224) instead of PR 3. The
backward data/weights port now lives in detail/Conv.{h,cpp} next to the
forward code, as in ideep's conv.hpp, and its forward hint calls the
ported get_primitive_desc instead of ideep::convolution_forward::
get_primitive_desc. detail/ConvBackward.{h,cpp} are removed.
pytorchmergebot pushed a commit that referenced this pull request Nov 19, 2026
…1053)

## Linked issue or supporting maintainer
Part of #154444

## BC-breaking?
No

## Summary (human written only)
See #154444 for ideep removal discussion.
Replace ideep type aliases with the oneDNN or std types they name. Each is a plain `using` in ideep, so this is a pure spelling change with no effect on generated code. It removes about a third of the remaining ideep references from ATen CPU code.

#### Fake Stack
* #201052
* -> #201053
* Port ops:
* #201055
* #201059
* #201062
* #201080
* #201083
* #201126
* #201194
* #201224
* #201229
* #202547
* #202611
* #202622
* #203645
* #204617
* #204615
* Port classes and utils:
* #204801
* #204805
* #204806
* #204807
* Final removal:
* #204808

## Agent details (if applicable)

Developed with assistance from Claude Opus 5.5
Summary:
> Replace ideep type aliases with the oneDNN (or std) types they name:
> data_type, dims, format_tag/tag, prop_kind, algorithm, scale_t,
> zero_point_t and exec_args. Each is a plain `using` in ideep, so this is
> a pure spelling change with no effect on generated code. It removes
> about a third of the remaining ideep references from ATen CPU code
> without touching any ideep-specific behavior.

Pull Request resolved: #201053
Approved by: https://github.com/albanD, https://github.com/malfet
@frost-intel

Copy link
Copy Markdown
Collaborator Author

Moved to ghstack:
#205709

frost-intel added a commit that referenced this pull request Nov 19, 2026
## Linked issue or supporting maintainer
Part of #154444

## BC-breaking?
No

## Summary (human written only)
Port of the convolution backward ops from ideep to ATen. Unused params and functions were dropped, but otherwise this is a line-for-line port with identical functionality, verified by tests and onednn_verbose log checking.

Depends on #201224


## Agent details (if applicable)
Developed with assistance from Claude Opus 5.5.

>
> Ports the floating-point convolution **backward** operators that ATen uses from ideep (`ideep::convolution_backward_data`, `ideep::convolution_backward_weights`) into `aten/src/ATen/native/mkldnn/detail/Conv.{h,cpp}` (namespace `at::native::mkldnn`), based on #201224 (conv forward). The port is line-for-line and changes no behavior: it still takes `ideep::tensor` / `ideep::attr_t` and uses ideep's engine and stream.
>
> This is one of the convolution PRs (split for size). It builds on the forward PR, #201224, and adds the backward functions to the same `detail/Conv.{h,cpp}`.
>
> ### Ported
> Public (`detail/Conv.h`):
> - `convolution_backward_data_compute_v2` (`ideep::attr_t op_attr` by value, as in ideep)
> - `convolution_backward_weights_compute_v2`: with and without bias
>
> File-local (`detail/Conv.cpp`):
> - `backward_weights_compute_impl<with_diff_bias>`: ideep's `convolution_backward_weights::compute_impl`, renamed to avoid clashing with the forward helpers.
>
> Both functions keep ideep's aarch64 and x86 primitive-descriptor variants.
>
> The forward primitive descriptor used as a hint comes from the ported `get_primitive_desc`, exactly as ideep's backward does. On x86 that lookup goes through ideep's forward primitive cache, as before.
>
> ### Call sites switched
> - `mkldnn/Conv.cpp`: `mkldnn_convolution_backward_input` (backward data) and `mkldnn_convolution_backward_weights` (with and without bias).
>
> ### Dropped (no ATen callers / unused)
> - The `algorithm` parameter of both functions; it was always `convolution_direct`, which is now fixed locally.
> - The `engine` parameters.
> - Backward weights: `diff_weight_type` and the branch that only ran with a non-default value.
>
> ### Other changes
> - `IDEEP_CHECK` (bf16/f16 on avx2_vnni_2) becomes an unconditional `dnnl::error::wrap_c_api`, as in ideep. ideep's backward functions have no `IDEEP_ENFORCE`, so there is no debug-only check here.
> - Called directly from ideep for now: `ideep::utils::get_compatible_dilates`.
>
> ### Testing
> oneDNN verbose logs (`ONEDNN_VERBOSE=1`, timings stripped, sorted counts) are identical before and after:
> - `test_mkldnn.py` plus `test_freezing.py -k mkldnn`: 6,572 distinct lines, 1,494 of them convolution backward.
> - `quantization/core/test_quantized_op.py -k "qconv and pt2e and not fp8"`: 257 distinct lines.
> - `nn/test_convolution.py -k mkldnn` and the Inductor mkldnn pattern tests: covered by the whole-series A/B comparison against `main` in #204808, with identical per-test outcomes and identical oneDNN primitive logs. (`test_mkldnn_fusion.py` no longer exists upstream.)
>
> (`test/jit/test_freezing.py` was later deleted upstream by #203621. The final A/B comparison of the whole series against `main`, described in #204808, re-checks these paths without it.)
>
> Previously submitted as #201229.

cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10 aditew01


ghstack-source-id: 1b60cfc
Pull-Request: #205717
frost-intel added a commit that referenced this pull request Nov 19, 2026
## Linked issue or supporting maintainer
Part of #154444

## BC-breaking?
No

## Summary (human written only)
Port of the convolution backward ops from ideep to ATen. Unused params and functions were dropped, but otherwise this is a line-for-line port with identical functionality, verified by tests and onednn_verbose log checking.

Depends on #201224

## Agent details (if applicable)
Developed with assistance from Claude Opus 5.5.

>
> Ports the floating-point convolution **backward** operators that ATen uses from ideep (`ideep::convolution_backward_data`, `ideep::convolution_backward_weights`) into `aten/src/ATen/native/mkldnn/detail/Conv.{h,cpp}` (namespace `at::native::mkldnn`), based on #201224 (conv forward). The port is line-for-line and changes no behavior: it still takes `ideep::tensor` / `ideep::attr_t` and uses ideep's engine and stream.
>
> This is one of the convolution PRs (split for size). It builds on the forward PR, #201224, and adds the backward functions to the same `detail/Conv.{h,cpp}`.
>
> ### Ported
> Public (`detail/Conv.h`):
> - `convolution_backward_data_compute_v2` (`ideep::attr_t op_attr` by value, as in ideep)
> - `convolution_backward_weights_compute_v2`: with and without bias
>
> File-local (`detail/Conv.cpp`):
> - `backward_weights_compute_impl<with_diff_bias>`: ideep's `convolution_backward_weights::compute_impl`, renamed to avoid clashing with the forward helpers.
>
> Both functions keep ideep's aarch64 and x86 primitive-descriptor variants.
>
> The forward primitive descriptor used as a hint comes from the ported `get_primitive_desc`, exactly as ideep's backward does. On x86 that lookup goes through ideep's forward primitive cache, as before.
>
> ### Call sites switched
> - `mkldnn/Conv.cpp`: `mkldnn_convolution_backward_input` (backward data) and `mkldnn_convolution_backward_weights` (with and without bias).
>
> ### Dropped (no ATen callers / unused)
> - The `algorithm` parameter of both functions; it was always `convolution_direct`, which is now fixed locally.
> - The `engine` parameters.
> - Backward weights: `diff_weight_type` and the branch that only ran with a non-default value.
>
> ### Other changes
> - `IDEEP_CHECK` (bf16/f16 on avx2_vnni_2) becomes an unconditional `dnnl::error::wrap_c_api`, as in ideep. ideep's backward functions have no `IDEEP_ENFORCE`, so there is no debug-only check here.
> - Called directly from ideep for now: `ideep::utils::get_compatible_dilates`.
>
> ### Testing
> oneDNN verbose logs (`ONEDNN_VERBOSE=1`, timings stripped, sorted counts) are identical before and after:
> - `test_mkldnn.py` plus `test_freezing.py -k mkldnn`: 6,572 distinct lines, 1,494 of them convolution backward.
> - `quantization/core/test_quantized_op.py -k "qconv and pt2e and not fp8"`: 257 distinct lines.
> - `nn/test_convolution.py -k mkldnn` and the Inductor mkldnn pattern tests: covered by the whole-series A/B comparison against `main` in #204808, with identical per-test outcomes and identical oneDNN primitive logs. (`test_mkldnn_fusion.py` no longer exists upstream.)
>
> (`test/jit/test_freezing.py` was later deleted upstream by #203621. The final A/B comparison of the whole series against `main`, described in #204808, re-checks these paths without it.)
>
> Previously submitted as #201229.

cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10 aditew01

ghstack-source-id: 179ae13
Pull-Request: #205717
frost-intel added a commit that referenced this pull request Nov 19, 2026
## Linked issue or supporting maintainer
Part of #154444

## BC-breaking?
No

## Summary (human written only)
Port of the convolution backward ops from ideep to ATen. Unused params and functions were dropped, but otherwise this is a line-for-line port with identical functionality, verified by tests and onednn_verbose log checking.

## Agent details (if applicable)
Developed with assistance from Claude Opus 5.5.

>
> Ports the floating-point convolution **backward** operators that ATen uses from ideep (`ideep::convolution_backward_data`, `ideep::convolution_backward_weights`) into `aten/src/ATen/native/mkldnn/detail/Conv.{h,cpp}` (namespace `at::native::mkldnn`), based on #201224 (conv forward). The port is line-for-line and changes no behavior: it still takes `ideep::tensor` / `ideep::attr_t` and uses ideep's engine and stream.
>
> This is one of the convolution PRs (split for size). It adds the backward functions to the same `detail/Conv.{h,cpp}` as the forward port.
>
> ### Ported
> Public (`detail/Conv.h`):
> - `convolution_backward_data_compute_v2` (`ideep::attr_t op_attr` by value, as in ideep)
> - `convolution_backward_weights_compute_v2`: with and without bias
>
> File-local (`detail/Conv.cpp`):
> - `backward_weights_compute_impl<with_diff_bias>`: ideep's `convolution_backward_weights::compute_impl`, renamed to avoid clashing with the forward helpers.
>
> Both functions keep ideep's aarch64 and x86 primitive-descriptor variants.
>
> The forward primitive descriptor used as a hint comes from the ported `get_primitive_desc`, exactly as ideep's backward does. On x86 that lookup goes through ideep's forward primitive cache, as before.
>
> ### Call sites switched
> - `mkldnn/Conv.cpp`: `mkldnn_convolution_backward_input` (backward data) and `mkldnn_convolution_backward_weights` (with and without bias).
>
> ### Dropped (no ATen callers / unused)
> - The `algorithm` parameter of both functions; it was always `convolution_direct`, which is now fixed locally.
> - The `engine` parameters.
> - Backward weights: `diff_weight_type` and the branch that only ran with a non-default value.
>
> ### Other changes
> - `IDEEP_CHECK` (bf16/f16 on avx2_vnni_2) becomes an unconditional `dnnl::error::wrap_c_api`, as in ideep. ideep's backward functions have no `IDEEP_ENFORCE`, so there is no debug-only check here.
> - Called directly from ideep for now: `ideep::utils::get_compatible_dilates`.
>
> ### Testing
> oneDNN verbose logs (`ONEDNN_VERBOSE=1`, timings stripped, sorted counts) are identical before and after:
> - `test_mkldnn.py` plus `test_freezing.py -k mkldnn`: 6,572 distinct lines, 1,494 of them convolution backward.
> - `quantization/core/test_quantized_op.py -k "qconv and pt2e and not fp8"`: 257 distinct lines.
> - `nn/test_convolution.py -k mkldnn` and the Inductor mkldnn pattern tests: covered by the whole-series A/B comparison against `main` in #204808, with identical per-test outcomes and identical oneDNN primitive logs. (`test_mkldnn_fusion.py` no longer exists upstream.)
>
> (`test/jit/test_freezing.py` was later deleted upstream by #203621. The final A/B comparison of the whole series against `main`, described in #204808, re-checks these paths without it.)
>
> Previously submitted as #201229.

cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10 aditew01

ghstack-source-id: e46f8da
Pull-Request: #205717
frost-intel added a commit that referenced this pull request Nov 19, 2026
## Linked issue or supporting maintainer
Part of #154444

## BC-breaking?
No

## Summary (human written only)
Port of the convolution backward ops from ideep to ATen. Unused params and functions were dropped, but otherwise this is a line-for-line port with identical functionality, verified by tests and onednn_verbose log checking.

## Agent details (if applicable)
Developed with assistance from Claude Opus 5.5.

>
> Ports the floating-point convolution **backward** operators that ATen uses from ideep (`ideep::convolution_backward_data`, `ideep::convolution_backward_weights`) into `aten/src/ATen/native/mkldnn/detail/Conv.{h,cpp}` (namespace `at::native::mkldnn`), based on #201224 (conv forward). The port is line-for-line and changes no behavior: it still takes `ideep::tensor` / `ideep::attr_t` and uses ideep's engine and stream.
>
> This is one of the convolution PRs (split for size). It adds the backward functions to the same `detail/Conv.{h,cpp}` as the forward port.
>
> ### Ported
> Public (`detail/Conv.h`):
> - `convolution_backward_data_compute_v2` (`ideep::attr_t op_attr` by value, as in ideep)
> - `convolution_backward_weights_compute_v2`: with and without bias
>
> File-local (`detail/Conv.cpp`):
> - `backward_weights_compute_impl<with_diff_bias>`: ideep's `convolution_backward_weights::compute_impl`, renamed to avoid clashing with the forward helpers.
>
> Both functions keep ideep's aarch64 and x86 primitive-descriptor variants.
>
> The forward primitive descriptor used as a hint comes from the ported `get_primitive_desc`, exactly as ideep's backward does. On x86 that lookup goes through ideep's forward primitive cache, as before.
>
> ### Call sites switched
> - `mkldnn/Conv.cpp`: `mkldnn_convolution_backward_input` (backward data) and `mkldnn_convolution_backward_weights` (with and without bias).
>
> ### Dropped (no ATen callers / unused)
> - The `algorithm` parameter of both functions; it was always `convolution_direct`, which is now fixed locally.
> - The `engine` parameters.
> - Backward weights: `diff_weight_type` and the branch that only ran with a non-default value.
>
> ### Other changes
> - `IDEEP_CHECK` (bf16/f16 on avx2_vnni_2) becomes an unconditional `dnnl::error::wrap_c_api`, as in ideep. ideep's backward functions have no `IDEEP_ENFORCE`, so there is no debug-only check here.
> - Called directly from ideep for now: `ideep::utils::get_compatible_dilates`.
>
> ### Testing
> oneDNN verbose logs (`ONEDNN_VERBOSE=1`, timings stripped, sorted counts) are identical before and after:
> - `test_mkldnn.py` plus `test_freezing.py -k mkldnn`: 6,572 distinct lines, 1,494 of them convolution backward.
> - `quantization/core/test_quantized_op.py -k "qconv and pt2e and not fp8"`: 257 distinct lines.
> - `nn/test_convolution.py -k mkldnn` and the Inductor mkldnn pattern tests: covered by the whole-series A/B comparison against `main` in #204808, with identical per-test outcomes and identical oneDNN primitive logs. (`test_mkldnn_fusion.py` no longer exists upstream.)
>
> (`test/jit/test_freezing.py` was later deleted upstream by #203621. The final A/B comparison of the whole series against `main`, described in #204808, re-checks these paths without it.)
>
> Previously submitted as #201229.

cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10 aditew01

ghstack-source-id: 1ec1529
Pull-Request: #205717
pytorchmergebot pushed a commit that referenced this pull request Nov 20, 2026
## Linked issue or supporting maintainer
Part of #154444

## BC-breaking?
No

## Summary (human written only)
Ports floating-point conv **forward** operators from ideep.  Only ops called within ATen are ported over. Backward and quantized ops are left for a follow-up PR

Ports are line-for-line and do not change any behavior.

## Agent details (if applicable)
Developed with assistance from Claude Opus 5.5.

> Ports the floating-point convolution **forward** operators that ATen uses from ideep (`ideep::convolution_forward`) into `aten/src/ATen/native/mkldnn/detail/Conv.{h,cpp}` (namespace `at::native::mkldnn`). The port is line-for-line and changes no behavior: it still takes `ideep::tensor` / `ideep::attr_t` and uses ideep's engine, stream and primitive cache.
>
> To stay under the PR size limit, convolution is split across three PRs:
> - **This PR:** fp32 forward.
> - **#201229, backward:** `convolution_backward_data` / `convolution_backward_weights`, in `detail/Conv.{h,cpp}`.
> - **#202611, `compute_v2`:** ideep's deprecated `compute_v2` and the int8 `prepare_parameters` / `compute_dispatch` it routes through. Used only by `ConvPrepack.cpp`. Stacked on this PR.
>
> ### Ported
> Public (`detail/Conv.h`), each with ideep's comment:
> - `convolution_forward_compute_v3`: with and without bias.
> - `convolution_forward_compute_binary<reorder_src, reorder_weight>`: with and without bias. Explicitly instantiated for `<true, true>`, the only combination ATen uses.
> - `convolution_forward_expected_weights_desc`: the overload that takes `is_channels_last` at runtime.
>
> File-local (`detail/Conv.cpp`), same names as in ideep:
> - `convolution_forward_params`
> - `conv_deconv_utils::prepare_parameters` (fp32 overload)
> - `get_primitive_desc`: the uncached aarch64 variant and the cached x86 variant
> - `expected_weights_desc<is_channels_last>`
> - `do_compute`, `do_compute_binary`
> - `compute_dispatch` (fp32)
> - `do_prepare` (fp32)
> - `compute_binary_dispatch`
>
> ### Call sites switched
> - `mkldnn/Conv.cpp`: `compute_v3` ×2, `compute_binary` ×2.
> - `mkldnn/ConvPrepack.cpp`: `expected_weights_desc`.
> - `mkldnn/MKLDNNConversions.cpp`: `expected_weights_desc` ×2 (conv2d/conv3d weight reorder).
> - `quantized/cpu/qconv_prepack.cpp`: `expected_weights_desc` ×2. This is a quantized file, but the call is the same fp `expected_weights_desc` overload.
>
> Still on ideep:
> - backward data and weights (backward PR)
> - `ConvPrepack.cpp` `compute_v2` (`compute_v2` PR)
> - quantized `prepare` / `compute` in `qconv.cpp`
> - transposed convolution
> - `t_store().clear()` in `IDeepRegistration.cpp`
>
> ### Dropped (no ATen callers / unused)
> - `convolution_forward::use_gemm`
> - unused overloads, and the `engine` / `lowp_kind` parameters on the public functions
> - the int8 `do_prepare` and the param-based `prepare` / `compute(params, ...)` overloads (moving with quantized conv)
>
> ### Other changes
> - `IDEEP_ENFORCE` becomes a debug-only `dnnl::error::wrap_c_api(...)` under `#ifndef NDEBUG`. `IDEEP_CHECK` becomes an unconditional `wrap_c_api`. Both behave as in ideep.
> - Called directly from ideep for now: `ideep::utils::get_compatible_dilates`, `ideep::utils::group_dims`, `ideep::utils::create_key`, `ideep::utils::computation_cache`.
> - The primitive cache is ideep's thread-local `computation_cache<dnnl::convolution_forward::primitive_desc>`, the same store ideep uses. `clear_computation_cache()` therefore needs no change.
> - Two loop indices in `expected_weights_desc` changed from `int` to `size_t` (sign-compare; ideep hides this as a system header).
> - Fixed typos in a comment copied from ideep: "workaroud", "detials", "weihgts".
>
> ### Testing
> oneDNN verbose logs (`ONEDNN_VERBOSE=1`, timings stripped, sorted counts) are identical before and after:
> - `test_mkldnn.py` plus `test_freezing.py -k mkldnn`: 6,572 distinct lines.
> - `quantization/core/test_quantized_op.py -k "qconv and pt2e and not fp8"`: 257 distinct lines.
> - `test_mkldnn_fusion.py`, `nn/test_convolution.py -k mkldnn`, and `inductor/test_mkldnn_pattern_matcher.py -k "conv and not qconv and not quant and not woq"`: 1,284 distinct lines, 772 of them convolution.
>
> Four Inductor tests fail identically with and without this change: `test_conv{2,3}d_binary_broadcast_shapes_cpu` and `test_conv_transpose{2,3}d_unary_cpu`, all with bf16 tolerance errors. `test_conv2d_unary_cpu` is flaky at its fp32 tolerance.
>
> Convolution is split across PRs for size: forward (#201224), backward (#201229), `compute_v2` (#202611), quantized (#202622) and transposed (#203645). Backward lives in `detail/Conv.{h,cpp}` alongside forward.
>
> (`test/jit/test_freezing.py` and `test/test_mkldnn_fusion.py` were later deleted upstream by #203621. The final A/B comparison of the whole series against `main`, described in #204808, re-checks these paths without it.)
>
> Previously submitted as #201224.

Pull Request resolved: #205716
Approved by: https://github.com/albanD
ghstack dependencies: #205709, #205710, #205711, #205712, #205713, #205714, #205715
pytorchmergebot pushed a commit that referenced this pull request Nov 20, 2026
## Linked issue or supporting maintainer
Part of #154444

## BC-breaking?
No

## Summary (human written only)
Port of the convolution backward ops from ideep to ATen. Unused params and functions were dropped, but otherwise this is a line-for-line port with identical functionality, verified by tests and onednn_verbose log checking.

## Agent details (if applicable)
Developed with assistance from Claude Opus 5.5.

>
> Ports the floating-point convolution **backward** operators that ATen uses from ideep (`ideep::convolution_backward_data`, `ideep::convolution_backward_weights`) into `aten/src/ATen/native/mkldnn/detail/Conv.{h,cpp}` (namespace `at::native::mkldnn`), based on #201224 (conv forward). The port is line-for-line and changes no behavior: it still takes `ideep::tensor` / `ideep::attr_t` and uses ideep's engine and stream.
>
> This is one of the convolution PRs (split for size). It adds the backward functions to the same `detail/Conv.{h,cpp}` as the forward port.
>
> ### Ported
> Public (`detail/Conv.h`):
> - `convolution_backward_data_compute_v2` (`ideep::attr_t op_attr` by value, as in ideep)
> - `convolution_backward_weights_compute_v2`: with and without bias
>
> File-local (`detail/Conv.cpp`):
> - `backward_weights_compute_impl<with_diff_bias>`: ideep's `convolution_backward_weights::compute_impl`, renamed to avoid clashing with the forward helpers.
>
> Both functions keep ideep's aarch64 and x86 primitive-descriptor variants.
>
> The forward primitive descriptor used as a hint comes from the ported `get_primitive_desc`, exactly as ideep's backward does. On x86 that lookup goes through ideep's forward primitive cache, as before.
>
> ### Call sites switched
> - `mkldnn/Conv.cpp`: `mkldnn_convolution_backward_input` (backward data) and `mkldnn_convolution_backward_weights` (with and without bias).
>
> ### Dropped (no ATen callers / unused)
> - The `algorithm` parameter of both functions; it was always `convolution_direct`, which is now fixed locally.
> - The `engine` parameters.
> - Backward weights: `diff_weight_type` and the branch that only ran with a non-default value.
>
> ### Other changes
> - `IDEEP_CHECK` (bf16/f16 on avx2_vnni_2) becomes an unconditional `dnnl::error::wrap_c_api`, as in ideep. ideep's backward functions have no `IDEEP_ENFORCE`, so there is no debug-only check here.
> - Called directly from ideep for now: `ideep::utils::get_compatible_dilates`.
>
> ### Testing
> oneDNN verbose logs (`ONEDNN_VERBOSE=1`, timings stripped, sorted counts) are identical before and after:
> - `test_mkldnn.py` plus `test_freezing.py -k mkldnn`: 6,572 distinct lines, 1,494 of them convolution backward.
> - `quantization/core/test_quantized_op.py -k "qconv and pt2e and not fp8"`: 257 distinct lines.
> - `nn/test_convolution.py -k mkldnn` and the Inductor mkldnn pattern tests: covered by the whole-series A/B comparison against `main` in #204808, with identical per-test outcomes and identical oneDNN primitive logs. (`test_mkldnn_fusion.py` no longer exists upstream.)
>
> (`test/jit/test_freezing.py` was later deleted upstream by #203621. The final A/B comparison of the whole series against `main`, described in #204808, re-checks these paths without it.)
>
> Previously submitted as #201229.

Pull Request resolved: #205717
Approved by: https://github.com/albanD
ghstack dependencies: #205709, #205710, #205711, #205712, #205713, #205714, #205715, #205716
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: cpu CPU specific problem (e.g., perf, algorithm) open source release notes: quantization release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants