Skip to content
Snippets Groups Projects
Commit 8c678742 authored by Matthias Diener's avatar Matthias Diener
Browse files

change compile() location and some doc fixes

parent 54101c33
No related branches found
No related tags found
No related merge requests found
......@@ -102,12 +102,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
from typing import Sequence, Union
from typing import Sequence, Union, Callable, Any, Tuple
from abc import ABC, abstractmethod
import numpy as np
from pytools import memoize_method
from pytools.tag import Tag
from numbers import Number
# {{{ ArrayContext
......@@ -148,6 +149,7 @@ class ArrayContext(ABC):
.. automethod:: thaw
.. automethod:: tag
.. automethod:: tag_axis
.. automethod:: compile
"""
def __init__(self):
......@@ -349,6 +351,19 @@ class ArrayContext(ABC):
"setup-only" array context "leaks" into the application.
"""
def compile(self, f: Callable[[Any], Any],
inputs_like: Tuple[Union[Number, np.ndarray], ...]) -> Callable[
..., Any]:
"""Compiles a function for use on this array context. Might perform some
optimizations (such as kernel fusion) during compilation.
:arg f: the function to compile.
:arg inputs_like: the input arguments to the function.
:return: the compiled function.
"""
return f
# }}}
# vim: foldmethod=marker
......@@ -26,10 +26,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
from typing import Sequence, Union, Callable, Any, Tuple
from typing import Sequence, Union
from functools import partial
import operator
from numbers import Number
import numpy as np
......@@ -344,11 +343,6 @@ class PyOpenCLArrayContext(ArrayContext):
def clone(self):
return type(self)(self.queue, self.allocator, self._wait_event_queue_length)
def compile(self, f: Callable[[Any], Any],
inputs_like: Tuple[Union[Number, np.ndarray], ...]) -> Callable[
..., Any]:
return f
# }}}
# vim: foldmethod=marker
......@@ -224,13 +224,14 @@ class PytatoArrayContext(ArrayContext):
A :class:`ArrayContext` that uses :mod:`pytato` data types to represent
the DOF arrays targeting OpenCL for offloading operations.
.. attribute:: context
A :class:`pyopencl.Context`.
.. attribute:: queue
A :class:`pyopencl.CommandQueue`.
.. attribute:: allocator
A :mod:`pyopencl` memory allocator. Can also be None (default) or False
to use the default allocator.
"""
def __init__(self, queue, allocator=None):
......
......@@ -15,6 +15,6 @@ Array context based on :mod:`pyopencl.array`
Array context based on :mod:`pytato`
--------------------------------------------
------------------------------------
.. automodule:: arraycontext.impl.pytato
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment