hzfan commented on a change in pull request #16660: [WIP] [Numpy] TVM
implementation for binary ops
URL: https://github.com/apache/incubator-mxnet/pull/16660#discussion_r343961440
##########
File path: contrib/tvmop/core/umath.py
##########
@@ -120,3 +121,327 @@ def _compute_binary_scalar_logic(op, dtype, ndim):
**_bin_scalar_logic_cpu_attrs)(_binary_logic_cpu)
defop(name='{}_gpu'.format(op_name), op=op_name,
**_bin_scalar_logic_gpu_attrs)(_binary_logic_gpu)
+
+
+_bin_cpu_attrs_base = {
+ 'target': 'cpu',
+ 'dtype': AllTypes,
+ 'ndim': [5],
+ 'req': ['kWriteTo', 'kAddTo'],
+ 'attrs': ['req'],
+}
+
+_bin_gpu_attrs_base = {
+ 'target': 'gpu',
+ 'dtype': ["float32", "float64", "uint8", "int8", "int32", "int64"],
+ 'ndim': [5],
+ 'req': ['kWriteTo', 'kAddTo'],
+ 'attrs': ['req'],
+}
+
+def _binary_cpu(compute_func, op, dtype, ndim, req):
+ s, a, b, old, new = compute_func(op, dtype, ndim, req)
+ axes = [axis for axis in new.op.axis]
+ fused = s[new].fuse(*axes)
+ s[new].parallel(fused)
+ return s, [a, b, old, new]
+
+
+def _binary_gpu(compute_func, op, dtype, ndim, req):
+ s, a, b, old, new = compute_func(op, dtype, ndim, req)
+ axes = [axis for axis in new.op.axis]
+ fused = s[new].fuse(*axes)
+ bx, tx = s[new].split(fused, factor=64)
+ s[new].bind(bx, tvm.thread_axis('blockIdx.x'))
+ s[new].bind(tx, tvm.thread_axis('threadIdx.x'))
+ return s, [a, b, old, new]
+
+_bin_op_map = {
Review comment:
Agree. I will do it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services