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

2017-11-22 Thread GitBox
piiswrong commented on a change in pull request #8759: image flip op
URL: https://github.com/apache/incubator-mxnet/pull/8759#discussion_r152694925
 
 

 ##
 File path: src/operator/image/image_random.cc
 ##
 @@ -66,6 +60,32 @@ NNVM_REGISTER_OP(_image_normalize)
 .add_arguments(NormalizeParam::__FIELDS__());
 
 
+NNVM_REGISTER_OP(_image_flip_left_right)
 
 Review comment:
   use one op, flip(axis) instead.


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


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

2017-11-22 Thread GitBox
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 ,
   });
 }
 
+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
+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:
us...@infra.apache.org


With regards,
Apache Git Services