Skip to content

PytatoPyOpenCLArrayContext: respect arraycontext.loopy's options #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions arraycontext/impl/pytato/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import numpy as np
from typing import Any, Callable, Union, Sequence, TYPE_CHECKING
from pytools.tag import Tag
from arraycontext.loopy import _DEFAULT_LOOPY_OPTIONS

if TYPE_CHECKING:
import pytato
Expand Down Expand Up @@ -121,7 +122,6 @@ def call_loopy(self, program, **kwargs):
def freeze(self, array):
import pytato as pt
import pyopencl.array as cla
import loopy as lp

if isinstance(array, cla.Array):
return array.with_queue(None)
Expand Down Expand Up @@ -150,8 +150,7 @@ def freeze(self, array):
pt_prg = self._freeze_prg_cache[normalized_expr]
except KeyError:
pt_prg = pt.generate_loopy(self.transform_dag(normalized_expr),
options=lp.Options(return_dict=True,
no_numpy=True),
options=_DEFAULT_LOOPY_OPTIONS,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I'd prefer if this could be customized per instance of the pytato array context. This is too global for my taste.
  • Also, it should check that the important options are set.

cl_device=self.queue.device)
pt_prg = pt_prg.with_transformed_program(self.transform_loopy_program)
self._freeze_prg_cache[normalized_expr] = pt_prg
Expand Down
7 changes: 2 additions & 5 deletions arraycontext/impl/pytato/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from arraycontext import PytatoPyOpenCLArrayContext
from arraycontext.container.traversal import (rec_keyed_map_array_container,
is_array_container)
from arraycontext.loopy import _DEFAULT_LOOPY_OPTIONS

import numpy as np
from typing import Any, Callable, Tuple, Dict, Mapping
Expand Down Expand Up @@ -225,15 +226,11 @@ def _as_dict_of_named_arrays(keys, ary):
rec_keyed_map_array_container(_as_dict_of_named_arrays,
outputs)

import loopy as lp

pt_dict_of_named_arrays = self.actx.transform_dag(
pt.make_dict_of_named_arrays(dict_of_named_arrays))

pytato_program = pt.generate_loopy(pt_dict_of_named_arrays,
options=lp.Options(
return_dict=True,
no_numpy=True),
options=_DEFAULT_LOOPY_OPTIONS,
cl_device=self.actx.queue.device)
assert isinstance(pytato_program, BoundPyOpenCLProgram)

Expand Down