Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Facilitate graph pattern matching#1786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
ricardoV94 wants to merge4 commits intopymc-devs:main
base:main
Choose a base branch
Loading
fromricardoV94:op_shortcut

Conversation

@ricardoV94
Copy link
Member

@ricardoV94ricardoV94 commentedDec 12, 2025
edited
Loading

This PR provides a POC for#1455

  • It adds two variable properties:owner_op andowner_op_and_inputs.
    • This allows us to avoid the verboseif x.owner.op is not None and isinstance(x.owner.op, ...) in favor ofisinstance(x.owner_op, ...)
    • The second one is more niche, but allows to both match an Op and structurally unpack the inputs in case of a match in a singlecase statement. This makes nested patterns easier to write. Eg.case (Blocwise(Dot()), a, b) for a singlematch x.owner_op_and_inputs.
  • It addsmatch_args so common parametrized Ops (Elemwise, Blockwise) and Constants are easier to pattern match without kwargs
  • It adds a much neededis_matrix_transpose andis_left_expanded_matrix_transpose property to DimShuffle, for easier pattern matching

I then refactored the existing linalg rewrites as a POC. I went a bit overboard and tried to standardize names, and fuse rewrites that were pretty simple to combine.

CC@tanish1729 who did many of these rewrites, see if it feels nicer?

williambdean reacted with rocket emoji
# Check for use of pt.diag first
case (AllocDiag(offset=0,axis1=axis1,axis2=axis2),diag_input):
ndim=diag_input.ndim
ifaxis1==ndim-1andaxis2==ndim:
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

This is new, we were not checking for non standard allocdiagonal, not along the last dims!

@ricardoV94ricardoV94force-pushed theop_shortcut branch 2 times, most recently from0a5ec73 tocf91364CompareDecember 12, 2025 14:16
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@ricardoV94

[8]ページ先頭

©2009-2025 Movatter.jp