mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
Fix bit math (#46837)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/46837 Formerly `static_cast<StreamId>(bits)` and `static_cast<DeviceIndex>(bits)` were and-ed against `ull` types resulting in an integer promotion which later raised a warning in downcasting passes to `Stream` and `Device`. Moving the `&` operation inside the cast results in two `uint64_t` being operated on and then cast to the correct type, eliminating the warning. Test Plan: Standard pre-commit test rig. Reviewed By: malfet Differential Revision: D24481292 fbshipit-source-id: a8bcbde631054c26ca8c98fbed275254dd359dd0
This commit is contained in:
parent
c9222b7471
commit
c3fc17b48e
1 changed files with 3 additions and 3 deletions
|
|
@ -124,11 +124,11 @@ public:
|
|||
}
|
||||
|
||||
static Stream unpack(uint64_t bits) {
|
||||
auto stream_id = static_cast<StreamId>(bits) & 0xFFFFFFFFull;
|
||||
const auto stream_id = static_cast<StreamId>(bits & 0xFFFFFFFFull);
|
||||
bits >>= 32;
|
||||
auto device_index = static_cast<DeviceIndex>(bits) & 0xFFFFull;
|
||||
const auto device_index = static_cast<DeviceIndex>(bits & 0xFFFFull);
|
||||
bits >>= 16;
|
||||
auto device_type = static_cast<DeviceType>(bits);
|
||||
const auto device_type = static_cast<DeviceType>(bits);
|
||||
TORCH_CHECK(isValidDeviceType(device_type));
|
||||
// Unfortunately, we can't check if the StreamId is valid here; it
|
||||
// will be checked upon first use.
|
||||
|
|
|
|||
Loading…
Reference in a new issue