提交 8711a9a2 编写于 作者: C chengduoZH

refine code

上级 a0c1190f
......@@ -21,7 +21,7 @@ namespace operators {
template <typename T>
struct AddFunctor {
HOSTDEVICE T operator()(T a, T b) const { return a + b; }
inline HOSTDEVICE T operator()(T a, T b) const { return a + b; }
};
template <typename Place, typename T>
......
......@@ -71,7 +71,9 @@ class RowwiseTransformIterator<T, platform::CPUPlace> {
RowwiseTransformIterator<T, platform::CPUPlace>& operator++() {
++i_;
i_ %= n_;
if (UNLIKELY(i_ == n_)) {
i_ = 0;
}
return *this;
}
......@@ -100,7 +102,12 @@ class MidWiseTransformIterator<T, platform::CPUPlace> {
: ptr_(ptr), i_(0), j_(0), n_(n), post_(post) {}
MidWiseTransformIterator<T, platform::CPUPlace>& operator++() {
i_ = (++j_ / post_) % n_;
++j_;
i_ = j_ / post_;
if (UNLIKELY(i_ == n_)) {
j_ = 0;
i_ = 0;
}
return *this;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册