diff --git a/paddle/operators/elementwise_op_function.h b/paddle/operators/elementwise_op_function.h index 7ebfc7df8c117edd7bcf14cc5ae6ba3dc1302c03..65484f318ea7b2ef1fd82451753764db00a8e872 100644 --- a/paddle/operators/elementwise_op_function.h +++ b/paddle/operators/elementwise_op_function.h @@ -103,10 +103,12 @@ class MidWiseTransformIterator { MidWiseTransformIterator& operator++() { ++j_; - i_ = j_ / post_; - if (UNLIKELY(i_ == n_)) { - j_ = 0; - i_ = 0; + if (UNLIKELY(j_ == post_)) { + ++i_; + if (UNLIKELY(i_ == n_)) { + j_ = 0; + i_ = 0; + } } return *this; }