Skip to content

Commit

Permalink
[CustomDevice] remove get_device in device_guard (PaddlePaddle#57994)
Browse files Browse the repository at this point in the history
  • Loading branch information
ronny1996 authored and Frida-a committed Oct 14, 2023
1 parent ed13c42 commit fd2fd74
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions paddle/phi/backends/device_guard.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,15 @@ namespace phi {
class DeviceGuard {
public:
explicit inline DeviceGuard(const Place& place)
: dev_type_(place.GetDeviceType()) {
prev_id = DeviceManager::GetDevice(dev_type_);
cur_id = place.GetDeviceId();

if (cur_id != prev_id) {
DeviceManager::SetDevice(dev_type_, cur_id);
}
: cur_id(place.GetDeviceId()), dev_type_(place.GetDeviceType()) {
DeviceManager::SetDevice(dev_type_, cur_id);
}

DeviceGuard(const DeviceGuard& o) = delete;
DeviceGuard& operator=(const DeviceGuard& o) = delete;

private:
size_t prev_id, cur_id;
size_t cur_id;
std::string dev_type_;
};

Expand Down

0 comments on commit fd2fd74

Please sign in to comment.