Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pymbolic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lawrence Mitchell
pymbolic
Commits
d64448db
Commit
d64448db
authored
12 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Don't remove CSEs when forming CSE keys.
parent
ab0db002
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pymbolic/cse.py
+1
-17
1 addition, 17 deletions
pymbolic/cse.py
with
1 addition
and
17 deletions
pymbolic/cse.py
+
1
−
17
View file @
d64448db
from
__future__
import
division
import
pymbolic.primitives
as
prim
from
pymbolic.mapper
import
IdentityMapper
,
WalkMapper
,
CSECachingMapperMixin
from
pytools
import
memoize_method
from
pymbolic.mapper
import
IdentityMapper
,
WalkMapper
COMMUTATIVE_CLASSES
=
(
prim
.
Sum
,
prim
.
Product
)
class
CSERemover
(
IdentityMapper
):
def
map_common_subexpression
(
self
,
expr
):
return
self
.
rec
(
expr
.
child
)
class
NormalizedKeyGetter
(
object
):
def
__init__
(
self
):
self
.
cse_remover
=
CSERemover
()
@memoize_method
def
remove_cses
(
self
,
expr
):
return
self
.
cse_remover
(
expr
)
def
__call__
(
self
,
expr
):
expr
=
self
.
remove_cses
(
expr
)
if
isinstance
(
expr
,
COMMUTATIVE_CLASSES
):
kid_count
=
{}
for
child
in
expr
.
children
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment