Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix copy bug #7159

Merged
merged 7 commits into from
Dec 31, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions oneflow/user/ops/copy_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ namespace {
Maybe<Symbol<Device>> MakeOpDevice(const Symbol<Device>& in_device,
const Symbol<Device>& out_device) {
if (JUST(in_device->of_type()) == "gpu" && JUST(out_device->of_type()) == "cpu") {
return Device::New("cuda_d2h");
return Device::New("cuda_d2h", in_device->device_id());
} else if (JUST(in_device->of_type()) == "cpu" && JUST(out_device->of_type()) == "gpu") {
return Device::New("cuda_h2d");
return Device::New("cuda_h2d", out_device->device_id());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是修复了copy op实现上的一个bug:在new Device时如果不带上输出的device id,会走到

/* static */ Maybe<Symbol<Device>> Device::New(const std::string& type) {
  return New(type, GlobalProcessCtx::LocalRank());
}

仅通过type构造的Device,其device id默认为本进程所在rank,而不是to.("cuda:x")的目标device x

} else {
return Device::New(out_device->type(), out_device->device_id());
}
Expand Down