Skip to content
Snippets Groups Projects
Commit b60af20a authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Check for contiguity in array operations.

parent 60f8f0d4
No related branches found
No related tags found
No related merge requests found
......@@ -151,6 +151,9 @@ def elwise_kernel_runner(kernel_getter):
actual_args = []
for arg in args:
if isinstance(arg, Array):
if not arg.flags.forc:
raise RuntimeError("only contiguous arrays may "
"be used as arguments to this operation")
actual_args.append(arg.data)
else:
actual_args.append(arg)
......
......@@ -142,6 +142,10 @@ class ElementwiseKernel:
invocation_args = []
for arg, arg_descr in zip(args, self.arguments):
if isinstance(arg_descr, VectorArg):
if not arg.flags.forc:
raise RuntimeError("ElementwiseKernel cannot "
"deal with non-contiguous arrays")
vectors.append(arg)
invocation_args.append(arg.data)
else:
......
......@@ -291,6 +291,10 @@ class ReductionKernel:
from pyopencl.tools import VectorArg
for arg, arg_tp in zip(args, stage_inf.arg_types):
if isinstance(arg_tp, VectorArg):
if not arg.flags.forc:
raise RuntimeError("ReductionKernel cannot "
"deal with non-contiguous arrays")
vectors.append(arg)
invocation_args.append(arg.data)
else:
......
......@@ -442,6 +442,10 @@ if _CL_MODE:
if input_ary.shape != output_ary.shape:
raise ValueError("input and output must have the same shape")
if not input_ary.flags.forc:
raise RuntimeError("ScanKernel cannot "
"deal with non-contiguous arrays")
n, = input_ary.shape
if not n:
......@@ -542,6 +546,10 @@ else:
if input_ary.shape != output_ary.shape:
raise ValueError("input and output must have the same shape")
if not input_ary.flags.forc:
raise RuntimeError("ScanKernel cannot "
"deal with non-contiguous arrays")
n, = input_ary.shape
if not n:
......
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