Skip to content

[mkldnn][24/N] Let inner_product_forward_expected_weights_desc take an Attr - #206279

Open
frost-intel wants to merge 5 commits into
gh/frost-intel/22/basefrom
gh/frost-intel/22/head
Open

frost-intel wants to merge 5 commits into
gh/frost-intel/22/basefrom
gh/frost-intel/22/head

Conversation

@frost-intel

@frost-intel frost-intel commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Stack from ghstack (oldest at bottom):

Linked issue or supporting maintainer

Part of #154444

BC-breaking?

No

Summary (human written only)

Changing inner_product_forward_expected_weights_desc to take an Attr parameter as its last argument, allowing the packed weight layout to depend on primitive attributes. This was requested by @mriganks-amd for upcoming ZenDNN fp16 accumulation support.

Agent details (if applicable)

Developed with assistance from Claude Opus 5.5.

Part of #154444. Requested by AMD for ZenDNN fp16 accumulation (#204794).

inner_product_forward_expected_weights_desc now takes const Attr& attr = Attr() as its last parameter and passes it to the dnnl::inner_product_forward::primitive_desc, as matmul_forward_expected_weights_desc already does. The packed weight layout can depend on primitive attributes. For example, with ZenDNN's fp16 "any" accumulation mode, a weight packed with default attributes runs on brgemm even with the mode set. Callers can now pack with the attributes they compute with.

No behavior change: the only caller, mkldnn_reorder_linear_weight in MKLDNNConversions.cpp, does not pass attr, and a default Attr is an empty dnnl::primitive_attr, which is what oneDNN uses when no attributes are given. This is an API addition on top of the port; ideep's version takes no attributes.

Testing: compiles with -Wall -Wextra -Wsign-compare -Werror in release and debug builds; test_mkldnn, the mkldnn conv tests and the quantized conv/linear tests pass at the tip.

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

Differential Revision: D135688234

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

Please fix all CI failures and trigger merge by commenting "@pytorchbot merge".

✅ AUTOMATED REVIEW - OUTDATED (earlier commit) - Ready for human review:

The PR adds a trailing `const Attr& attr = Attr()` parameter to
`inner_product_forward_expected_weights_desc` and passes it to
`dnnl::inner_product_forward::primitive_desc`, so the packed weight layout can
depend on primitive attributes. Recommendation: Approve. The review found
nothing blocking: behavior is unchanged for existing callers, the API stays
source-compatible, and it follows the existing matmul pattern.

Reviewed commit: 978dc67 (NOT the current head 9513082)

Review run

🐛 Report a bad review

🔗 Helpful Links

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

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

✅ No Failures

As of commit 9513082 with merge base d54e485 (image):
💚 Looks good so far! There are no failures yet. 💚

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

[ghstack-poisoned]
frost-intel added a commit that referenced this pull request Nov 25, 2026
…n Attr

## Linked issue or supporting maintainer
Part of #154444

## BC-breaking?
No

## Summary (human written only)
Changing `inner_product_forward_expected_weights_desc` to take an `Attr` parameter as its last argument, allowing the packed weight layout to depend on primitive attributes. This was requested by mriganks-amd for upcoming ZenDNN fp16 accumulation support.

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

> Part of #154444. Requested by AMD for ZenDNN fp16 accumulation (#204794).
>
> `inner_product_forward_expected_weights_desc` now takes `const Attr& attr = Attr()` as its last parameter and passes it to the `dnnl::inner_product_forward::primitive_desc`, as `matmul_forward_expected_weights_desc` already does. The packed weight layout can depend on primitive attributes. For example, with ZenDNN's fp16 "any" accumulation mode, a weight packed with default attributes runs on brgemm even with the mode set. Callers can now pack with the attributes they compute with.
>
> No behavior change: the only caller, `mkldnn_reorder_linear_weight` in `MKLDNNConversions.cpp`, does not pass `attr`, and a default `Attr` is an empty `dnnl::primitive_attr`, which is what oneDNN uses when no attributes are given. This is an API addition on top of the port; ideep's version takes no attributes.
>
> Testing: compiles with `-Wall -Wextra -Wsign-compare -Werror` in release and debug builds; `test_mkldnn`, the mkldnn conv tests and the quantized conv/linear tests pass at the tip.


ghstack-source-id: be5695a
Pull-Request: #206279
[ghstack-poisoned]
[ghstack-poisoned]
@frost-intel frost-intel added topic: not user facing topic category in progress PR is being worked on by the author, until the automated review accepts it labels Nov 25, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review of 978dc67: nothing blocking; ready for human review.

The PR adds a trailing const Attr& attr = Attr() parameter to inner_product_forward_expected_weights_desc and passes it to dnnl::inner_product_forward::primitive_desc, so the packed weight layout can depend on primitive attributes. Recommendation: Approve. The review found nothing blocking: behavior is unchanged for existing callers, the API stays source-compatible, and it follows the existing matmul pattern.

This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review

@pytorch-bot pytorch-bot Bot added ready for review Automated review passed, ready for a final review by a maintainer. and removed in progress PR is being worked on by the author, until the automated review accepts it labels Nov 25, 2026

@albanD albanD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #206630

pytorchmergebot pushed a commit that referenced this pull request Nov 25, 2026
## Linked issue or supporting maintainer
Part of #154444

## BC-breaking?
No

## Summary (human written only)
Rename all itensor functions to `memory_*` to eliminate all itensor references in ideep port.

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

> Part of #154444 (remove the ideep submodule).
>
> Follows the `ITensor` -> `MkldnnMemory` rename. The helpers that convert between `at::Tensor` and `MkldnnMemory` drop their `itensor` prefix. This is a mechanical rename with no behavior change:
> - `itensor_from_mkldnn` -> `memory_from_mkldnn`
> - `itensor_from_tensor` -> `memory_from_tensor`
> - `itensor_from_const_tensor` -> `memory_from_const_tensor`
> - `itensor_view_from_dense` -> `memory_view_from_dense`
> - `itensor_view_from_const_dense` -> `memory_view_from_const_dense`
> - `itensor_view_from_dense_impl` -> `memory_view_from_dense_impl` (file-local)
> - `new_with_itensor_mkldnn` -> `new_with_mkldnn_memory`
> - `typed_itensor_view_from_dense` -> `typed_mkldnn_memory_view_from_dense` (file-local)
>
> These are internal ATen helpers declared in `MKLDNNCommon.h`, so their exported symbol names change, as with the helpers in 21/N.
Pull Request resolved: #206630
Approved by: https://github.com/albanD
ghstack dependencies: #205978, #205979, #205980, #206276, #206277, #206278, #206279
pytorchmergebot added a commit that referenced this pull request Nov 27, 2026
…c take an Attr (#206279)"

This reverts commit c067e37.

Reverted #206279 on behalf of https://github.com/izaitsevfb due to Breaks Meta-internal tests that OSS CI does not run ([comment](#206276 (comment)))
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@frost-intel your PR has been reverted as part of the stack under #206276.

[ghstack-poisoned]
@soulitzer

Copy link
Copy Markdown
Contributor

@soulitzer has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Dec 2, 2026

This branch was previously deployed

1 inactive (outdated) deployment
bedrock — 978dc676 Deployed Nov 27, 2026 by pytorchmergebot via analyze #43228
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-triage-error ci-no-td Do not run TD on this PR ciflow/trunk Trigger trunk jobs on your pull request Merged module: cpu CPU specific problem (e.g., perf, algorithm) open source ready for review Automated review passed, ready for a final review by a maintainer. Reverted topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants