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
pycodegen
pystencils
Commits
994f6fcb
Commit
994f6fcb
authored
1 year ago
by
Daniel Bauer
Browse files
Options
Downloads
Patches
Plain Diff
add test
parent
b2f328c0
No related branches found
No related tags found
1 merge request
!343
Do not reorder accesses in `move_constants_before_loop` (quickly)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pystencils_tests/test_move_constant_before_loop.py
+31
-0
31 additions, 0 deletions
pystencils_tests/test_move_constant_before_loop.py
with
31 additions
and
0 deletions
pystencils_tests/test_move_constant_before_loop.py
+
31
−
0
View file @
994f6fcb
...
...
@@ -31,3 +31,34 @@ def test_symbol_renaming():
for
loop
in
loops
:
assert
len
(
loop
.
parent
.
args
)
==
4
# 2 loops + 2 subexpressions
assert
loop
.
parent
.
args
[
0
].
lhs
.
name
!=
loop
.
parent
.
args
[
2
].
lhs
.
name
def
test_keep_order_of_accesses
():
f
=
ps
.
fields
(
"
f: [1D]
"
)
x
=
TypedSymbol
(
"
x
"
,
np
.
float64
)
n
=
5
loop
=
LoopOverCoordinate
(
Block
([
SympyAssignment
(
x
,
f
[
0
]),
SympyAssignment
(
f
[
1
],
2
*
x
)]),
0
,
0
,
n
)
block
=
Block
([
loop
])
ps
.
transformations
.
resolve_field_accesses
(
block
)
new_loops
=
ps
.
transformations
.
cut_loop
(
loop
,
[
n
-
1
])
ps
.
transformations
.
move_constants_before_loop
(
new_loops
.
args
[
1
])
kernel_func
=
ps
.
astnodes
.
KernelFunction
(
block
,
ps
.
Target
.
CPU
,
ps
.
Backend
.
C
,
ps
.
cpu
.
cpujit
.
make_python_function
,
None
)
kernel
=
kernel_func
.
compile
()
print
(
ps
.
show_code
(
kernel_func
))
f_arr
=
np
.
ones
(
n
+
1
)
kernel
(
f
=
f_arr
)
print
(
f_arr
)
assert
np
.
allclose
(
f_arr
,
np
.
array
([
1
,
2
,
4
,
8
,
16
,
32
]))
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