Instances of DeviceId represent TensorFlow devices as integers. This helps avoid having to manipulate device names as strings when auto-clustering.
| 34 | // This helps avoid having to manipulate device names as strings when |
| 35 | // auto-clustering. |
| 36 | class DeviceId { |
| 37 | public: |
| 38 | DeviceId(DeviceId&&) = default; |
| 39 | DeviceId(const DeviceId&) = default; |
| 40 | DeviceId& operator=(const DeviceId&) = default; |
| 41 | |
| 42 | bool operator==(const DeviceId& other) const { return id() == other.id(); } |
| 43 | bool operator!=(const DeviceId& other) const { return !(*this == other); } |
| 44 | |
| 45 | private: |
| 46 | int id_; |
| 47 | |
| 48 | explicit DeviceId(int id) : id_(id) {} |
| 49 | |
| 50 | int id() const { return id_; } |
| 51 | |
| 52 | friend class DeviceInfoCache; |
| 53 | friend class DeviceSet; |
| 54 | }; |
| 55 | |
| 56 | // A set of DeviceIds, represented as a bitmap. |
| 57 | class DeviceSet { |