Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-codegen
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Christian Heinigk
dune-codegen
Commits
875bb3e4
Commit
875bb3e4
authored
8 years ago
by
Dominic Kempf
Browse files
Options
Downloads
Patches
Plain Diff
Add a shape determination algorithm
parent
e1d99888
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
python/dune/perftool/ufl/shape.py
+37
-0
37 additions, 0 deletions
python/dune/perftool/ufl/shape.py
with
37 additions
and
0 deletions
python/dune/perftool/ufl/shape.py
0 → 100644
+
37
−
0
View file @
875bb3e4
"""
An algorithm to determine the shape aka the loop domain for a given index
"""
from
ufl.algorithms
import
MultiFunction
class
ShapeDetermination
(
MultiFunction
):
def
__init__
(
self
,
index
):
MultiFunction
.
__init__
(
self
)
self
.
index
=
index
def
expr
(
self
,
o
):
ret
=
tuple
(
self
(
op
)
for
op
in
o
.
ufl_operands
)
asset
=
set
(
ret
)
if
len
(
asset
)
==
0
:
return
None
if
len
(
asset
)
==
1
:
# All determined shapes are equal. We just use the result.
return
ret
[
0
]
if
len
(
asset
)
==
2
:
try
:
# Two shapes determined, one might be "None" so we use the other.
asset
.
remove
(
None
)
return
ret
[
0
]
except
KeyError
:
pass
raise
AssertionError
(
"
I had trouble determining the shape of an expression!
"
)
def
indexed
(
self
,
o
):
try
:
position
=
o
.
ufl_operands
[
1
].
indices
().
index
(
self
.
index
)
return
o
.
ufl_operands
[
0
].
ufl_shape
[
position
]
except
ValueError
:
return
self
(
o
.
ufl_operands
[
0
])
def
determine_shape
(
expr
,
i
):
return
ShapeDetermination
(
i
)(
expr
)
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