Fix Clang compile error

update-doc-pybind
fengjiayi 8 years ago
parent 13d00053d1
commit 0620b00eb6

@ -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 {
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}}));
} }
} }
} }

Loading…
Cancel
Save