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_r317888810
 
 

 ##########
 File path: src/operator/contrib/tvmop/ufunc.cc
 ##########
 @@ -144,6 +144,61 @@ NNVM_REGISTER_OP(_backward_contrib_tvm_vadd)
     .set_attr<mxnet::FCompute>("FCompute<cpu>",
                                
mxnet::op::TVMBinaryBackwardComputeUseNone<func_bakcward_vadd_cpu>);
 
+
+static constexpr char func_exp2_cpu[] = "exp2";
+static constexpr char func_epx2_gpu[] = "cuda_exp2";
+static constexpr char func_backward_epx2_cpu[] = "backward_exp2";
+static constexpr char func_backward_epx2_gpu[] = "cuda_backward_exp2";
+
+template<const char* func>
+void TVMOpExp2Compute(const nnvm::NodeAttrs& attrs,
+                      const mxnet::OpContext& ctx,
+                      const std::vector<TBlob>& inputs,
+                      const std::vector<OpReqType>& req,
+                      const std::vector<TBlob>& outputs) {
+  CHECK_EQ(inputs.size(), 1U);
+  CHECK_EQ(outputs.size(), 1U);
+  tvm::runtime::TVMOpModule::Get()->Call(func, ctx, {inputs[0], outputs[0]});
+}
+
+template<const char* func>
+void TVMExp2Backward(const nnvm::NodeAttrs& attrs,
+                     const OpContext& ctx,
+                     const std::vector<TBlob>& inputs,
+                     const std::vector<OpReqType>& req,
+                     const std::vector<TBlob>& outputs) {
+  CHECK_EQ(inputs.size(), 3U);
+  CHECK_EQ(outputs.size(), 1U);
+  CHECK_EQ(req.size(), 1U);
+  using namespace mshadow;
+  const TBlob& out_grad = inputs[0];
+  const TBlob& in_data1 = inputs[1];
+  const TBlob& in_data2 = inputs[2];
+  const TBlob& in_grad = outputs[0];
+  tvm::runtime::TVMOpModule::Get()->Call(func, ctx, {out_grad, in_data1, 
in_data2, in_grad});
+}
+
+NNVM_REGISTER_OP(_npi_exp2)
+    .set_num_inputs(1)
 
 Review comment:
   no indentation

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