Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
loopy
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kaushik Kulkarni
loopy
Commits
bd3222c7
Commit
bd3222c7
authored
9 years ago
by
James Stevens
Browse files
Options
Downloads
Patches
Plain Diff
added version of add_and_infer_dtypes that accepts type dicts with unused variables
parent
7364c0e6
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
loopy/kernel/tools.py
+23
-5
23 additions, 5 deletions
loopy/kernel/tools.py
with
23 additions
and
5 deletions
loopy/kernel/tools.py
+
23
−
5
View file @
bd3222c7
...
...
@@ -43,6 +43,22 @@ def add_dtypes(knl, dtype_dict):
:arg dtype_dict: a mapping from variable names to :class:`numpy.dtype`
instances
"""
dtype_dict_remainder
,
new_args
,
new_temp_vars
=
_add_dtypes
(
knl
,
dtype_dict
)
if
dtype_dict_remainder
:
raise
RuntimeError
(
"
unused argument dtypes: %s
"
%
"
,
"
.
join
(
dtype_dict_remainder
))
return
knl
.
copy
(
args
=
new_args
,
temporary_variables
=
new_temp_vars
)
def
_add_dtypes_overdetermined
(
knl
,
dtype_dict
):
dtype_dict_remainder
,
new_args
,
new_temp_vars
=
_add_dtypes
(
knl
,
dtype_dict
)
# do not throw error for unused args
return
knl
.
copy
(
args
=
new_args
,
temporary_variables
=
new_temp_vars
)
def
_add_dtypes
(
knl
,
dtype_dict
):
dtype_dict
=
dtype_dict
.
copy
()
new_args
=
[]
...
...
@@ -76,11 +92,7 @@ def add_dtypes(knl, dtype_dict):
new_temp_vars
[
tv_name
]
=
tv
.
copy
(
dtype
=
new_dtype
)
if
dtype_dict
:
raise
RuntimeError
(
"
unused argument dtypes: %s
"
%
"
,
"
.
join
(
dtype_dict
))
return
knl
.
copy
(
args
=
new_args
,
temporary_variables
=
new_temp_vars
)
return
dtype_dict
,
new_args
,
new_temp_vars
def
get_arguments_with_incomplete_dtype
(
knl
):
...
...
@@ -94,6 +106,12 @@ def add_and_infer_dtypes(knl, dtype_dict):
from
loopy.preprocess
import
infer_unknown_types
return
infer_unknown_types
(
knl
,
expect_completion
=
True
)
def
_add_and_infer_dtypes_overdetermined
(
knl
,
dtype_dict
):
knl
=
_add_dtypes_overdetermined
(
knl
,
dtype_dict
)
from
loopy.preprocess
import
infer_unknown_types
return
infer_unknown_types
(
knl
,
expect_completion
=
True
)
# }}}
...
...
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