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
9f79445e
Commit
9f79445e
authored
6 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Add test for `address_of`
parent
de250f5a
No related branches found
No related tags found
1 merge request
!1
Address of SymPy-Function `address_of`
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pystencils_tests/test_address_of.py
+58
-0
58 additions, 0 deletions
pystencils_tests/test_address_of.py
with
58 additions
and
0 deletions
pystencils_tests/test_address_of.py
0 → 100644
+
58
−
0
View file @
9f79445e
"""
Test of pystencils.data_types.address_of
"""
from
pystencils.data_types
import
address_of
,
cast_func
,
PointerType
import
pystencils
from
pystencils.simp.simplifications
import
sympy_cse
import
sympy
def
test_address_of
():
x
,
y
=
pystencils
.
fields
(
'
x,y: int64[2d]
'
)
s
=
pystencils
.
TypedSymbol
(
'
s
'
,
PointerType
(
'
int64
'
))
assignments
=
pystencils
.
AssignmentCollection
({
s
:
address_of
(
x
[
0
,
0
]),
y
[
0
,
0
]:
cast_func
(
s
,
'
int64
'
)
},
{})
ast
=
pystencils
.
create_kernel
(
assignments
)
code
=
pystencils
.
show_code
(
ast
)
print
(
code
)
assignments
=
pystencils
.
AssignmentCollection
({
y
[
0
,
0
]:
cast_func
(
address_of
(
x
[
0
,
0
]),
'
int64
'
)
},
{})
ast
=
pystencils
.
create_kernel
(
assignments
)
code
=
pystencils
.
show_code
(
ast
)
print
(
code
)
def
test_address_of_with_cse
():
x
,
y
=
pystencils
.
fields
(
'
x,y: int64[2d]
'
)
s
=
pystencils
.
TypedSymbol
(
'
s
'
,
PointerType
(
'
int64
'
))
assignments
=
pystencils
.
AssignmentCollection
({
y
[
0
,
0
]:
cast_func
(
address_of
(
x
[
0
,
0
]),
'
int64
'
),
x
[
0
,
0
]:
cast_func
(
address_of
(
x
[
0
,
0
]),
'
int64
'
)
+
1
},
{})
ast
=
pystencils
.
create_kernel
(
assignments
)
code
=
pystencils
.
show_code
(
ast
)
assignments_cse
=
sympy_cse
(
assignments
)
ast
=
pystencils
.
create_kernel
(
assignments_cse
)
code
=
pystencils
.
show_code
(
ast
)
print
(
code
)
def
main
():
test_address_of
()
test_address_of_with_cse
()
if
__name__
==
'
__main__
'
:
main
()
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