Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Markus Holzer
pystencils
Commits
5594cd3b
Commit
5594cd3b
authored
May 18, 2022
by
Markus Holzer
Browse files
Remove symbol replacement
parent
e2d3dd60
Pipeline
#40018
passed with stages
in 13 minutes and 29 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
pystencils/transformations.py
View file @
5594cd3b
...
...
@@ -607,13 +607,7 @@ def move_constants_before_loop(ast_node):
get_blocks
(
ast_node
,
all_blocks
)
for
block
in
all_blocks
:
children
=
block
.
take_child_nodes
()
# Every time a symbol can be replaced in the current block because the assignment
# was found in a parent block, but with a different lhs symbol (same rhs)
# the outer symbol is inserted here as key.
substitute_variables
=
{}
for
child
in
children
:
# Before traversing the next child, all symbols are substituted first.
child
.
subs
(
substitute_variables
)
if
not
isinstance
(
child
,
ast
.
SympyAssignment
):
# only move SympyAssignments
block
.
append
(
child
)
...
...
@@ -629,14 +623,7 @@ def move_constants_before_loop(ast_node):
exists_already
=
False
if
not
exists_already
:
rhs_identical
=
check_if_assignment_already_in_block
(
child
,
target
,
True
)
if
rhs_identical
:
# there is already an assignment out there with the same rhs
# -> replace all lhs symbols in this block with the lhs of the outer assignment
# -> remove the local assignment (do not re-append child to the former block)
substitute_variables
[
child
.
lhs
]
=
rhs_identical
.
lhs
else
:
target
.
insert_before
(
child
,
child_to_insert_before
)
target
.
insert_before
(
child
,
child_to_insert_before
)
elif
exists_already
and
exists_already
.
rhs
==
child
.
rhs
:
if
target
.
args
.
index
(
exists_already
)
>
target
.
args
.
index
(
child_to_insert_before
):
assert
target
.
args
.
count
(
exists_already
)
==
1
...
...
@@ -650,7 +637,6 @@ def move_constants_before_loop(ast_node):
new_symbol
=
TypedSymbol
(
sp
.
Dummy
().
name
,
child
.
lhs
.
dtype
)
target
.
insert_before
(
ast
.
SympyAssignment
(
new_symbol
,
child
.
rhs
,
is_const
=
child
.
is_const
),
child_to_insert_before
)
substitute_variables
[
child
.
lhs
]
=
new_symbol
def
split_inner_loop
(
ast_node
:
ast
.
Node
,
symbol_groups
):
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment