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 2018/01/31 20:33:52 UTC

[GitHub] piiswrong commented on a change in pull request #9029: Update ndarray binary ops to use kernel launch instead of mshadow operations

piiswrong commented on a change in pull request #9029: Update ndarray binary ops to use kernel launch instead of mshadow operations
URL: https://github.com/apache/incubator-mxnet/pull/9029#discussion_r165178480
 
 

 ##########
 File path: src/ndarray/ndarray_function-inl.h
 ##########
 @@ -433,6 +442,27 @@ void EvalBroadcast<DEVICE>(TBlob const& src, TBlob* ret, int size, RunContext ct
   out = mshadow::expr::broadcast_with_axis(in, 0, size);
 }
 
+/*! \brief Minimum of three */
+MSHADOW_XINLINE size_t minthree(const size_t a, const size_t b, const size_t c) {
+  return a < b ? (a < c ? a : c) : (b < c ? b : c);
+}
+
+template<typename OP, typename xpu>
+void BinaryOpKernelLaunch(mshadow::Stream<xpu>* s, const TBlob& lhs, const TBlob& rhs, TBlob *out) {
+  using namespace op::mxnet_op;
+  using namespace mshadow;
+  MSHADOW_TYPE_SWITCH(out->type_flag_, DType, {
+    const size_t size = (minthree(out->Size(), lhs.Size(), rhs.Size())
+                         + DataType<DType>::kLanes - 1)
+                        / DataType<DType>::kLanes;
 
 Review comment:
   why do you need to calc size like this?

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