[WIP] this fixes some, but not all, cases...
@@ -33,6 +33,7 @@ from cupy_backends.cuda.api cimport runtime
import math
import string
+import warnings
import numpy
@@ -496,7 +497,11 @@ cdef class _AbstractReductionKernel:
cpdef _SimpleReductionKernel create_reduction_func(
name, ops, routine=None, identity=None, preamble='',
sort_reduce_axis=True):
+ print(ops)
+ print(routine)
ops = _kernel._Ops.from_tuples(ops, routine)
+ for op in ops.ops:
+ print(op.in_types, op.out_types, op.routine)
return _SimpleReductionKernel(
name, ops, identity, preamble, sort_reduce_axis)
@@ -544,6 +549,16 @@ cdef class _SimpleReductionKernel(_AbstractReductionKernel):
raise TypeError(
'Argument \'a\' has incorrect type (expected %s, got %s)' %
(ndarray, type(a)))
+
+ in_dtype = arr.dtype
+ print("\n\n\n I AM CALLED \n\n\n")
+ if (in_dtype.kind == 'c'
+ and numpy.dtype(dtype).kind == 'f'):
+ warnings.warn(
+ 'Casting complex values to real discards the imaginary part',
+ numpy.ComplexWarning)
+ arr = arr.real
+
in_args = [arr]
dev_id = device.get_device_id()
