Skip to content

Comments

Add canonicalization rewrite for useless cumsum/cumprod on length-1 axes#1904

Open
alessandrogentili001 wants to merge 2 commits intopymc-devs:mainfrom
alessandrogentili001:rewrite-useless-cum-ops-1576
Open

Add canonicalization rewrite for useless cumsum/cumprod on length-1 axes#1904
alessandrogentili001 wants to merge 2 commits intopymc-devs:mainfrom
alessandrogentili001:rewrite-useless-cum-ops-1576

Conversation

@alessandrogentili001
Copy link

Description

Related Issue

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

Copy link
Member

@ricardoV94 ricardoV94 left a comment

Choose a reason for hiding this comment

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

Looks, good some minor comments

When ``cumsum`` or ``cumprod`` is applied along an axis of length 1,
the result is identical to the input, so the operation can be removed.
"""
if not isinstance(node.op, CumOp):
Copy link
Member

Choose a reason for hiding this comment

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

not needed, tracks enforce it

((3, 4), 0, "mul", False),
],
)
def test_local_CumOp_length1(shape, axis, mode, should_rewrite):
Copy link
Member

Choose a reason for hiding this comment

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

simplify tests, case is simple enough that we can just rewrite and check the rewrite applies or does not. Also no need for so many combinations.

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.

Rewrite useless cumsum/cumprod on dim_length==1

2 participants