未验证 提交 bc761058 编写于 作者: Z Zhang Ting 提交者: GitHub

use eval() to improve CPU performance (#25243)

上级 88e05c40
......@@ -82,7 +82,12 @@ class ClipByNormKernel : public framework::OpKernel<T> {
auto scaling = temp + (static_cast<T>(1) - temp) * max_norm / x_norm;
Eigen::array<int, 1> one_dim{{1}};
Eigen::DSizes<int, 1> m_dsize(input->numel());
out.device(place) = x * scaling.reshape(one_dim).broadcast(m_dsize);
if (context.GetPlace() == platform::CPUPlace()) {
out.device(place) =
x * scaling.reshape(one_dim).eval().broadcast(m_dsize);
} else {
out.device(place) = x * scaling.reshape(one_dim).broadcast(m_dsize);
}
}
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册