piiswrong commented on a change in pull request #8686: Kernel operator tuning 
including broadcast
URL: https://github.com/apache/incubator-mxnet/pull/8686#discussion_r151821026
 
 

 ##########
 File path: src/operator/tensor/elemwise_binary_broadcast_op.h
 ##########
 @@ -134,24 +137,122 @@ inline int BinaryBroadcastShapeCompact(const TShape& 
lshape, const TShape& rshap
 }
 
 namespace mxnet_op {
-template<int ndim, typename DType, typename OP>
-struct binary_broadcast_kernel {
+
+/*!
+ * \brief Type-level specialization base class for binary_broadcast_kernel
+ * \tparam DType
+ */
+template <typename DType> struct tunable_binary_broadcast_kernel;
+
+template<int ndim, typename DType, typename OP, bool is_tuning = false>
+struct binary_broadcast_kernel : public tunable_binary_broadcast_kernel<DType> 
{
+  /*! \brief Map function for binary_broadcast_kernel */
   MSHADOW_XINLINE static void Map(int base, int length, OpReqType req,
                                   const Shape<ndim>& lstride, const 
Shape<ndim>& rstride,
                                   const Shape<ndim>& oshape, DType* lhs, 
DType* rhs,
-                                  DType* out, int lsize, int rsize) {
-    Shape<ndim> coord = unravel(base, oshape);
-    index_t lidx = dot(coord, lstride);
-    index_t ridx = dot(coord, rstride);
-    KERNEL_ASSIGN(out[base], req, OP::Map(lhs[lidx], rhs[ridx]));
-    // starts from 1 to avoid extra inc at end of loop
-    for (int i = 1; i < length; ++i) {
-      inc(&coord, oshape, &lidx, lstride, &ridx, rstride);
-      KERNEL_ASSIGN(out[base+i], req, OP::Map(lhs[lidx], rhs[ridx]));
+                                  DType* out) {
+    if (req != kNullOp) {
 
 Review comment:
   if req is null the kernel shouldn't be launched

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to