From 730d95107dc42f296246146e1911bfa2fc794551 Mon Sep 17 00:00:00 2001 From: Dwayne Robinson Date: Thu, 20 Aug 2020 21:20:37 +0000 Subject: [PATCH] Merged PR 5065263: ONNX backend autopilot crash in WinML ToString running test_cast_BFLOAT16_to_FLOAT While attempting to throw an error and format an error message about an incompatible binding, WinML dies via FAIL_FAST_IF_MSG because the helper `ToString` function itself croaks :b. Instead, it should just say the data type is undefined. ``` StartGroup: Test:#62; Graph:test_cast_BFLOAT16_to_FLOAT; Executor:WinMLOperatorExecutor_Cpu; TAEF: A crash with exception code 0xC0000409 occurred in module "Windows.AI.MachineLearning.dll" in process "te.processhost.exe" (pid:15732). Error: TAEF: [HRESULT 0x800706BE] A failure occurred while running a test operation: 'OnnxConformanceTestsTaef::OnnxBackend'. (A crash with exception code 0xC0000409 occurred in module "Windows.AI.MachineLearning.dll" in the process hosting the test code while invoking a test operation.) ``` --- winml/lib/Api/impl/FeatureCompatibility.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/winml/lib/Api/impl/FeatureCompatibility.h b/winml/lib/Api/impl/FeatureCompatibility.h index 5338623a9e..2966f854b2 100644 --- a/winml/lib/Api/impl/FeatureCompatibility.h +++ b/winml/lib/Api/impl/FeatureCompatibility.h @@ -54,9 +54,10 @@ static std::string ToString(wfc::IVectorView shape) { static std::string ToString( winml::TensorKind kind, wfc::IVectorView shape) { - FAIL_FAST_IF_MSG(kind == winml::TensorKind::Complex128, "Unexpected TensorKind Complex128."); - FAIL_FAST_IF_MSG(kind == winml::TensorKind::Complex64, "Unexpected TensorKind Complex64."); - FAIL_FAST_IF_MSG(kind == winml::TensorKind::Undefined, "Unexpected TensorKind Undefined."); + // Any unrecognized data type is considered "Undefined". + if (static_cast(kind) >= std::size(SzTensorKind)) { + kind = winml::TensorKind::Undefined; + } std::ostringstream stream; stream << SzTensorKind[static_cast(kind)] << ToString(shape); @@ -73,9 +74,10 @@ static std::string ToString(winml::ITensor value) { static std::string ToString(winml::IMapFeatureDescriptor descriptor) { auto keyKind = descriptor.KeyKind(); - FAIL_FAST_IF_MSG(keyKind == winml::TensorKind::Complex128, "Unexpected TensorKind Complex128."); - FAIL_FAST_IF_MSG(keyKind == winml::TensorKind::Complex64, "Unexpected TensorKind Complex64."); - FAIL_FAST_IF_MSG(keyKind == winml::TensorKind::Undefined, "Unexpected TensorKind Undefined."); + // Any unrecognized data type is considered "Undefined". + if (static_cast(keyKind) >= std::size(SzTensorKind)) { + keyKind = winml::TensorKind::Undefined; + } auto valueDescriptor = descriptor.ValueDescriptor(); std::ostringstream stream; @@ -86,9 +88,10 @@ static std::string ToString(winml::IMapFeatureDescriptor descriptor) { static std::string ToString(winrt::com_ptr<_winml::IMapFeatureValue> value) { winml::TensorKind keyKind; FAIL_FAST_IF_FAILED(value->get_KeyKind(&keyKind)); - FAIL_FAST_IF_MSG(keyKind == winml::TensorKind::Complex128, "Unexpected TensorKind Complex128."); - FAIL_FAST_IF_MSG(keyKind == winml::TensorKind::Complex64, "Unexpected TensorKind Complex64."); - FAIL_FAST_IF_MSG(keyKind == winml::TensorKind::Undefined, "Unexpected TensorKind Undefined."); + // Any unrecognized data type is considered "Undefined". + if (static_cast(keyKind) >= std::size(SzTensorKind)) { + keyKind = winml::TensorKind::Undefined; + } winml::ILearningModelFeatureDescriptor valueDescriptor; FAIL_FAST_IF_FAILED(value->get_ValueDescriptor(&valueDescriptor));