Skip to content

Commit

Permalink
move feature_buf into if-branch (PaddlePaddle#31)
Browse files Browse the repository at this point in the history
Co-authored-by: root <root@yq01-inf-hic-k8s-a100-ab2-0009.yq01.baidu.com>
  • Loading branch information
huwei02 and root authored Jun 14, 2022
1 parent 8e712f0 commit 0c33297
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions paddle/fluid/framework/data_feed.cu
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ int GraphDataGenerator::FillInsBuf() {
cudaMemcpyAsync(&h_pair_num, d_pair_num, sizeof(int), cudaMemcpyDeviceToHost,
stream_);

int64_t *feature_buf = reinterpret_cast<int64_t *>(d_feature_buf_->ptr());
if (!FLAGS_enable_opt_get_features && slot_num_ > 0) {
int64_t *feature_buf = reinterpret_cast<int64_t *>(d_feature_buf_->ptr());
int64_t *feature = reinterpret_cast<int64_t *>(d_feature_->ptr());
cudaMemsetAsync(d_pair_num, 0, sizeof(int), stream_);
int len = buf_state_.len;
Expand All @@ -355,11 +355,14 @@ int GraphDataGenerator::FillInsBuf() {
}
delete[] h_ins_buf;

int64_t h_feature_buf[(batch_size_ * 2 * 2) * slot_num_];
cudaMemcpy(h_feature_buf, feature_buf, (batch_size_ * 2 * 2) * slot_num_ * sizeof(int64_t),
cudaMemcpyDeviceToHost);
for (int xx = 0; xx < (batch_size_ * 2 * 2) * slot_num_; xx++) {
VLOG(2) << "h_feature_buf[" << xx << "]: " << h_feature_buf[xx];
if (!FLAGS_enable_opt_get_features && slot_num_ > 0) {
int64_t *feature_buf = reinterpret_cast<int64_t *>(d_feature_buf_->ptr());
int64_t h_feature_buf[(batch_size_ * 2 * 2) * slot_num_];
cudaMemcpy(h_feature_buf, feature_buf, (batch_size_ * 2 * 2) * slot_num_ * sizeof(int64_t),
cudaMemcpyDeviceToHost);
for (int xx = 0; xx < (batch_size_ * 2 * 2) * slot_num_; xx++) {
VLOG(2) << "h_feature_buf[" << xx << "]: " << h_feature_buf[xx];
}
}
}
return ins_buf_pair_len_;
Expand Down

0 comments on commit 0c33297

Please sign in to comment.