xla
4cec76f4 - Make `DeviceType` constructor not throw. (#9714)

Commit
104 days ago
Make `DeviceType` constructor not throw. (#9714) This PR refactors `DeviceType` so that it won't throw an exception in any case, e.g.: (a) when `XlaDeviceTypeToString` is called with `PLUGIN`; or (b) when `XlaDeviceTypeToString` is called with some unspecified value (i.e. arbitrary integer is cast to `XlaDeviceType`. **Key Changes:** - Create `kNativeXlaDeviceTypeNames` array for associating each `XlaDeviceType` with its name - For each element at position `i` in the array, `kNativeXlaDeviceTypeNames[i]` corresponds to the name of whatever `XlaDeviceType` integer representation is `i` (i.e. `static_cast<XlaDeviceType>(i)`) - Refactor `NativeXlaDeviceTypeToString` and `StringToXlaDeviceType` - Make them into simple static functions - Adapt them so as to use `kNativeXlaDeviceTypeNames` - Make `NativeXlaDeviceTypeToString` crash if a non-native (e.g. `PLUGIN`) `XlaDeviceType` is passed as argument
Author
Parents
Loading