Windows 机器学习实现使用各种检查来确定特定 GPU 是否支持 Float16。
看看这里的实现:
https ://github.com/microsoft/onnxruntime/blob/bfa996b5fa1ce87d2501abd8371ec5612d288cac/winml/lib/Common/CommonDeviceHelpers.cpp#L140
它包含一个阻止列表的组合:
bool CheckAdapterFP16Blocked(bool isMcdmAdapter, uint32_t vendorId, uint32_t majorVersion, uint32_t minorVersion) {
switch (vendorId) {
case c_intelVendorId: {
if (isMcdmAdapter) {
return false;
}
// Check Intel GPU driver version
return (majorVersion < 25) || (majorVersion == 25 && minorVersion < 6574) || (majorVersion == 26 && minorVersion < 6572);
}
}
return false;
}
以及对 DML 设备的查询以指示底层硬件是否支持 float16。
winrt::com_ptr<IDMLDevice> dmlDevice;
winrt::check_hresult(DMLCreateDevice(
device,
DML_CREATE_DEVICE_FLAG_NONE,
IID_PPV_ARGS(dmlDevice.put())));
DML_FEATURE_QUERY_TENSOR_DATA_TYPE_SUPPORT float16Query = {DML_TENSOR_DATA_TYPE_FLOAT16};
DML_FEATURE_DATA_TENSOR_DATA_TYPE_SUPPORT float16Data = {};
winrt::check_hresult(dmlDevice->CheckFeatureSupport(
DML_FEATURE_TENSOR_DATA_TYPE_SUPPORT,
sizeof(float16Query),
&float16Query,
sizeof(float16Data),
&float16Data));
return float16Data.IsSupported;