reminisce commented on a change in pull request #15973: Numpy . implement numpy 
 op exp2 with tvm
URL: https://github.com/apache/incubator-mxnet/pull/15973#discussion_r317888436
 
 

 ##########
 File path: contrib/tvmop/basic/ufunc.py
 ##########
 @@ -98,3 +99,71 @@ def backward_vadd_gpu(dtype, ndim, reduce1st, req):
         s[t].bind(bx, block_x)
         s[t].bind(tx, thread_x)
     return s, [X, in_grad_a, in_grad]
+
+def compute_exp2(dtype, ndim):
+    A = tvm.placeholder([tvm.var() for _ in range(ndim)], name='A', 
dtype=dtype)
+    if dtype in ['float32', 'float64']:
+        B = tvm.compute([tvm.var() for _ in range(ndim)],
+                        lambda *index: topi.power(2, A[index]), name='B')
+    else:
+        B = tvm.compute([tvm.var() for _ in range(ndim)],
+                        lambda *index: topi.power(2, 
A[index].astype('float32')).astype(dtype),
+                        name='B')
+    s = tvm.create_schedule(B.op)
+    return s, A, B
+
+
+@defop(name="exp2", target="cpu", auto_broadcast=True,
 
 Review comment:
   This is strictly an element-wise unary op. `auto_broadcast` should not be 
needed.

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

Reply via email to