Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 11, 2025

Plan: Expand DotGeneral CSE Pass to handle more equivalence

  • Understand the current CSE implementation for DotGeneralOp
  • Analyze when dot_general(A, B) is equivalent to dot_general(B, A)
  • Create a specialized CSE pattern for DotGeneralOp that checks operand swapping
  • Add test cases for the new CSE functionality
  • Address all code review feedback and eliminate all duplication
  • Refactor to reuse more of the generic CSE pattern structure
  • Run security checks
  • Complete implementation
Original prompt

This section details on the original issue you should resolve

<issue_title>Expand DotGeneral CSE Pass to handle more equivalence</issue_title>
<issue_description>```
%6 = stablehlo.dot_general %4, %5, batching_dims = [0] x [0], contracting_dims = [1] x [1] : (tensor<4x4xf32>, tensor<4x4xf32>) -> tensor<4xf32>
%7 = stablehlo.dot_general %5, %4, batching_dims = [0] x [0], contracting_dims = [1] x [1] : (tensor<4x4xf32>, tensor<4x4xf32>) -> tensor<4xf32>


This would be an example. `dot_general(A, B)` can be written as `dot_general(B, A)` if certain patterns on the dot_dimensions hold up. we should expand the current dot general cse pass to account for these</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 6 commits December 11, 2025 17:31
Co-authored-by: avik-pal <30564094+avik-pal@users.noreply.github.com>
Co-authored-by: avik-pal <30564094+avik-pal@users.noreply.github.com>
Co-authored-by: avik-pal <30564094+avik-pal@users.noreply.github.com>
…emove unnecessary checks

Co-authored-by: avik-pal <30564094+avik-pal@users.noreply.github.com>
Co-authored-by: avik-pal <30564094+avik-pal@users.noreply.github.com>
Copilot AI changed the title [WIP] Expand DotGeneral CSE pass to handle more equivalence Extend DotGeneral CSE to recognize operand-swapped equivalence Dec 11, 2025
Copilot AI requested a review from avik-pal December 11, 2025 17:50
patterns.add<CSE<stablehlo::BroadcastInDimOp>, CSE<stablehlo::SliceOp>,
CSE<stablehlo::TransposeOp>, CSE<stablehlo::ConvertOp>,
CSE<stablehlo::PadOp>, CSE<stablehlo::DotGeneralOp>,
CSE<stablehlo::PadOp>, CSEDotGeneral,
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot can we reuse more of the CSE struct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored to follow the structure of the generic CSE pattern more closely. The implementation now directly mirrors the CSE template's iteration and checking logic, only adding the DotGeneral-specific swapped equivalence check. Commit: 9dea61e

…ture

Co-authored-by: avik-pal <30564094+avik-pal@users.noreply.github.com>
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.

Expand DotGeneral CSE Pass to handle more equivalence

2 participants