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 2017/11/22 22:43:50 UTC

[GitHub] piiswrong commented on a change in pull request #8759: image flip op

piiswrong commented on a change in pull request #8759: image flip op
URL: https://github.com/apache/incubator-mxnet/pull/8759#discussion_r152694849
 
 

 ##########
 File path: src/operator/image/image_random-inl.h
 ##########
 @@ -144,6 +151,45 @@ static void Normalize(const nnvm::NodeAttrs &attrs,
   });
 }
 
+inline static int FlipIndex(int idx, const int stride, const int trailing) {
+  const int low = idx % trailing;
+  int high = idx / trailing;
+  const int x = high % stride;
+  high /= stride;
+
+  return (high * stride + stride - 1 - x) * trailing + low;
+}
+
+template<typename DType>
+static void FlipImpl(const int size, DType *src, DType *dst,
+                     const int stride, const int trailing) {
+  for (int idx = 0; idx < size; ++idx) {
+    int new_idx = FlipIndex(idx, stride, trailing);
 
 Review comment:
   Doing this on every index is slow. Either use two loops explicitly or use `inc`, see broadcasting for example

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