You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/10/29 21:46:38 UTC

[GitHub] [incubator-mxnet] Laurawly commented on a change in pull request #16660: [WIP] [Numpy] TVM implementation for binary ops

Laurawly 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_r340226828
 
 

 ##########
 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:
   A better method as @reminisce suggested is to add an api to add new binary functions to the dictionary.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services