Skip to content

Commit b6554e2

Browse files
authored
Merge pull request #328 from abergeron/reduce_f16
Raise an error for float16 in ReductionKernel.
2 parents 61fe479 + 612ae2f commit b6554e2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

pygpu/reduction.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ def __init__(self, context, dtype_out, neutral, reduce_expr, redux,
150150
else:
151151
self.arguments = arguments
152152

153+
if (self.dtype_out == numpy.dtype('float16') or
154+
any(ar.dtype == numpy.dtype('float16')
155+
for ar in self.arguments)):
156+
raise NotImplementedError('float16 not supported for the reduction interface')
157+
153158
self.reduce_expr = reduce_expr
154159
if map_expr is None:
155160
if len(self.arguments) != 1:

pygpu/tests/test_reduction.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import numpy
22

3+
from nose.tools import assert_raises
4+
35
from pygpu import gpuarray, ndgpuarray as elemary
46
from pygpu.reduction import ReductionKernel
57

@@ -130,3 +132,9 @@ def test_reduction_0d():
130132
rg = g.all()
131133

132134
assert numpy.all(rc == numpy.asarray(rg))
135+
136+
137+
def test_reduction_f16():
138+
c, g = gen_gpuarray((3,), dtype='float16', ctx=context, cls=elemary)
139+
140+
assert_raises(NotImplementedError, g.sum)

0 commit comments

Comments
 (0)