onnxruntime/winml/test/model/ort_value_helper.h
Ryan Lai f207f0bf5e
Add WinML Model testing (#5417)
* Model test start with float

* Clean up code and add environment variable detection

* Move into namespace

* PR comments

* Fix linker errors in latest merge to master and also fix warning

* add skipping model test mechanism

* Return std::string instead of writing to buffer

* Address case where env variable is larger than max_path

* use const static string for test reason

* Disable x86 tests and don't build if ort memory checker is enabled

* Add comment

* Add additional failing x86 tests and ifdef for checking fo rx86 build

* PR comments
2020-10-15 19:04:12 -07:00

82 lines
No EOL
2.7 KiB
C++

#include "testPch.h"
#include "onnxruntime_cxx_api.h"
namespace OrtValueHelpers {
winml::ITensor LoadTensorFromOrtValue(Ort::Value& val);
}
template <ONNXTensorElementDataType T>
struct ONNXTensorElementDataTypeToWinMLTensorKind {
// Invalid ONNXTensorElementDataType to TensorKind
static_assert(sizeof(T) == -1, "No WinML TensorKind mapped for given ONNX Tensor Element type!");
};
template <>
struct ONNXTensorElementDataTypeToWinMLTensorKind<ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT> {
typedef winml::TensorFloat Type;
};
template <>
struct ONNXTensorElementDataTypeToWinMLTensorKind<ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8> {
typedef winml::TensorUInt8Bit Type;
};
template <>
struct ONNXTensorElementDataTypeToWinMLTensorKind<ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8> {
typedef winml::TensorInt8Bit Type;
};
template <>
struct ONNXTensorElementDataTypeToWinMLTensorKind<ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT16> {
typedef winml::TensorUInt16Bit Type;
};
template <>
struct ONNXTensorElementDataTypeToWinMLTensorKind<ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16> {
typedef winml::TensorInt16Bit Type;
};
template <>
struct ONNXTensorElementDataTypeToWinMLTensorKind<ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32> {
typedef winml::TensorInt32Bit Type;
};
template <>
struct ONNXTensorElementDataTypeToWinMLTensorKind<ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64> {
typedef winml::TensorInt64Bit Type;
};
template <>
struct ONNXTensorElementDataTypeToWinMLTensorKind<ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING> {
typedef winml::TensorString Type;
};
template <>
struct ONNXTensorElementDataTypeToWinMLTensorKind<ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_BOOL> {
typedef winml::TensorBoolean Type;
};
template <>
struct ONNXTensorElementDataTypeToWinMLTensorKind<ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16> {
typedef winml::TensorFloat16Bit Type;
};
template <>
struct ONNXTensorElementDataTypeToWinMLTensorKind<ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE> {
typedef winml::TensorDouble Type;
};
template <>
struct ONNXTensorElementDataTypeToWinMLTensorKind<ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT32> {
typedef winml::TensorUInt32Bit Type;
};
template <>
struct ONNXTensorElementDataTypeToWinMLTensorKind<ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT64> {
typedef winml::TensorUInt64Bit Type;
};
template <>
struct ONNXTensorElementDataTypeToWinMLTensorKind<ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_BFLOAT16> {
typedef winml::TensorFloat16Bit Type;
};