Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pystencils_autodiff
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
pycodegen
pystencils_autodiff
Commits
0cd0283c
Commit
0cd0283c
authored
4 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Support symbolic index assignments
parent
e0a3abbd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pystencils_autodiff/_autodiff.py
+7
-7
7 additions, 7 deletions
src/pystencils_autodiff/_autodiff.py
with
7 additions
and
7 deletions
src/pystencils_autodiff/_autodiff.py
+
7
−
7
View file @
0cd0283c
...
@@ -122,7 +122,7 @@ def _create_backward_assignments_tf_mad(self, diff_fields_prefix):
...
@@ -122,7 +122,7 @@ def _create_backward_assignments_tf_mad(self, diff_fields_prefix):
elif
diff_read_field
.
index_dimensions
==
1
:
elif
diff_read_field
.
index_dimensions
==
1
:
diff_read_field_sum
=
[
0
]
*
diff_read_field
.
index_shape
[
0
]
diff_read_field_sum
=
{}
for
ra
in
read_field_accesses
:
for
ra
in
read_field_accesses
:
if
ra
.
field
!=
forward_read_field
:
if
ra
.
field
!=
forward_read_field
:
continue
# ignore constant fields in differentiation
continue
# ignore constant fields in differentiation
...
@@ -130,19 +130,19 @@ def _create_backward_assignments_tf_mad(self, diff_fields_prefix):
...
@@ -130,19 +130,19 @@ def _create_backward_assignments_tf_mad(self, diff_fields_prefix):
# TF-MAD requires flipped stencils
# TF-MAD requires flipped stencils
inverted_offset
=
tuple
(
-
v
-
w
for
v
,
inverted_offset
=
tuple
(
-
v
-
w
for
v
,
w
in
zip
(
ra
.
offsets
,
write_field_accesses
[
0
].
offsets
))
w
in
zip
(
ra
.
offsets
,
write_field_accesses
[
0
].
offsets
))
diff_read_field_sum
[
ra
.
index
[
0
]
diff_read_field_sum
[
ra
.
index
[
0
]
]
=
diff_read_field_sum
.
get
(
]
+
=
sp
.
diff
(
forward_assignment
.
rhs
,
ra
)
*
diff_write_field
[
inverted_offset
]
ra
.
index
[
0
],
0
)
+
sp
.
diff
(
forward_assignment
.
rhs
,
ra
)
*
diff_write_field
[
inverted_offset
]
for
index
in
range
(
diff_read_field
.
index_shape
[
0
]
):
for
index
in
diff_read_field
_sum
.
keys
(
):
if
self
.
time_constant_fields
is
not
None
and
forward_read_field
in
self
.
_time_constant_fields
:
if
self
.
time_constant_fields
is
not
None
and
forward_read_field
in
self
.
_time_constant_fields
:
# Accumulate in case of time_constant_fields
# Accumulate in case of time_constant_fields
assignment
=
ps
.
Assignment
(
assignment
=
ps
.
Assignment
(
diff_read_field
.
center
_vector
[
index
]
,
diff_read_field
.
center
.
at_index
(
index
)
,
diff_read_field
.
center
_vector
[
index
]
+
diff_read_field_sum
[
index
])
diff_read_field
.
center
.
at_index
(
index
)
+
diff_read_field_sum
[
index
])
else
:
else
:
# If time dependent, we just need to assign the sum for the current time step
# If time dependent, we just need to assign the sum for the current time step
assignment
=
ps
.
Assignment
(
assignment
=
ps
.
Assignment
(
diff_read_field
.
center
_vector
[
index
]
,
diff_read_field_sum
[
index
])
diff_read_field
.
center
.
at_index
(
index
)
,
diff_read_field_sum
[
index
])
if
assignment
.
lhs
in
backward_assignment_dict
:
if
assignment
.
lhs
in
backward_assignment_dict
:
backward_assignment_dict
[
assignment
.
lhs
].
append
(
assignment
.
rhs
)
backward_assignment_dict
[
assignment
.
lhs
].
append
(
assignment
.
rhs
)
...
...
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