Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Markus Holzer
pystencils
Commits
1c5814c2
Commit
1c5814c2
authored
2 years ago
by
Markus Holzer
Browse files
Options
Downloads
Patches
Plain Diff
node collection replacements more specific
parent
404f5138
No related branches found
No related tags found
No related merge requests found
Pipeline
#47235
failed
2 years ago
Stage: pretest
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pystencils/node_collection.py
+7
-5
7 additions, 5 deletions
pystencils/node_collection.py
pystencils_tests/test_vectorization.py
+1
-0
1 addition, 0 deletions
pystencils_tests/test_vectorization.py
with
8 additions
and
5 deletions
pystencils/node_collection.py
+
7
−
5
View file @
1c5814c2
...
...
@@ -43,14 +43,15 @@ class NodeCollection:
def
evaluate_terms
(
self
):
evaluate_constant_terms
=
ReplaceOptim
(
lambda
e
:
hasattr
(
e
,
'
is_constant
'
)
and
e
.
is_constant
and
not
e
.
is_integer
,
lambda
p
:
p
.
evalf
())
lambda
p
:
p
.
evalf
()
)
evaluate_pow
=
ReplaceOptim
(
lambda
e
:
e
.
is_Pow
and
e
.
exp
.
is_Integer
and
abs
(
e
.
exp
)
<=
8
,
lambda
p
:
(
sp
.
UnevaluatedExpr
(
sp
.
Mul
(
*
([
p
.
base
]
*
+
p
.
exp
),
evaluate
=
False
)
)
if
p
.
exp
>
0
else
DivFunc
(
sp
.
Integer
(
1
),
sp
.
UnevaluatedExpr
(
sp
.
Mul
(
*
([
p
.
base
]
*
-
p
.
exp
),
evaluate
=
False
)))
)
)
lambda
p
:
sp
.
UnevaluatedExpr
(
sp
.
Mul
(
*
([
p
.
base
]
*
+
p
.
exp
),
evaluate
=
False
))
if
p
.
exp
>
0
else
(
DivFunc
(
sp
.
Integer
(
1
),
p
.
base
)
if
p
.
exp
==
-
1
else
DivFunc
(
sp
.
Integer
(
1
),
sp
.
UnevaluatedExpr
(
sp
.
Mul
(
*
([
p
.
base
]
*
-
p
.
exp
),
evaluate
=
False
)))
)
)
sympy_optimisations
=
[
evaluate_constant_terms
,
evaluate_pow
]
if
self
.
is_Nodes
:
...
...
@@ -65,6 +66,7 @@ class NodeCollection:
return
optimize
(
node
,
sympy_optimisations
)
else
:
raise
NotImplementedError
(
f
'
{
node
}
{
type
(
node
)
}
has no valid visitor
'
)
self
.
all_assignments
=
[
visitor
(
assignment
)
for
assignment
in
self
.
all_assignments
]
else
:
self
.
all_assignments
=
[
Assignment
(
a
.
lhs
,
optimize
(
a
.
rhs
,
sympy_optimisations
))
...
...
This diff is collapsed.
Click to expand it.
pystencils_tests/test_vectorization.py
+
1
−
0
View file @
1c5814c2
...
...
@@ -282,6 +282,7 @@ def test_vectorised_pow(instruction_set=instruction_set):
ast
=
ps
.
create_kernel
(
as6
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
ps
.
show_code
(
ast
)
ast
.
compile
()
...
...
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