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
Package registry
Model registry
Operate
Environments
Terraform modules
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
hyteg
pystencils
Commits
0845d667
Commit
0845d667
authored
1 year ago
by
Frederik Hennig
Browse files
Options
Downloads
Patches
Plain Diff
Fix symbol canonicalization to not duplicate when marking as updated
parent
3ee5d9b6
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/pystencils/backend/transformations/canonicalize_symbols.py
+1
-1
1 addition, 1 deletion
...ystencils/backend/transformations/canonicalize_symbols.py
tests/nbackend/transformations/test_canonicalize_symbols.py
+28
-0
28 additions, 0 deletions
tests/nbackend/transformations/test_canonicalize_symbols.py
with
29 additions
and
1 deletion
src/pystencils/backend/transformations/canonicalize_symbols.py
+
1
−
1
View file @
0845d667
...
...
@@ -33,7 +33,7 @@ class CanonContext:
return
replacement
def
mark_as_updated
(
self
,
symb
:
PsSymbol
):
self
.
updated_symbols
.
add
(
self
.
deduplicate
(
symb
)
)
self
.
updated_symbols
.
add
(
symb
)
def
is_live
(
self
,
symb
:
PsSymbol
)
->
bool
:
return
symb
in
self
.
live_symbols_map
...
...
This diff is collapsed.
Click to expand it.
tests/nbackend/transformations/test_canonicalize_symbols.py
+
28
−
0
View file @
0845d667
...
...
@@ -86,3 +86,31 @@ def test_do_not_constify():
assert
ctx
.
find_symbol
(
"
x
"
).
dtype
.
const
assert
not
ctx
.
find_symbol
(
"
z
"
).
dtype
.
const
def
test_loop_counters
():
ctx
=
KernelCreationContext
()
factory
=
AstFactory
(
ctx
)
canonicalize
=
CanonicalizeSymbols
(
ctx
)
f
=
Field
.
create_generic
(
"
f
"
,
2
,
index_shape
=
(
1
,))
g
=
Field
.
create_generic
(
"
g
"
,
2
,
index_shape
=
(
1
,))
ispace
=
FullIterationSpace
.
create_from_slice
(
ctx
,
make_slice
[:,
:],
archetype_field
=
f
)
ctx
.
set_iteration_space
(
ispace
)
asm
=
Assignment
(
f
.
center
(
0
),
2
*
g
.
center
(
0
))
body
=
PsBlock
([
factory
.
parse_sympy
(
asm
)])
loops
=
factory
.
loops_from_ispace
(
ispace
,
body
)
loops_copy
=
loops
.
clone
()
ast
=
PsBlock
([
loops
,
loops_copy
])
ast
=
canonicalize
(
ast
)
assert
loops_copy
.
counter
.
symbol
.
name
==
"
ctr_0
"
assert
not
loops_copy
.
counter
.
symbol
.
get_dtype
().
const
assert
loops
.
counter
.
symbol
.
name
==
"
ctr_0__0
"
assert
not
loops
.
counter
.
symbol
.
get_dtype
().
const
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