From 310531a0f791623e1e00dea3f245f5b3f401b653 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 10 Jul 2017 16:16:39 -0500 Subject: [PATCH 1/2] Fix PyOpenCLKernelExecutor.get_code to adequately preprocess arg_to_dtype so that get_typed_and_scheduled_kernel caching works --- loopy/target/pyopencl_execution.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/loopy/target/pyopencl_execution.py b/loopy/target/pyopencl_execution.py index a8f47adb9..f7400d5d0 100644 --- a/loopy/target/pyopencl_execution.py +++ b/loopy/target/pyopencl_execution.py @@ -25,6 +25,7 @@ THE SOFTWARE. import six from six.moves import range, zip +import numpy as np from pytools import ImmutableRecord, memoize_method from loopy.diagnostic import ParameterFinderWarning from pytools.py_codegen import ( @@ -686,8 +687,17 @@ class PyOpenCLKernelExecutor(KernelExecutorBase): # {{{ debugging aids def get_code(self, arg_to_dtype=None): + def process_dtype(dtype): + if issubclass(dtype, np.generic): + dtype = np.dtype(dtype) + if isinstance(dtype, np.dtype): + dtype = NumpyType(dtype, self.kernel.target) + + return dtype + if arg_to_dtype is not None: - arg_to_dtype = frozenset(six.iteritems(arg_to_dtype)) + arg_to_dtype = frozenset( + (k, process_dtype(v)) for k, v in six.iteritems(arg_to_dtype)) kernel = self.get_typed_and_scheduled_kernel(arg_to_dtype) -- GitLab From 6873784a8a4832fb79a793f8ea3736f11f590032 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 10 Jul 2017 16:42:40 -0500 Subject: [PATCH 2/2] Fix: Fix PyOpenCLKernelExecutor.get_code to adequately preprocess arg_to_dtype so that get_typed_and_scheduled_kernel caching works --- loopy/target/pyopencl_execution.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopy/target/pyopencl_execution.py b/loopy/target/pyopencl_execution.py index f7400d5d0..2da25ba39 100644 --- a/loopy/target/pyopencl_execution.py +++ b/loopy/target/pyopencl_execution.py @@ -688,7 +688,7 @@ class PyOpenCLKernelExecutor(KernelExecutorBase): def get_code(self, arg_to_dtype=None): def process_dtype(dtype): - if issubclass(dtype, np.generic): + if isinstance(dtype, type) and issubclass(dtype, np.generic): dtype = np.dtype(dtype) if isinstance(dtype, np.dtype): dtype = NumpyType(dtype, self.kernel.target) -- GitLab