Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arraycontext
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Klöckner
arraycontext
Commits
1db13f2e
Commit
1db13f2e
authored
3 years ago
by
Alexandru Fikl
Committed by
Andreas Klöckner
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add DeviceArray type alias for typing
parent
a2620be2
No related branches found
No related tags found
No related merge requests found
Pipeline
#226119
passed
3 years ago
Stage: test
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
arraycontext/__init__.py
+2
-2
2 additions, 2 deletions
arraycontext/__init__.py
arraycontext/container/traversal.py
+5
-5
5 additions, 5 deletions
arraycontext/container/traversal.py
arraycontext/context.py
+17
-0
17 additions, 0 deletions
arraycontext/context.py
doc/conf.py
+5
-0
5 additions, 0 deletions
doc/conf.py
with
29 additions
and
7 deletions
arraycontext/__init__.py
+
2
−
2
View file @
1db13f2e
...
...
@@ -29,7 +29,7 @@ THE SOFTWARE.
"""
import
sys
from
.context
import
ArrayContext
from
.context
import
ArrayContext
,
DeviceArray
,
DeviceScalar
from
.transform_metadata
import
(
CommonSubexpressionTag
,
ElementwiseMapKernelTag
)
...
...
@@ -74,7 +74,7 @@ from .loopy import make_loopy_program
__all__
=
(
"
ArrayContext
"
,
"
ArrayContext
"
,
"
DeviceScalar
"
,
"
DeviceArray
"
,
"
CommonSubexpressionTag
"
,
"
ElementwiseMapKernelTag
"
,
...
...
This diff is collapsed.
Click to expand it.
arraycontext/container/traversal.py
+
5
−
5
View file @
1db13f2e
...
...
@@ -67,7 +67,7 @@ from functools import update_wrapper, partial, singledispatch
import
numpy
as
np
from
arraycontext.context
import
ArrayContext
from
arraycontext.context
import
ArrayContext
,
DeviceArray
from
arraycontext.container
import
(
ContainerT
,
ArrayOrContainerT
,
NotAnArrayContainerError
,
serialize_container
,
deserialize_container
)
...
...
@@ -355,7 +355,7 @@ def rec_keyed_map_array_container(f: Callable[[Tuple[Any, ...], Any], Any],
def
map_reduce_array_container
(
reduce_func
:
Callable
[[
Iterable
[
Any
]],
Any
],
map_func
:
Callable
[[
Any
],
Any
],
ary
:
ArrayOrContainerT
)
->
Any
:
ary
:
ArrayOrContainerT
)
->
"
DeviceArray
"
:
"""
Perform a map-reduce over array containers.
:param reduce_func: callable used to reduce over the components of *ary*
...
...
@@ -378,7 +378,7 @@ def map_reduce_array_container(
def
multimap_reduce_array_container
(
reduce_func
:
Callable
[[
Iterable
[
Any
]],
Any
],
map_func
:
Callable
[...,
Any
],
*
args
:
Any
)
->
Any
:
*
args
:
Any
)
->
"
DeviceArray
"
:
r
"""
Perform a map-reduce over multiple array containers.
:param reduce_func: callable used to reduce over the components of any
...
...
@@ -401,7 +401,7 @@ def multimap_reduce_array_container(
def
rec_map_reduce_array_container
(
reduce_func
:
Callable
[[
Iterable
[
Any
]],
Any
],
map_func
:
Callable
[[
Any
],
Any
],
ary
:
ArrayOrContainerT
)
->
Any
:
ary
:
ArrayOrContainerT
)
->
"
DeviceArray
"
:
"""
Perform a map-reduce over array containers recursively.
:param reduce_func: callable used to reduce over the components of *ary*
...
...
@@ -455,7 +455,7 @@ def rec_map_reduce_array_container(
def
rec_multimap_reduce_array_container
(
reduce_func
:
Callable
[[
Iterable
[
Any
]],
Any
],
map_func
:
Callable
[...,
Any
],
*
args
:
Any
)
->
Any
:
*
args
:
Any
)
->
"
DeviceArray
"
:
r
"""
Perform a map-reduce over multiple array containers recursively.
:param reduce_func: callable used to reduce over the components of any
...
...
This diff is collapsed.
Click to expand it.
arraycontext/context.py
+
17
−
0
View file @
1db13f2e
...
...
@@ -74,6 +74,19 @@ The interface of an array context
---------------------------------
.. currentmodule:: arraycontext
.. class:: DeviceArray
A (type alias for an) array type supported by the :class:`ArrayContext`
meant to aid in typing annotations. For a explicit list of supported types
see :attr:`ArrayContext.array_types`.
.. class:: DeviceScalar
A (type alias for a) scalar type supported by the :class:`ArrayContext`
meant to aid in typing annotations, e.g. for reductions. In :mod:`numpy`
terminology, this is just an array with a shape of ``()``.
.. autoclass:: ArrayContext
"""
...
...
@@ -110,6 +123,10 @@ from pytools import memoize_method
from
pytools.tag
import
Tag
DeviceArray
=
Any
DeviceScalar
=
Any
# {{{ ArrayContext
class
ArrayContext
(
ABC
):
...
...
This diff is collapsed.
Click to expand it.
doc/conf.py
+
5
−
0
View file @
1db13f2e
...
...
@@ -14,6 +14,11 @@ exec(compile(open("../arraycontext/version.py").read(), "../arraycontext/version
version
=
"
.
"
.
join
(
str
(
x
)
for
x
in
ver_dic
[
"
VERSION
"
])
release
=
ver_dic
[
"
VERSION_TEXT
"
]
autodoc_type_aliases
=
{
"
DeviceScalar
"
:
"
arraycontext.DeviceScalar
"
,
"
DeviceArray
"
:
"
arraycontext.DeviceArray
"
,
}
intersphinx_mapping
=
{
"
https://docs.python.org/3/
"
:
None
,
"
https://numpy.org/doc/stable/
"
:
None
,
...
...
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