Skip to content

More rewrites for ExtractDiag#2045

Open
jessegrabowski wants to merge 1 commit intopymc-devs:v3from
jessegrabowski:extract-diag-rewrites
Open

More rewrites for ExtractDiag#2045
jessegrabowski wants to merge 1 commit intopymc-devs:v3from
jessegrabowski:extract-diag-rewrites

Conversation

@jessegrabowski
Copy link
Copy Markdown
Member

@jessegrabowski jessegrabowski commented Apr 12, 2026

These came up when I was working on #2032. They're not related to that perse so I split them off. We're missing a lot of simple rewrites for ExtractDiag. I added:

  • ExtractDiag(Eye) -> Ones or Zeros, depending on k
  • ExtractDiag(Eye * x) -> Alloc(x) (new shape)
  • ExtractDiag(Zeros / Ones) -> Zeros / Ones of new shape
  • ExtractDiag(Alloc) -> Alloc (with new shape)
  • ExtractDiag(Elemwise(a, b)) -> Elemwise(ExtractDiag(a), ExtractDiag(b)) (plus some broadcasting logic)
  • ExtractDiag(Transpose(x), offset=k) -> ExtractDiag(X, offset=-k) (I understand transpose is just a free view but it removes a blocker to further rewrites that no longer need to see through the transpose)

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

Labels

enhancement New feature or request graph rewriting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant