Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1cd16ff
Add support for fp16 operators: add, sub, mul, fma, abs and neg
testhound Feb 16, 2022
3efd4fe
Correctly name classes for unary operators
testhound Feb 16, 2022
6c69b2c
Add support for inplace binary operators
testhound Feb 17, 2022
5188b28
Merge branch 'main' into testhound/fp16-operators1
testhound Feb 17, 2022
5b721ad
Change to use AbstractTemplate
testhound Mar 3, 2022
87b8c2c
Use ConcreteTemplate for intrinsics and AbstractTemplate for operators
testhound Mar 4, 2022
6809886
Merge branch 'main' into testhound/fp16-operators1
testhound Mar 4, 2022
7b36527
User @register_global to register operator lowering functions, update…
testhound Apr 15, 2022
9269ff7
Merge branch 'main' into testhound/fp16-operators1
testhound Apr 15, 2022
227ca5b
Fix registration of 'abs', add test cases to verify fp16 operators ar…
testhound Apr 15, 2022
fac30e2
Handle different argument types correctly for binary operators
testhound May 12, 2022
db03e4d
Merge branch 'main' into testhound/fp16-operators1
testhound May 12, 2022
5898b6b
Allow safe promotions and safe conversions for fp16 operators
testhound Jun 6, 2022
527973c
Add fp16 mixed type test for binary operators
testhound Jun 7, 2022
f10a4e5
Merge branch 'main' into testhound/fp16-operators1
testhound Jul 5, 2022
882ea3d
Document need for AbstractTemplate and ConcreateTemplate
testhound Jul 8, 2022
0b244ea
Seed RNG and pass additional paramater to self.subTest:
testhound Jul 8, 2022
a7129d4
Merge branch 'main' into testhound/fp16-operators1
testhound Jul 8, 2022
e1783fa
Merge branch 'main' into testhound/fp16-operators1
testhound Jul 25, 2022
7a7ad7d
Update comment description to recommendation by @gmarkall
testhound Jul 26, 2022
b2bef05
Add new case for function resolution of fp16 unary and binary operators
testhound Jul 26, 2022
021503f
Merge branch 'main' into testhound/fp16-operators1
testhound Jul 28, 2022
f26d289
Skip test if nvvm is not available
testhound Jul 29, 2022
8932a70
Simplify test cases and remove redundant assignments, fix comments
testhound Aug 17, 2022
a19874d
Merge branch 'main' into testhound/fp16-operators1
testhound Aug 17, 2022
fbc183d
Merge comments for binary and comparison fp16 operators
testhound Aug 19, 2022
cfeb49c
Merge branch 'main' into testhound/fp16-operators1
testhound Aug 19, 2022
aa4835c
Merge branch 'main' into testhound/fp16-operators1
testhound Sep 1, 2022
dd8498e
Add back erroneously removed skip if compute compatability is less th…
testhound Sep 6, 2022
277cf08
Merge branch 'main' into testhound/fp16-operators1
testhound Sep 6, 2022
224bd48
Skip tests unless cc >= 5.3
testhound Sep 8, 2022
95670b0
Merge branch 'main' into testhound/fp16-operators1
testhound Sep 8, 2022
ce23094
Streamline code by assing assertEqual
testhound Sep 9, 2022
8a96ff7
Merge branch 'main' into testhound/fp16-operators1
testhound Sep 12, 2022
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
Prev Previous commit
Next Next commit
Use ConcreteTemplate for intrinsics and AbstractTemplate for operators
  • Loading branch information
testhound committed Mar 4, 2022
commit 87b8c2cd18375a83991922cadc3749f261107ef6
92 changes: 30 additions & 62 deletions numba/cuda/cudadecl.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,98 +338,66 @@ def generic(self, args, kws):
return signature(a, test, a, a)


#def _genfp16_unary(l_key):
# @register
# class Cuda_fp16_unary(ConcreteTemplate):
# key = l_key
# cases = [signature(types.float16, types.float16)]
#
# return Cuda_fp16_unary

def _genfp16_unary(l_key):
@register
class Cuda_fp16_unary(ConcreteTemplate):
key = l_key
cases = [signature(types.float16, types.float16)]

return Cuda_fp16_unary


def _genfp16_unary_operator(l_key):
@register
Comment thread
gmarkall marked this conversation as resolved.
Resolved
class Cuda_fp16_unary(AbstractTemplate):
key = l_key

def generic(self, args, kws):
assert not kws
Comment thread
gmarkall marked this conversation as resolved.
Resolved
if len(args) == 1 and args[0] == types.float16:
return signature(types.float16, types.float16)

return Cuda_fp16_unary

#def _genfp16_binary(l_key):
# @register
# class Cuda_fp16_binary(ConcreteTemplate):
# key = l_key
# cases = [signature(types.float16, types.float16, types.float16)]
#
# return Cuda_fp16_binary

def _genfp16_binary(l_key):
@register
class Cuda_fp16_binary(ConcreteTemplate):
key = l_key
cases = [signature(types.float16, types.float16, types.float16)]

return Cuda_fp16_binary


def _genfp16_binary_operator(l_key):
@register
Comment thread
gmarkall marked this conversation as resolved.
Resolved
class Cuda_fp16_binary(AbstractTemplate):
key = l_key

def generic(self, args, kws):
assert not kws
if len(args) == 2 and args[0] == types.float16 and args[1] == types.float16:
if len(args) == 2 and \
(args[0] == types.float16 or args[1] == types.float16):
return signature(types.float16, types.float16, types.float16)

return Cuda_fp16_binary


Cuda_hadd = _genfp16_binary(cuda.fp16.hadd)
Cuda_add = _genfp16_binary(operator.add)
Cuda_iadd = _genfp16_binary(operator.iadd)

Cuda_add = _genfp16_binary_operator(operator.add)
Cuda_iadd = _genfp16_binary_operator(operator.iadd)
Cuda_hsub = _genfp16_binary(cuda.fp16.hsub)
Cuda_sub = _genfp16_binary(operator.sub)
Cuda_isub = _genfp16_binary(operator.isub)


Cuda_sub = _genfp16_binary_operator(operator.sub)
Cuda_isub = _genfp16_binary_operator(operator.isub)
Cuda_hmul = _genfp16_binary(cuda.fp16.hmul)
Cuda_mul = _genfp16_binary(operator.mul)
Cuda_imul = _genfp16_binary(operator.imul)


Cuda_hneg = _genfp16_unary(cuda.fp16.hneg)
Cuda_mul = _genfp16_binary_operator(operator.mul)
Cuda_imul = _genfp16_binary_operator(operator.imul)
Cuda_hneg = _genfp16_unary_operator(cuda.fp16.hneg)
Cuda_neg = _genfp16_unary(operator.neg)
Cuda_habs = _genfp16_unary(cuda.fp16.habs)
Cuda_habs = _genfp16_unary_operator(cuda.fp16.habs)
Cuda_abs = _genfp16_unary(operator.abs)


class FP16BinOp(ConcreteTemplate):
cases = [signature(types.float16, types.float16, types.float16)]

#@register_global(operator.iadd)
#@register_global(operator.add)
#class BinOpFP16Add(FP16BinOp):
# pass

#@register_global(operator.isub)
#@register_global(operator.sub)
#class BinOpFP16Sub(FP16BinOp):
# pass

#@register_global(operator.imul)
#@register_global(operator.mul)
#class BinOpFP16Mul(FP16BinOp):
# pass


class FP16UnaryOp(ConcreteTemplate):
cases = [signature(types.float16, types.float16)]


#@register_global(operator.neg)
#class UnaryOpFP16Neg(FP16UnaryOp):
# pass


#@register_global(operator.abs)
#class UnaryOpFP16Abs(FP16UnaryOp):
# pass


# generate atomic operations
def _gen(l_key, supported_types):
@register
Expand Down