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
e9ee769d
Commit
e9ee769d
authored
4 months ago
by
Richard Angersbach
Browse files
Options
Downloads
Patches
Plain Diff
Adaptations to reduction test
parent
9a8e6f9b
No related branches found
No related tags found
1 merge request
!438
Reduction Support
Pipeline
#72114
failed
4 months ago
Stage: Code Quality
Stage: Unit Tests
Stage: legacy_test
Stage: docs
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/kernelcreation/test_reduction.py
+12
-28
12 additions, 28 deletions
tests/kernelcreation/test_reduction.py
with
12 additions
and
28 deletions
tests/kernelcreation/test_reduction.py
+
12
−
28
View file @
e9ee769d
...
@@ -6,39 +6,23 @@ import pystencils as ps
...
@@ -6,39 +6,23 @@ import pystencils as ps
from
pystencils
import
AddReducedAssignment
from
pystencils
import
AddReducedAssignment
@pytest.mark.parametrize
(
'
dtype
'
,
[
"
float64
"
,
"
float32
"
])
@pytest.mark.parametrize
(
'
dtype
'
,
[
"
float64
"
])
def
test_log
(
dtype
):
def
test_reduction
(
dtype
):
a
=
sp
.
Symbol
(
"
a
"
)
x
=
ps
.
fields
(
f
'
x:
{
dtype
}
[1d]
'
)
x
=
ps
.
fields
(
f
'
x:
{
dtype
}
[1d]
'
)
w
=
sp
.
Symbol
(
"
w
"
)
# kernel with
mai
n assignment
s and no reduction
# kernel with
reductio
n assignment
mai
n_assignment
=
ps
.
AssignmentCollection
({
x
.
center
()
:
a
}
)
reductio
n_assignment
=
AddReducedAssignment
(
w
,
x
.
center
())
ast_main
=
ps
.
create_kernel
(
main_assignment
,
default_dtype
=
dtype
)
config
=
ps
.
CreateKernelConfig
(
cpu_openmp
=
True
)
code_main
=
ps
.
get_code_str
(
ast_main
)
kernel_main
=
ast_main
.
compile
()
# ps.show_code(ast)
ast_reduction
=
ps
.
create_kernel
([
reduction_assignment
],
config
,
default_dtype
=
dtype
)
#code_reduction = ps.get_code_str(ast_reduction)
if
dtype
==
"
float64
"
:
assert
"
float
"
not
in
code_main
array
=
np
.
zeros
((
10
,),
dtype
=
dtype
)
kernel_main
(
x
=
array
,
a
=
100
)
assert
np
.
allclose
(
array
,
4.60517019
)
# kernel with single reduction assignment
omega
=
sp
.
Symbol
(
"
omega
"
)
reduction_assignment
=
AddReducedAssignment
(
omega
,
x
.
center
())
ast_reduction
=
ps
.
create_kernel
(
reduction_assignment
,
default_dtype
=
dtype
)
code_reduction
=
ps
.
get_code_str
(
ast_reduction
)
kernel_reduction
=
ast_reduction
.
compile
()
kernel_reduction
=
ast_reduction
.
compile
()
if
dtype
==
"
float64
"
:
ps
.
show_code
(
ast_reduction
)
assert
"
float
"
not
in
code_reduction
ps
.
show_code
(
ast_reduction
)
array
=
np
.
ones
((
10
,),
dtype
=
dtype
)
\ No newline at end of file
kernel_reduction
(
x
=
array
,
w
=
0
)
# TODO: check if "w = #points"
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Frederik Hennig
@da15siwa
mentioned in commit
4e688b86
·
2 weeks ago
mentioned in commit
4e688b86
mentioned in commit 4e688b867339c90a6fba3ad12c383d1e59211ed9
Toggle commit list
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