未验证 提交 b30e8bc0 编写于 作者: C chengduo 提交者: GitHub

Merge pull request #6324 from chengduoZH/profiling/refine_elementwise_add

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