Skip to content

[mkldnn][6/N] Port pooling from ideep to ATen - #201080

Closed
frost-intel wants to merge 3 commits into
pytorch:mainfrom
frost-intel:ideep-removal/06-port-pooling
Closed

frost-intel wants to merge 3 commits into
pytorch:mainfrom
frost-intel:ideep-removal/06-port-pooling

Conversation

@frost-intel

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

Copy link
Copy Markdown
Collaborator

Linked issue or supporting maintainer

Part of #154444

BC-breaking?

No

Summary (human written only)

Port of pooling_forward/backward from ideep. Ported line-for-line. A few details that might be seen in review:

  • The dilation variants (pooling_v2) in ideep are never called in ATen, so they are left out of the port here.
  • A workaround for an existing layout issue (src._get_unblocked_desc_if_4c_blocked) is left as-is. Fixing/verification is outside the scope of this porting PR.

Pooling calls are now to aten operators, not ideep.

Fake stack

Agent details (if applicable)

Developed with assistance from Claude Opus 5.5.

What changed (4 files, +184/−2):

  • detail/Pooling.{h,cpp}: pooling_forward and pooling_backward, ported line for line from ideep's pool.hpp.
    • Kept: the workaround that reads src's layout through _get_unblocked_desc_if_4c_blocked() (for oneDNN issue Pooling and BN fallback to ref implementation uxlfoundation/oneDNN#588), output layout any, the input reorder, buffer replacement on the outputs, scale propagation, and the avx2_vnni_2 bf16/f16 check on backward.
    • Max-pool indices: in training mode, forward stores the indices on dst (init_workspace), and backward reads them back from dst and reorders them if needed. This is unchanged from ideep, so tensors created before and after this change behave the same.
    • Only the variants ATen calls are ported. ideep's pooling_v2_forward/backward (the dilation variants) have no ATen callers.
  • Call sites: Pooling.cpp (2). It no longer calls ideep operators.
  • build_variables.bzl: 1 entry.

Checks:

  • Same oneDNN calls before and after. Same comparison as above. All 6,572 distinct primitive log lines are identical.
    • Pooling runs 227 times, with 216 distinct lines. Of those, 48 are max-pool forward in training mode and 48 are max-pool backward.
    • The max-pool backward lines include the workspace argument (ws:s32::blocked:...), so the stored indices reach the backward pass.
  • Tests:
    • test_mkldnn.py: 92 passed, 1 skipped.
    • Freezing tests: 4 passed, 5 skipped.
    • test_nn.py -k "pool and cpu": 1 passed, 6 skipped.
  • Lint: clean.

(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 commented Oct 15, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 2674ee1 with merge base 780bf8e (image):
💚 Looks good so far! There are no failures yet. 💚

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

@pytorch-bot pytorch-bot Bot added module: cpu CPU specific problem (e.g., perf, algorithm) release notes: quantization release notes category labels Oct 15, 2026
@frost-intel
frost-intel force-pushed the ideep-removal/06-port-pooling branch from 4d2ec71 to de85193 Compare October 29, 2026 16:04
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.

Move ideep::pooling_forward and ideep::pooling_backward into
aten/src/ATen/native/mkldnn/detail/Pooling.{h,cpp} and switch the callers
in Pooling.cpp. The port is line-for-line, including storing max-pool
indices as a workspace on the output tensor for use by the backward pass.
ideep::pooling_v2_* (dilated pooling) has no ATen callers and is not
ported.

Verified with ONEDNN_VERBOSE=1 over test_mkldnn.py and the mkldnn freezing
tests: all 6572 distinct primitive create/exec lines are identical before
and after.
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

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 `pooling_forward/backward` from ideep. Ported line-for-line. A few details that might be seen in review:
* The dilation variants (pooling_v2) in ideep are never called in ATen, so they are left out of the port here.
* A workaround for an existing layout issue (`src._get_unblocked_desc_if_4c_blocked`) is left as-is. Fixing/verification is outside the scope of this porting PR.

Pooling calls are now to aten operators, not ideep.

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

> **What changed** (4 files, +189/−2):
>
> - **`detail/Pooling.{h,cpp}`:** `pooling_forward` and `pooling_backward`, ported line for line from ideep's `pool.hpp`.
>   - Kept: the workaround that reads `src`'s layout through `_get_unblocked_desc_if_4c_blocked()` (for oneDNN issue uxlfoundation/oneDNN#588), output layout `any`, the input reorder, buffer replacement on the outputs, scale propagation, and the avx2_vnni_2 bf16/f16 check on backward.
>   - **Max-pool indices:** in training mode, forward stores the indices on `dst` (`init_workspace`), and backward reads them back from `dst` and reorders them if needed. This is unchanged from ideep, so tensors created before and after this change behave the same.
>   - Only the variants ATen calls are ported. ideep's `pooling_v2_forward/backward` (the dilation variants) have no ATen callers.
> - **Call sites:** `Pooling.cpp` (2). It no longer calls ideep operators.
> - **`build_variables.bzl`:** 1 entry.
>
> **Checks:**
>
> - **Same oneDNN calls before and after.** Same comparison as above. All 6,572 distinct primitive log lines are identical.
>   - Pooling runs 227 times, with 216 distinct lines. Of those, 48 are max-pool forward in training mode and 48 are max-pool backward.
>   - The max-pool backward lines include the workspace argument (`ws:s32::blocked:...`), so the stored indices reach the backward pass.
> - **Tests:**
>   - `test_mkldnn.py`: 92 passed, 1 skipped.
>   - Freezing tests: 4 passed, 5 skipped.
>   - `test_nn.py -k "pool and cpu"`: 1 passed, 6 skipped.
> - **Lint:** clean.
>
> (`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 #201080.

Pull Request resolved: #205712
Approved by: https://github.com/albanD
ghstack dependencies: #205709, #205710, #205711
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