Skip to content

Create and lower broadcasted_reduce to get softmax e2e working - #3269

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_952401826
Open

Create and lower broadcasted_reduce to get softmax e2e working#3269
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_952401826

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Create and lower broadcasted_reduce to get softmax e2e working

This change introduces tensor_ext.broadcasted_reduce, which reduces along an axis of a tensor and then immediately broadcasts back along that axis. I found the default behavior (linalg.reduce + linalg.broadcast) introduced too much complexity and usually triggered an expensive layout conversion. A layout conversion is required, but it is usually simple enough and it seems easier to output the more efficient kernel when we handle the fused case directly.

A future change will support identifying opportunities to fuse linalg.reduce with linalg.broadcast, but for now the softmax-to-cgf-softmax kernel can output it directly.

This change introduces tensor_ext.broadcasted_reduce, which reduces along an axis of a tensor and then immediately broadcasts back along that axis. I found the default behavior (linalg.reduce + linalg.broadcast) introduced too much complexity and usually triggered an expensive layout conversion. A layout conversion is required, but it is usually simple enough and it seems easier to output the more efficient kernel when we handle the fused case directly.

A future change will support identifying opportunities to fuse linalg.reduce with linalg.broadcast, but for now the softmax-to-cgf-softmax kernel can output it directly.

PiperOrigin-RevId: 952401826
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.

1 participant