提交 0620b00e 编写于 作者: F fengjiayi

Fix Clang compile error

上级 13d00053
...@@ -56,7 +56,7 @@ class CosSimKernel : public framework::OpKernel { ...@@ -56,7 +56,7 @@ class CosSimKernel : public framework::OpKernel {
x_norm.device(place) = x.square().sum(row_along).sqrt(); x_norm.device(place) = x.square().sum(row_along).sqrt();
y_norm.device(place) = y.square().sum(row_along).sqrt(); y_norm.device(place) = y.square().sum(row_along).sqrt();
if (rows_x == rows_y) { if (rows_x == rows_y) {
auto xy = (x * y).sum(Eigen::array<int, 1>({1})); auto xy = (x * y).sum(Eigen::array<int, 1>({{1}}));
z.device(place) = xy / x_norm / y_norm; z.device(place) = xy / x_norm / y_norm;
} else { } else {
Eigen::DSizes<int, 2> bcast(rows_x, 1); Eigen::DSizes<int, 2> bcast(rows_x, 1);
...@@ -134,7 +134,7 @@ class CosSimGradKernel : public framework::OpKernel { ...@@ -134,7 +134,7 @@ class CosSimGradKernel : public framework::OpKernel {
out_grad_y->mutable_data<T>(context.GetPlace()); out_grad_y->mutable_data<T>(context.GetPlace());
auto dy = EigenMatrix<T>::Reshape(*out_grad_y, 1); auto dy = EigenMatrix<T>::Reshape(*out_grad_y, 1);
auto grad = x / norm_prod_bcast - z_bcast * y_bcast / y_snorm_bcast; auto grad = x / norm_prod_bcast - z_bcast * y_bcast / y_snorm_bcast;
dy.device(place) = (dz_bcast * grad).sum(Eigen::array<int, 1>({0})); dy.device(place) = (dz_bcast * grad).sum(Eigen::array<int, 1>({{0}}));
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册