Skip to content

Support broadcast strides in TensorAttr and ASM emitter#288

Merged
IanWood1 merged 2 commits intoiree-org:mainfrom
IanWood1:support_broadcast
Apr 6, 2026
Merged

Support broadcast strides in TensorAttr and ASM emitter#288
IanWood1 merged 2 commits intoiree-org:mainfrom
IanWood1:support_broadcast

Conversation

@IanWood1
Copy link
Copy Markdown
Member

@IanWood1 IanWood1 commented Apr 1, 2026

Support broadcast strides (stride=0) in TensorAttr and ASM emitter.

TensorAttr changes:

  • Add hasBroadcastDims() and getUnexpandedDim() methods
  • Update hasValidPhysicalRepresentation() to accept stride=0
  • Update getPhysicalDim() to return size 1 for broadcast dims
  • Update getLogicalToPhysicalPermuteOrder()

ASM emitter changes:

  • Add buildTensorTypeStr() helper for explicit dims
  • Rename getPermuteOpsAsm → getLayoutConversionOpsAsm which handles permute + broadcast expand internally for physical⇾logical conversion

Fixes #276

@IanWood1 IanWood1 changed the title Support broadcast strides (stride=0) in TensorAttr and ASM emitter Support broadcast strides in TensorAttr and ASM emitter Apr 1, 2026
@IanWood1 IanWood1 force-pushed the support_broadcast branch 4 times, most recently from e22a875 to eaf3b2e Compare April 3, 2026 21:05
@IanWood1 IanWood1 marked this pull request as ready for review April 3, 2026 21:06
@IanWood1 IanWood1 requested a review from sjain-stanford April 3, 2026 21:06
Copy link
Copy Markdown
Contributor

@keshavvinayak01 keshavvinayak01 left a comment

Choose a reason for hiding this comment

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

Looks good

@IanWood1 IanWood1 force-pushed the support_broadcast branch from eaf3b2e to 1892118 Compare April 6, 2026 20:40
Broadcast strides (stride=0 on dims with size > 1) are used by
frameworks like cuDNN and PyTorch to share data across dimensions
via memory aliasing. This enables fusilli to accept tensors where
certain dimensions read from the same physical memory location.

TensorAttr changes:
- Add hasBroadcastDims() and getUnexpandedDim() methods
- Update hasValidPhysicalRepresentation() to accept stride=0
- Update getPhysicalDim() to return size 1 for broadcast dims
- Update getLogicalToPhysicalPermuteOrder() to pin broadcast dims

ASM emitter changes:
- Add buildTensorTypeStr() helper for explicit dims
- Rename getPermuteOpsAsm → getLayoutConversionOpsAsm which handles
  permute + broadcast expand internally for physical→logical conversion
- Callers no longer need broadcast-specific branching

Broadcast strides on output tensors are not yet supported and are
rejected during graph validation with a clear error message.

Fixes iree-org#276

Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
@IanWood1 IanWood1 force-pushed the support_broadcast branch from 1892118 to c199bb5 Compare April 6, 2026 20:43
@IanWood1 IanWood1 enabled auto-merge (squash) April 6, 2026 20:45
@IanWood1 IanWood1 merged commit 55e7e1b into iree-org:main Apr 6, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SDPA][hipDNN] Broadcast strides (stride=0) not supported

2 participants