Skip to content

Support 1D linear in the CPU Reference provider - #24254

Open
JakeStevens wants to merge 1 commit into
pytorch:mainfrom
JakeStevens:export-D128153701
Open

JakeStevens wants to merge 1 commit into
pytorch:mainfrom
JakeStevens:export-D128153701

Conversation

@JakeStevens

Copy link
Copy Markdown
Contributor

Summary:
aten::linear with a 1D input or a 1D weight failed at execution with 0x12 (InvalidArgument). The Reference provider routes every linear to opt_linear_out, which requires an input of rank >= 2 and a 2D weight. Portable has no linear kernel, and XNNPACK declines non-constant or non-2D weights.

The Reference provider now binds 1D operands as single-row views: a [K] input or weight becomes [1, K], and the output gains the matching unit dimension. Scalar bias is also viewed as [1] to satisfy the optimized kernel's bias contract. Views share the value's buffer, so nothing is copied. The partitioner keeps preserving these linear nodes instead of decomposing them, so a provider can later claim the 1D shapes with a dedicated kernel.

Authored with assistance from Claude Code and Codex.

Differential Revision: D128153701

Summary:
`aten::linear` with a 1D input or a 1D weight failed at execution with `0x12` (InvalidArgument). The Reference provider routes every `linear` to `opt_linear_out`, which requires an input of rank >= 2 and a 2D weight. Portable has no `linear` kernel, and XNNPACK declines non-constant or non-2D weights.

The Reference provider now binds 1D operands as single-row views: a `[K]` input or weight becomes `[1, K]`, and the output gains the matching unit dimension. Scalar bias is also viewed as `[1]` to satisfy the optimized kernel's bias contract. Views share the value's buffer, so nothing is copied. The partitioner keeps preserving these `linear` nodes instead of decomposing them, so a provider can later claim the 1D shapes with a dedicated kernel.

Authored with assistance from Claude Code and Codex.

Differential Revision: D128153701
@pytorch-bot

pytorch-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

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

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

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 28, 2026
@meta-codesync

meta-codesync Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

@JakeStevens has exported this pull request. If you are a Meta employee, you can view the originating Diff in D128153701.

@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant