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
Julian Hammer
pystencils
Commits
391da2e7
Commit
391da2e7
authored
4 years ago
by
Markus Holzer
Committed by
Stephan Seitz
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
FIX Quicktests
parent
1ed90ce1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pystencils_tests/test_vectorization.py
+24
-19
24 additions, 19 deletions
pystencils_tests/test_vectorization.py
with
24 additions
and
19 deletions
pystencils_tests/test_vectorization.py
+
24
−
19
View file @
391da2e7
...
@@ -7,6 +7,11 @@ from pystencils.cpu.vectorization import vectorize
...
@@ -7,6 +7,11 @@ from pystencils.cpu.vectorization import vectorize
from
pystencils.fast_approximation
import
insert_fast_sqrts
,
insert_fast_divisions
from
pystencils.fast_approximation
import
insert_fast_sqrts
,
insert_fast_divisions
from
pystencils.transformations
import
replace_inner_stride_with_one
from
pystencils.transformations
import
replace_inner_stride_with_one
supported_instruction_sets
=
get_supported_instruction_sets
()
if
supported_instruction_sets
:
instruction_set
=
supported_instruction_sets
[
-
1
]
else
:
instruction_set
=
None
def
test_vector_type_propagation
():
def
test_vector_type_propagation
():
a
,
b
,
c
,
d
,
e
=
sp
.
symbols
(
"
a b c d e
"
)
a
,
b
,
c
,
d
,
e
=
sp
.
symbols
(
"
a b c d e
"
)
...
@@ -19,7 +24,7 @@ def test_vector_type_propagation():
...
@@ -19,7 +24,7 @@ def test_vector_type_propagation():
ps
.
Assignment
(
g
[
0
,
0
],
b
+
3
+
f
[
0
,
1
])]
ps
.
Assignment
(
g
[
0
,
0
],
b
+
3
+
f
[
0
,
1
])]
ast
=
ps
.
create_kernel
(
update_rule
)
ast
=
ps
.
create_kernel
(
update_rule
)
vectorize
(
ast
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
func
=
ast
.
compile
()
func
=
ast
.
compile
()
dst
=
np
.
zeros_like
(
arr
)
dst
=
np
.
zeros_like
(
arr
)
...
@@ -42,7 +47,7 @@ def test_inplace_update():
...
@@ -42,7 +47,7 @@ def test_inplace_update():
f1
@=
2
*
s
.
tmp0
f1
@=
2
*
s
.
tmp0
f2
@=
2
*
s
.
tmp0
f2
@=
2
*
s
.
tmp0
ast
=
ps
.
create_kernel
(
update_rule
,
cpu_vectorize_info
=
True
)
ast
=
ps
.
create_kernel
(
update_rule
,
cpu_vectorize_info
=
{
'
instruction_set
'
:
instruction_set
}
)
kernel
=
ast
.
compile
()
kernel
=
ast
.
compile
()
kernel
(
f
=
arr
)
kernel
(
f
=
arr
)
np
.
testing
.
assert_equal
(
arr
,
2
)
np
.
testing
.
assert_equal
(
arr
,
2
)
...
@@ -67,7 +72,7 @@ def test_vectorization_fixed_size():
...
@@ -67,7 +72,7 @@ def test_vectorization_fixed_size():
update_rule
=
[
ps
.
Assignment
(
g
[
0
,
0
],
f
[
0
,
0
]
+
f
[
-
1
,
0
]
+
f
[
1
,
0
]
+
f
[
0
,
1
]
+
f
[
0
,
-
1
]
+
42.0
)]
update_rule
=
[
ps
.
Assignment
(
g
[
0
,
0
],
f
[
0
,
0
]
+
f
[
-
1
,
0
]
+
f
[
1
,
0
]
+
f
[
0
,
1
]
+
f
[
0
,
-
1
]
+
42.0
)]
ast
=
ps
.
create_kernel
(
update_rule
)
ast
=
ps
.
create_kernel
(
update_rule
)
vectorize
(
ast
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
func
=
ast
.
compile
()
func
=
ast
.
compile
()
dst
=
np
.
zeros_like
(
arr
)
dst
=
np
.
zeros_like
(
arr
)
...
@@ -81,7 +86,7 @@ def test_vectorization_variable_size():
...
@@ -81,7 +86,7 @@ def test_vectorization_variable_size():
ast
=
ps
.
create_kernel
(
update_rule
)
ast
=
ps
.
create_kernel
(
update_rule
)
replace_inner_stride_with_one
(
ast
)
replace_inner_stride_with_one
(
ast
)
vectorize
(
ast
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
func
=
ast
.
compile
()
func
=
ast
.
compile
()
arr
=
np
.
ones
((
23
+
2
,
17
+
2
))
*
5.0
arr
=
np
.
ones
((
23
+
2
,
17
+
2
))
*
5.0
...
@@ -102,7 +107,7 @@ def test_piecewise1():
...
@@ -102,7 +107,7 @@ def test_piecewise1():
ps
.
Assignment
(
g
[
0
,
0
],
sp
.
Piecewise
((
b
+
3
+
f
[
0
,
1
],
c
),
(
0.0
,
True
)))]
ps
.
Assignment
(
g
[
0
,
0
],
sp
.
Piecewise
((
b
+
3
+
f
[
0
,
1
],
c
),
(
0.0
,
True
)))]
ast
=
ps
.
create_kernel
(
update_rule
)
ast
=
ps
.
create_kernel
(
update_rule
)
vectorize
(
ast
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
func
=
ast
.
compile
()
func
=
ast
.
compile
()
dst
=
np
.
zeros_like
(
arr
)
dst
=
np
.
zeros_like
(
arr
)
func
(
g
=
dst
,
f
=
arr
)
func
(
g
=
dst
,
f
=
arr
)
...
@@ -121,7 +126,7 @@ def test_piecewise2():
...
@@ -121,7 +126,7 @@ def test_piecewise2():
g
[
0
,
0
]
@=
s
.
result
g
[
0
,
0
]
@=
s
.
result
ast
=
ps
.
create_kernel
(
test_kernel
)
ast
=
ps
.
create_kernel
(
test_kernel
)
vectorize
(
ast
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
func
=
ast
.
compile
()
func
=
ast
.
compile
()
func
(
f
=
arr
,
g
=
arr
)
func
(
f
=
arr
,
g
=
arr
)
np
.
testing
.
assert_equal
(
arr
,
np
.
ones_like
(
arr
))
np
.
testing
.
assert_equal
(
arr
,
np
.
ones_like
(
arr
))
...
@@ -137,7 +142,7 @@ def test_piecewise3():
...
@@ -137,7 +142,7 @@ def test_piecewise3():
g
[
0
,
0
]
@=
1.0
/
(
s
.
b
+
s
.
k
)
if
f
[
0
,
0
]
>
0.0
else
1.0
g
[
0
,
0
]
@=
1.0
/
(
s
.
b
+
s
.
k
)
if
f
[
0
,
0
]
>
0.0
else
1.0
ast
=
ps
.
create_kernel
(
test_kernel
)
ast
=
ps
.
create_kernel
(
test_kernel
)
vectorize
(
ast
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
ast
.
compile
()
ast
.
compile
()
...
@@ -151,7 +156,7 @@ def test_logical_operators():
...
@@ -151,7 +156,7 @@ def test_logical_operators():
g
[
0
,
0
]
@=
sp
.
Piecewise
([
1.0
/
f
[
1
,
0
],
s
.
c
],
[
1.0
,
True
])
g
[
0
,
0
]
@=
sp
.
Piecewise
([
1.0
/
f
[
1
,
0
],
s
.
c
],
[
1.0
,
True
])
ast
=
ps
.
create_kernel
(
kernel_and
)
ast
=
ps
.
create_kernel
(
kernel_and
)
vectorize
(
ast
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
ast
.
compile
()
ast
.
compile
()
@ps.kernel
@ps.kernel
...
@@ -161,7 +166,7 @@ def test_logical_operators():
...
@@ -161,7 +166,7 @@ def test_logical_operators():
g
[
0
,
0
]
@=
sp
.
Piecewise
([
1.0
/
f
[
1
,
0
],
s
.
c
],
[
1.0
,
True
])
g
[
0
,
0
]
@=
sp
.
Piecewise
([
1.0
/
f
[
1
,
0
],
s
.
c
],
[
1.0
,
True
])
ast
=
ps
.
create_kernel
(
kernel_or
)
ast
=
ps
.
create_kernel
(
kernel_or
)
vectorize
(
ast
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
ast
.
compile
()
ast
.
compile
()
@ps.kernel
@ps.kernel
...
@@ -171,7 +176,7 @@ def test_logical_operators():
...
@@ -171,7 +176,7 @@ def test_logical_operators():
g
[
0
,
0
]
@=
sp
.
Piecewise
([
1.0
/
f
[
1
,
0
],
s
.
c
],
[
1.0
,
True
])
g
[
0
,
0
]
@=
sp
.
Piecewise
([
1.0
/
f
[
1
,
0
],
s
.
c
],
[
1.0
,
True
])
ast
=
ps
.
create_kernel
(
kernel_equal
)
ast
=
ps
.
create_kernel
(
kernel_equal
)
vectorize
(
ast
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
ast
.
compile
()
ast
.
compile
()
...
@@ -192,27 +197,27 @@ def test_vectorised_pow():
...
@@ -192,27 +197,27 @@ def test_vectorised_pow():
as6
=
ps
.
Assignment
(
g
[
0
,
0
],
sp
.
Pow
(
f
[
0
,
0
],
-
1
))
as6
=
ps
.
Assignment
(
g
[
0
,
0
],
sp
.
Pow
(
f
[
0
,
0
],
-
1
))
ast
=
ps
.
create_kernel
(
as1
)
ast
=
ps
.
create_kernel
(
as1
)
vectorize
(
ast
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
ast
.
compile
()
ast
.
compile
()
ast
=
ps
.
create_kernel
(
as2
)
ast
=
ps
.
create_kernel
(
as2
)
vectorize
(
ast
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
ast
.
compile
()
ast
.
compile
()
ast
=
ps
.
create_kernel
(
as3
)
ast
=
ps
.
create_kernel
(
as3
)
vectorize
(
ast
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
ast
.
compile
()
ast
.
compile
()
ast
=
ps
.
create_kernel
(
as4
)
ast
=
ps
.
create_kernel
(
as4
)
vectorize
(
ast
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
ast
.
compile
()
ast
.
compile
()
ast
=
ps
.
create_kernel
(
as5
)
ast
=
ps
.
create_kernel
(
as5
)
vectorize
(
ast
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
ast
.
compile
()
ast
.
compile
()
ast
=
ps
.
create_kernel
(
as6
)
ast
=
ps
.
create_kernel
(
as6
)
vectorize
(
ast
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
ast
.
compile
()
ast
.
compile
()
...
@@ -223,16 +228,16 @@ def test_vectorised_fast_approximations():
...
@@ -223,16 +228,16 @@ def test_vectorised_fast_approximations():
expr
=
sp
.
sqrt
(
f
[
0
,
0
]
+
f
[
1
,
0
])
expr
=
sp
.
sqrt
(
f
[
0
,
0
]
+
f
[
1
,
0
])
assignment
=
ps
.
Assignment
(
g
[
0
,
0
],
insert_fast_sqrts
(
expr
))
assignment
=
ps
.
Assignment
(
g
[
0
,
0
],
insert_fast_sqrts
(
expr
))
ast
=
ps
.
create_kernel
(
assignment
)
ast
=
ps
.
create_kernel
(
assignment
)
vectorize
(
ast
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
ast
.
compile
()
ast
.
compile
()
expr
=
f
[
0
,
0
]
/
f
[
1
,
0
]
expr
=
f
[
0
,
0
]
/
f
[
1
,
0
]
assignment
=
ps
.
Assignment
(
g
[
0
,
0
],
insert_fast_divisions
(
expr
))
assignment
=
ps
.
Assignment
(
g
[
0
,
0
],
insert_fast_divisions
(
expr
))
ast
=
ps
.
create_kernel
(
assignment
)
ast
=
ps
.
create_kernel
(
assignment
)
vectorize
(
ast
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
ast
.
compile
()
ast
.
compile
()
assignment
=
ps
.
Assignment
(
sp
.
Symbol
(
"
tmp
"
),
3
/
sp
.
sqrt
(
f
[
0
,
0
]
+
f
[
1
,
0
]))
assignment
=
ps
.
Assignment
(
sp
.
Symbol
(
"
tmp
"
),
3
/
sp
.
sqrt
(
f
[
0
,
0
]
+
f
[
1
,
0
]))
ast
=
ps
.
create_kernel
(
insert_fast_sqrts
(
assignment
))
ast
=
ps
.
create_kernel
(
insert_fast_sqrts
(
assignment
))
vectorize
(
ast
)
vectorize
(
ast
,
instruction_set
=
instruction_set
)
ast
.
compile
()
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