diff --git a/onnxruntime/core/providers/cuda/cudnn_common.cc b/onnxruntime/core/providers/cuda/cudnn_common.cc index 135b61999c..de8669cc6b 100644 --- a/onnxruntime/core/providers/cuda/cudnn_common.cc +++ b/onnxruntime/core/providers/cuda/cudnn_common.cc @@ -47,18 +47,6 @@ Status CudnnTensor::Set(const CudnnTensor& x_desc, cudnnBatchNormMode_t mode) { return Status::OK(); } -template -cudnnDataType_t CudnnTensor::GetDataType() { - if (typeid(ElemType) == typeid(float)) - return CUDNN_DATA_FLOAT; - else if (typeid(ElemType) == typeid(double)) - return CUDNN_DATA_DOUBLE; - else if (typeid(ElemType) == typeid(half)) - return CUDNN_DATA_HALF; - else - ORT_THROW("cuDNN engine currently supports only single/double/half precision data types."); -} - CudnnDataTensor::CudnnDataTensor() : tensor_(nullptr) { } @@ -124,9 +112,38 @@ Status CudnnFilterDescriptor::Set(const std::vector& filter_dims, cudnn return Status::OK(); } -template cudnnDataType_t CudnnTensor::GetDataType(); -template cudnnDataType_t CudnnTensor::GetDataType(); -template cudnnDataType_t CudnnTensor::GetDataType(); +template +cudnnDataType_t CudnnTensor::GetDataType() { + ORT_THROW("cuDNN engine currently supports only single/double/half/int8/uint8 precision data types. Got:", + typeid(ElemType).name()); + // Not reachable but GCC complains + return 0; +} + +template <> +cudnnDataType_t CudnnTensor::GetDataType() { + return CUDNN_DATA_FLOAT; +} + +template <> +cudnnDataType_t CudnnTensor::GetDataType() { + return CUDNN_DATA_DOUBLE; +} + +template <> +cudnnDataType_t CudnnTensor::GetDataType() { + return CUDNN_DATA_HALF; +} + +template <> +cudnnDataType_t CudnnTensor::GetDataType() { + return CUDNN_DATA_INT8; +} + +template <> +cudnnDataType_t CudnnTensor::GetDataType() { + return CUDNN_DATA_UINT8; +} template <> const float Consts::One = 1; @@ -144,5 +161,20 @@ const float Consts::Zero = 0; const float Consts::One = 1; +template <> +const int8_t Consts::Zero = 0; + +template <> +const int8_t Consts::One = 1; + +template <> +const uint8_t Consts::Zero = 0; + +template <> +const uint8_t Consts::One = 1; + +std::vector DeviceProp::s_cachedDeviceProps; +std::once_flag DeviceProp::s_cachedDevicePropsInitFlag; + } // namespace cuda } // namespace onnxruntime