diff --git a/paddle/fluid/framework/fleet/heter_ps/heter_comm_inl.h b/paddle/fluid/framework/fleet/heter_ps/heter_comm_inl.h index 51432e9de81fb42366838701d2df6b9c61f7f7ef..7ebf7660ee521a8ce53427ad85c375ed8efd7014 100644 --- a/paddle/fluid/framework/fleet/heter_ps/heter_comm_inl.h +++ b/paddle/fluid/framework/fleet/heter_ps/heter_comm_inl.h @@ -584,7 +584,7 @@ void HeterComm::pull_sparse(int num, for (int i = 0; i < total_device; ++i) { int shard_len = h_right[i] - h_left[i] + 1; - if (shard_len == 0) { + if (h_left[i] == -1 || h_right[i] == -1) { continue; } create_storage(num, i, shard_len * sizeof(KeyType), @@ -630,6 +630,9 @@ void HeterComm::pull_sparse(int num, sync_stream(stream); for (int i = 0; i < total_device; ++i) { + if (h_left[i] == -1 || h_right[i] == -1) { + continue; + } destroy_storage(num, i); } } @@ -747,6 +750,9 @@ void HeterComm::push_sparse(int dev_num, } for (int i = 0; i < total_device; ++i) { + if (h_left[i] == -1 || h_right[i] == -1) { + continue; + } destroy_storage(dev_num, i); } } @@ -862,6 +868,9 @@ void HeterComm::push_sparse(int dev_num, } for (int i = 0; i < total_device; ++i) { + if (h_left[i] == -1 || h_right[i] == -1) { + continue; + } destroy_storage(dev_num, i); } }