diff --git a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/OperatorRegistration.cpp b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/OperatorRegistration.cpp index e6c9f2fea1..10ab559560 100644 --- a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/OperatorRegistration.cpp +++ b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/OperatorRegistration.cpp @@ -301,7 +301,7 @@ constexpr static std::array supportedTypeListLogica constexpr static std::array supportedTypeListLogicalComparison9 = /* A&B,C */ { SupportedTensorDataTypes::Float16to32|SupportedTensorDataTypes::Ints8to64, SupportedTensorDataTypes::Bool }; constexpr static std::array supportedTypeListSigned = { SupportedTensorDataTypes::Float16to32 | SupportedTensorDataTypes::Int64 | SupportedTensorDataTypes::Int32 | SupportedTensorDataTypes::Int16 | SupportedTensorDataTypes::Int8 }; constexpr static std::array supportedTypeListRange = {SupportedTensorDataTypes::Int16|SupportedTensorDataTypes::Int32|SupportedTensorDataTypes::Int64|SupportedTensorDataTypes::Float32}; -constexpr static std::array supportedTypeListResize11 = {SupportedTensorDataTypes::Float16to32, SupportedTensorDataTypes::Float32 /* float32 ROI read by CPU */}; +constexpr static std::array supportedTypeListResize11 = {SupportedTensorDataTypes::Float16to32, SupportedTensorDataTypes::Float16to32 /* float32 ROI read by CPU */}; constexpr static std::array supportedTypeListInteger = {SupportedTensorDataTypes::Int8|SupportedTensorDataTypes::UInt8, SupportedTensorDataTypes::Int8|SupportedTensorDataTypes::UInt8, SupportedTensorDataTypes::Int32 }; constexpr static std::array supportedTypeListInteger8 = {SupportedTensorDataTypes::Int8|SupportedTensorDataTypes::UInt8 }; constexpr static std::array supportedTypeListRoiAlign = {SupportedTensorDataTypes::Float16to32, SupportedTensorDataTypes::Int32|SupportedTensorDataTypes::Int64 }; diff --git a/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.cpp b/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.cpp index 72c956356a..bb501f4cd9 100644 --- a/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.cpp +++ b/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.cpp @@ -86,16 +86,59 @@ namespace OperatorHelper const std::vector& tensorDimensions = tensor.GetShape(); const uint32_t elementCount = ComputeElementCountFromDimensions(tensorDimensions); + result.resize(elementCount); switch (tensor.GetTensorDataType()) { - case MLOperatorTensorDataType::Float: + case MLOperatorTensorDataType::Float16: + { + const onnxruntime::MLFloat16* data = tensor.GetData(); + std::transform(result.begin(), result.end(), result.begin(), [](auto v) {return static_cast(v); }); + } + break; + + case MLOperatorTensorDataType::/*Float32*/Float: { const float* data = tensor.GetData(); result.assign(data, data + elementCount); } break; + case MLOperatorTensorDataType::/*Float64*/Double: + { + const double* data = tensor.GetData(); + std::transform(result.begin(), result.end(), result.begin(), [](auto v) {return static_cast(v); }); + } + break; + + case MLOperatorTensorDataType::Int32: + { + const int32_t* data = tensor.GetData(); + std::transform(result.begin(), result.end(), result.begin(), [](auto v) {return static_cast(v); }); + } + break; + + case MLOperatorTensorDataType::UInt32: + { + const uint32_t* data = tensor.GetData(); + std::transform(result.begin(), result.end(), result.begin(), [](auto v) {return static_cast(v); }); + } + break; + + case MLOperatorTensorDataType::Int64: + { + const int64_t* data = tensor.GetData(); + std::transform(result.begin(), result.end(), result.begin(), [](auto v) {return static_cast(v); }); + } + break; + + case MLOperatorTensorDataType::UInt64: + { + const uint64_t* data = tensor.GetData(); + std::transform(result.begin(), result.end(), result.begin(), [](auto v) {return static_cast(v); }); + } + break; + default: ML_INVALID_ARGUMENT("Expecting CPU local tensor of type float32."); break; @@ -1110,7 +1153,7 @@ namespace OperatorHelper uint32_t labelIndex = labelIndices[j]; assert(labelIndex < labelSizes.size()); - if (labelSizes[labelIndex] == INT_MIN) + if (labelSizes[labelIndex] == static_cast(INT_MIN)) { labelSizes[labelIndex] = dimensionSize; } diff --git a/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.h b/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.h index f6cb59a324..66c72ecaca 100644 --- a/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.h +++ b/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.h @@ -6,7 +6,7 @@ #include "Common.h" #include "Attributes.h" #include "core/common/common.h" -#include "..\DmlExecutionProvider\src\ErrorHandling.h" +#include "../DmlExecutionProvider/src/ErrorHandling.h" #include "MLOperatorAuthorHelper.h" namespace OperatorHelper {