Skip to content

Commit 81e1457

Browse files
committed
refine code and comments, test=develop
1 parent 2f6b529 commit 81e1457

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

paddle/fluid/operators/hierarchical_sigmoid_op.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ template <typename T, int MajorType = Eigen::RowMajor,
3030
using EigenMatrix = framework::EigenMatrix<T, MajorType, IndexType>;
3131
using platform::Transform;
3232

33-
std::vector<int64_t> cal_rows(const framework::LoDTensor* path) {
33+
std::vector<int64_t> cal_rows(const framework::LoDTensor& path) {
3434
std::set<int64_t> tmp;
3535
std::vector<int64_t> rows;
3636
rows.clear();
37-
for (size_t i = 0; i < static_cast<size_t>(path->dims()[0]); i++) {
38-
for (size_t j = 0; j < static_cast<size_t>(path->dims()[1]); j++) {
37+
for (size_t i = 0; i < static_cast<size_t>(path.dims()[0]); i++) {
38+
for (size_t j = 0; j < static_cast<size_t>(path.dims()[1]); j++) {
3939
int64_t temp =
40-
path->data<int64_t>()[i * static_cast<size_t>(path->dims()[1]) + j];
40+
path.data<int64_t>()[i * static_cast<size_t>(path.dims()[1]) + j];
4141
if (temp >= 0) {
4242
tmp.insert(temp);
4343
}
@@ -188,7 +188,7 @@ class HierarchicalSigmoidGradOpKernel : public framework::OpKernel<T> {
188188
zero(dev_ctx, w_grad, static_cast<T>(0.0));
189189
bit_code->MulGradWeight(pre_out_grad, w_grad, *in);
190190
} else {
191-
framework::Vector<int64_t> real_rows = cal_rows(path);
191+
framework::Vector<int64_t> real_rows = cal_rows(*path);
192192
auto* w_grad =
193193
ctx.Output<framework::SelectedRows>(framework::GradVarName("W"));
194194
w_grad->set_rows(real_rows);

0 commit comments

Comments
 (0)