mxnet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] cjolivier01 commented on a change in pull request #8686: Kernel operator tuning
Date Thu, 01 Jan 1970 00:00:00 GMT
cjolivier01 commented on a change in pull request #8686: Kernel operator tuning
URL: https://github.com/apache/incubator-mxnet/pull/8686#discussion_r151841248
 
 

 ##########
 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:
   Added check to Compute call in the "remove broadcast" commit

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


With regards,
Apache Git Services

Mime
View raw message