Skip to content

[SYSTEMDS-3941] Add new rewrites#2460

Open
smelihportakal wants to merge 1 commit intoapache:mainfrom
smelihportakal:SYSTEMDS-3941
Open

[SYSTEMDS-3941] Add new rewrites#2460
smelihportakal wants to merge 1 commit intoapache:mainfrom
smelihportakal:SYSTEMDS-3941

Conversation

@smelihportakal
Copy link
Copy Markdown

This PR implements the rewrites requested in SYSTEMDS-3941.

Changes:

  • Add a static rewrite for rowSums(a*A) => a*rowSums(A)
  • Add a static rewrite for colSums(a*A) => a*colSums(A)
  • Add a dynamic rewrite for sum(matrix(a, rows=b, cols=c)) => a*b*c
  • Add tests for all new rewrites under src/test/java/org/apache/sysds/test/functions/rewrite
  • Adjust RewriteFusedRandTest to avoid interference from the new rowSums rewrite

Validation:

  • Added rowSums rewrite tests with rewrites enabled and disabled
  • Added colSums rewrite tests with rewrites enabled and disabled
  • Added constant matrix sum rewrite tests with rewrites enabled and disabled
  • Updated RewriteFusedRandTest so it continues to test the intended fused random rewrite behavior

This patch adds two algebraic simplification rewrites. First, it pushes scalar multiplication through rowSums and colSums, rewriting rowSums(a*A) to a*rowSums(A) and colSums(a*A) to a*colSums(A). Second, it simplifies sum(matrix(a, rows=b, cols=c)) to a*b*c when the matrix dimensions are known. The patch also adds rewrite tests for rowSums, colSums, and constant-value matrix sums with rewrites enabled and disabled to validate correctness against the reference outputs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant