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
b1a72be5
Commit
b1a72be5
authored
5 years ago
by
Martin Bauer
Browse files
Options
Downloads
Patches
Plain Diff
Bufix: RNG nodes produced wrong results when substituted
parent
36f757e2
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pystencils/rng.py
+12
-7
12 additions, 7 deletions
pystencils/rng.py
with
12 additions
and
7 deletions
pystencils/rng.py
+
12
−
7
View file @
b1a72be5
...
@@ -26,13 +26,12 @@ class PhiloxTwoDoubles(CustomCodeNode):
...
@@ -26,13 +26,12 @@ class PhiloxTwoDoubles(CustomCodeNode):
def
__init__
(
self
,
dim
,
time_step
=
TypedSymbol
(
"
time_step
"
,
np
.
uint32
),
keys
=
(
0
,
0
)):
def
__init__
(
self
,
dim
,
time_step
=
TypedSymbol
(
"
time_step
"
,
np
.
uint32
),
keys
=
(
0
,
0
)):
self
.
result_symbols
=
tuple
(
TypedSymbol
(
sp
.
Dummy
().
name
,
np
.
float64
)
for
_
in
range
(
2
))
self
.
result_symbols
=
tuple
(
TypedSymbol
(
sp
.
Dummy
().
name
,
np
.
float64
)
for
_
in
range
(
2
))
symbols_read
=
[
s
for
s
in
keys
if
isinstance
(
s
,
sp
.
Symbol
)]
symbols_read
=
[
s
for
s
in
keys
if
isinstance
(
s
,
sp
.
Symbol
)]
super
().
__init__
(
""
,
symbols_read
=
symbols_read
,
symbols_defined
=
self
.
result_symbols
)
super
().
__init__
(
""
,
symbols_read
=
symbols_read
,
symbols_defined
=
self
.
result_symbols
)
self
.
_time_step
=
time_step
self
.
_time_step
=
time_step
self
.
headers
=
[
'"
philox_rand.h
"'
]
self
.
headers
=
[
'"
philox_rand.h
"'
]
self
.
keys
=
list
(
keys
)
self
.
keys
=
tuple
(
keys
)
self
.
_args
=
(
time_step
,
*
sp
.
sympify
(
keys
))
self
.
_args
=
sp
.
sympify
((
dim
,
time_step
,
keys
))
self
.
_dim
=
dim
self
.
_dim
=
dim
@property
@property
...
@@ -47,9 +46,12 @@ class PhiloxTwoDoubles(CustomCodeNode):
...
@@ -47,9 +46,12 @@ class PhiloxTwoDoubles(CustomCodeNode):
result
.
update
(
loop_counters
)
result
.
update
(
loop_counters
)
return
result
return
result
def
fast_subs
(
self
,
_
):
return
self
# nothing to replace inside this node - would destroy intermediate "dummy" by re-creating them
def
get_code
(
self
,
dialect
,
vector_instruction_set
):
def
get_code
(
self
,
dialect
,
vector_instruction_set
):
parameters
=
[
self
.
_time_step
]
+
[
LoopOverCoordinate
.
get_loop_counter_symbol
(
i
)
parameters
=
[
self
.
_time_step
]
+
[
LoopOverCoordinate
.
get_loop_counter_symbol
(
i
)
for
i
in
range
(
self
.
_dim
)]
+
self
.
keys
for
i
in
range
(
self
.
_dim
)]
+
list
(
self
.
keys
)
while
len
(
parameters
)
<
6
:
while
len
(
parameters
)
<
6
:
parameters
.
append
(
0
)
parameters
.
append
(
0
)
...
@@ -76,8 +78,8 @@ class PhiloxFourFloats(CustomCodeNode):
...
@@ -76,8 +78,8 @@ class PhiloxFourFloats(CustomCodeNode):
super
().
__init__
(
""
,
symbols_read
=
symbols_read
,
symbols_defined
=
self
.
result_symbols
)
super
().
__init__
(
""
,
symbols_read
=
symbols_read
,
symbols_defined
=
self
.
result_symbols
)
self
.
_time_step
=
time_step
self
.
_time_step
=
time_step
self
.
headers
=
[
'"
philox_rand.h
"'
]
self
.
headers
=
[
'"
philox_rand.h
"'
]
self
.
keys
=
list
(
keys
)
self
.
keys
=
tuple
(
keys
)
self
.
_args
=
(
time_step
,
*
sp
.
sympify
(
keys
))
self
.
_args
=
sp
.
sympify
((
dim
,
time_step
,
keys
))
self
.
_dim
=
dim
self
.
_dim
=
dim
@property
@property
...
@@ -92,9 +94,12 @@ class PhiloxFourFloats(CustomCodeNode):
...
@@ -92,9 +94,12 @@ class PhiloxFourFloats(CustomCodeNode):
result
.
update
(
loop_counters
)
result
.
update
(
loop_counters
)
return
result
return
result
def
fast_subs
(
self
,
_
):
return
self
# nothing to replace inside this node - would destroy intermediate "dummy" by re-creating them
def
get_code
(
self
,
dialect
,
vector_instruction_set
):
def
get_code
(
self
,
dialect
,
vector_instruction_set
):
parameters
=
[
self
.
_time_step
]
+
[
LoopOverCoordinate
.
get_loop_counter_symbol
(
i
)
parameters
=
[
self
.
_time_step
]
+
[
LoopOverCoordinate
.
get_loop_counter_symbol
(
i
)
for
i
in
range
(
self
.
_dim
)]
+
self
.
keys
for
i
in
range
(
self
.
_dim
)]
+
list
(
self
.
keys
)
while
len
(
parameters
)
<
6
:
while
len
(
parameters
)
<
6
:
parameters
.
append
(
0
)
parameters
.
append
(
0
)
...
...
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