Skip to content

Commit

Permalink
Put stream checking out of callback
Browse files Browse the repository at this point in the history
  • Loading branch information
buptzyb committed Aug 24, 2023
1 parent ccae79b commit 332e1fe
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tensorflow/core/common_runtime/gpu/gpu_util.cc
Expand Up @@ -397,7 +397,12 @@ void GPUUtil::CopyCPUTensorToGPU(const Tensor* cpu_tensor,
}
}

if (merge_host_to_device_stream) done(OkStatus());
if (merge_host_to_device_stream) {
if (!recv_host_to_device_stream->ok()) {
LOG(FATAL) << "CPU->GPU Memcpy failed";
}
done(OkStatus());
}
dev_info->event_mgr->ThenExecute(
recv_host_to_device_stream,
[recv_host_to_device_stream, done, input_ref, do_staging, staging_buffer,
Expand All @@ -407,10 +412,12 @@ void GPUUtil::CopyCPUTensorToGPU(const Tensor* cpu_tensor,
} else {
input_ref.Unref();
}
if (!recv_host_to_device_stream->ok()) {
LOG(FATAL) << "CPU->GPU Memcpy failed";
if (!merge_host_to_device_stream) {
if (!recv_host_to_device_stream->ok()) {
LOG(FATAL) << "CPU->GPU Memcpy failed";
}
done(OkStatus());
}
if (!merge_host_to_device_stream) done(OkStatus());
});
}

Expand Down

0 comments on commit 332e1fe

Please sign in to comment.