Skip to content

Commit

Permalink
Merge pull request #3 from qingshui/paddlebox
Browse files Browse the repository at this point in the history
1. fix nncross expand_embedx size bug
  • Loading branch information
qingshui committed May 13, 2021
2 parents 01bf0c2 + 878ad7b commit cb4453c
Show file tree
Hide file tree
Showing 4 changed files with 264 additions and 314 deletions.
23 changes: 14 additions & 9 deletions paddle/fluid/framework/boxps_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,9 @@ void BoxPSWorker::CreateDeviceResource(const ProgramDesc& main_prog) {
}

int64_t pad_len = 0;
AllocParamTensor(&pad_len);

if (sync_mode_ > 0) {
AllocParamTensor(&pad_len);
}
auto& block = program_->Block(0);
thread_scope_ = &(root_scope_->NewScope());

Expand All @@ -338,18 +339,22 @@ void BoxPSWorker::CreateDeviceResource(const ProgramDesc& main_prog) {
const LoDTensor& root_tensor =
root_scope_->FindVar(name)->Get<LoDTensor>();
LoDTensor* gpu_tensor = thread_scope_->Var(name)->GetMutable<LoDTensor>();
if (CheckNeedParam(var)) {
auto dim = root_tensor.dims();
size_t len = root_tensor.numel();
gpu_tensor->ShareDataWith(param_sync_.Slice(offset, offset + len))
.Resize(dim);
offset += len;
if (sync_mode_ > 0) {
if (CheckNeedParam(var)) {
auto dim = root_tensor.dims();
size_t len = root_tensor.numel();
gpu_tensor->ShareDataWith(param_sync_.Slice(offset, offset + len))
.Resize(dim);
offset += len;
}
}
TensorCopy(*static_cast<const Tensor*>(&root_tensor), place_,
static_cast<Tensor*>(gpu_tensor));
}
}
CHECK(offset <= (param_sync_.numel() - pad_len));
if (sync_mode_ > 0) {
CHECK(offset <= (param_sync_.numel() - pad_len));
}
}
void BoxPSWorker::SyncParam(void) {
if (sync_mode_ == DenseKStepNode && node_size_ == 1) {
Expand Down

0 comments on commit cb4453c

Please sign in to comment.