diff --git a/mindspore/ccsrc/kernel/gpu/arrays/array_reduce_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/arrays/array_reduce_gpu_kernel.h index 224a3da8ad00abddd5a36556e5da6d8b02710e2c..e1f995d648bb1223556404074a772d0e80dd77e3 100644 --- a/mindspore/ccsrc/kernel/gpu/arrays/array_reduce_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/arrays/array_reduce_gpu_kernel.h @@ -81,7 +81,7 @@ class ArrayReduceGpuKernel : public GpuKernel { } bool Init(const CNodePtr &kernel_node) override { InitResource(); - data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node); if (input_num != 1) { MS_LOG(ERROR) << "Input number is " << input_num << ", but reduce op needs 1 inputs."; diff --git a/mindspore/ccsrc/kernel/gpu/gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/gpu_kernel.h index 9f8090451f52f706baa0f0ab8c811191ca8d95fe..e8b621aed6437a47caaf37a260b293e91597345e 100644 --- a/mindspore/ccsrc/kernel/gpu/gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/gpu_kernel.h @@ -22,6 +22,7 @@ #include #include #include "kernel/kernel.h" +#include "kernel/gpu/kernel_constants.h" #include "device/gpu/gpu_device_manager.h" #include "device/gpu/gpu_common.h" #include "session/anf_runtime_algorithm.h" @@ -79,6 +80,22 @@ class GpuKernel : public KernelMod { "must match the corresponding dimension of outC or must be equal to 1."; } } + + // choose the suitable datatype for cudnn/cublas + inline cudnnDataType_t GetCudnnDataType(const std::string &Type) { + auto type = kCudnnDtypeMap.find(Type); + if (type == kCudnnDtypeMap.end()) { + MS_EXCEPTION(TypeError) << Type << " is not supported."; + } + return type->second; + } + inline cudaDataType_t GetCudaDataType(const std::string &Type) { + auto type = kCudaDtypeMap.find(Type); + if (type == kCudaDtypeMap.end()) { + MS_EXCEPTION(TypeError) << Type << " is not supported."; + } + return type->second; + } }; } // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/kernel/gpu/math/addn_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/math/addn_gpu_kernel.h index 0b276027613adb364d095cae044e7aa750505c69..1498da777f78ec27225cdaf825245172e84f1ebf 100644 --- a/mindspore/ccsrc/kernel/gpu/math/addn_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/math/addn_gpu_kernel.h @@ -60,7 +60,7 @@ class AddNGpuFwdKernel : public GpuKernel { } bool Init(const CNodePtr &kernel_node) override { InitResource(); - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node); num_input_ = GetAttr(kernel_node, "n"); if (IntToSize(num_input_) != input_num) { diff --git a/mindspore/ccsrc/kernel/gpu/math/bias_add_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/math/bias_add_gpu_kernel.h index 5d197e3cde7fc9ddb15c6978b71396590e1211b9..5a664db2e18dbc2b381bab31c22cd18ce2083901 100644 --- a/mindspore/ccsrc/kernel/gpu/math/bias_add_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/math/bias_add_gpu_kernel.h @@ -67,7 +67,7 @@ class BiasAddGpuKernel : public GpuKernel { } bool Init(const CNodePtr &kernel_node) override { InitResource(); - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); auto x_shape = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0); auto num_dims = x_shape.size(); is_null_input_ = CHECK_NULL_INPUT(x_shape); diff --git a/mindspore/ccsrc/kernel/gpu/math/matmul_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/math/matmul_gpu_kernel.h index 59153c704178836b25fb7c02239c0a8c8a454fb3..3ee3493ed65b97405a2992c5005c0edc31b4aac3 100644 --- a/mindspore/ccsrc/kernel/gpu/math/matmul_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/math/matmul_gpu_kernel.h @@ -82,9 +82,9 @@ class MatMulGpuKernel : public GpuKernel { } bool Init(const CNodePtr &kernel_node) override { handle_ = device::gpu::GPUDeviceManager::GetInstance().GetCublasHandle(); - dtype_a_ = kCudaDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; - dtype_b_ = kCudaDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 1))]; - dtype_c_ = kCudaDtypeMap[TypeIdLabel(AnfAlgo::GetOutputDeviceDataType(kernel_node, 0))]; + dtype_a_ = GetCudaDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); + dtype_b_ = GetCudaDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 1))); + dtype_c_ = GetCudaDataType(TypeIdLabel(AnfAlgo::GetOutputDeviceDataType(kernel_node, 0))); auto output_shape = AnfAlgo::GetOutputInferShape(kernel_node, 0); is_null_input_ = CHECK_NULL_INPUT(output_shape); if (is_null_input_) { diff --git a/mindspore/ccsrc/kernel/gpu/nn/bias_add_grad_gpu_kenel.h b/mindspore/ccsrc/kernel/gpu/nn/bias_add_grad_gpu_kenel.h index c93a0506495ce2ab68754503a5c1312d303e6b53..9b4f18d24c75a8f819fc0a51f8745f7bb1f8e68e 100644 --- a/mindspore/ccsrc/kernel/gpu/nn/bias_add_grad_gpu_kenel.h +++ b/mindspore/ccsrc/kernel/gpu/nn/bias_add_grad_gpu_kenel.h @@ -68,7 +68,7 @@ class BiasAddGradGpuKernel : public GpuKernel { } bool Init(const CNodePtr &kernel_node) override { InitResource(); - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); auto dy_shape = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0); auto num_dims = dy_shape.size(); if (num_dims < 2) { diff --git a/mindspore/ccsrc/kernel/gpu/nn/conv2d_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/nn/conv2d_gpu_kernel.h index 7bb6aa2a6d2d19215c854aeb9782bf127f741d1f..f51cbfef337b29fab0c72f569e38d72d73e1c9c3 100644 --- a/mindspore/ccsrc/kernel/gpu/nn/conv2d_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/nn/conv2d_gpu_kernel.h @@ -191,7 +191,7 @@ class Conv2dGpuFwdKernel : public GpuKernel { CHECK_CUDNN_RET_WITH_ERROR(cudnnDestroyTensorDescriptor(input_desc_), "cudnnDestroyTensorDescriptor failed"); } bool CheckParam(const CNodePtr &kernel_node) { - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node); if (input_num != 2) { MS_LOG(ERROR) << "Input number is " << input_num << ", but conv2d needs 2 inputs."; diff --git a/mindspore/ccsrc/kernel/gpu/nn/conv2d_grad_filter_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/nn/conv2d_grad_filter_gpu_kernel.h index b126b542dd2f15b3e8c89e6d80f0b3e6881a4762..0d7be25772adb007de42cba52ebd74b7c034d3b7 100644 --- a/mindspore/ccsrc/kernel/gpu/nn/conv2d_grad_filter_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/nn/conv2d_grad_filter_gpu_kernel.h @@ -98,7 +98,7 @@ class ConvGradFilterGpuBkwKernel : public GpuKernel { if (!CheckParam(kernel_node)) { return false; } - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); auto dy_shape = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0); auto in_shape = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 1); is_null_input_ = CHECK_NULL_INPUT(dy_shape) || CHECK_NULL_INPUT(in_shape); diff --git a/mindspore/ccsrc/kernel/gpu/nn/conv2d_grad_input_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/nn/conv2d_grad_input_gpu_kernel.h index f7f371067ff7abb3ca335538d934836e63c98020..a33ea5b4da458bd52e2d05ac411113870ce6d45e 100644 --- a/mindspore/ccsrc/kernel/gpu/nn/conv2d_grad_input_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/nn/conv2d_grad_input_gpu_kernel.h @@ -98,7 +98,7 @@ class ConvGradInputGpuBkwKernel : public GpuKernel { if (!CheckParam(kernel_node)) { return false; } - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); auto dy_shape = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0); auto filter_shape = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 1); is_null_input_ = CHECK_NULL_INPUT(dy_shape); diff --git a/mindspore/ccsrc/kernel/gpu/nn/fused_batch_norm_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/nn/fused_batch_norm_gpu_kernel.h index c08b341e78b1392fb01f0784914251ce67cbde0c..b0a898209be13847f0669d0479366e76e2b4953a 100644 --- a/mindspore/ccsrc/kernel/gpu/nn/fused_batch_norm_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/nn/fused_batch_norm_gpu_kernel.h @@ -82,7 +82,7 @@ class FusedBatchNormGpuKernel : public GpuKernel { } bool Init(const CNodePtr &kernel_node) override { InitResource(); - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node); if (input_num != 5) { MS_LOG(EXCEPTION) << "input tensor size is " << input_num << ", FusedBatchNormGpuKernel should be 5"; diff --git a/mindspore/ccsrc/kernel/gpu/nn/fused_batchnorm_grad_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/nn/fused_batchnorm_grad_gpu_kernel.h index 153b0286b34d6fd2667eab9863bd21f8a0117141..712354b17cb9d9bd8b92196fb32f05d952b8d8dc 100644 --- a/mindspore/ccsrc/kernel/gpu/nn/fused_batchnorm_grad_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/nn/fused_batchnorm_grad_gpu_kernel.h @@ -75,7 +75,7 @@ class FusedBatchNormGradGpuKernel : public GpuKernel { } bool Init(const CNodePtr &kernel_node) override { InitResource(); - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node); if (input_num != 5) { MS_LOG(EXCEPTION) << "input tensor size is " << input_num << ", FusedBatchNormGradGpuKernel should be 5"; diff --git a/mindspore/ccsrc/kernel/gpu/nn/lstm_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/nn/lstm_gpu_kernel.h index 01247f0ed6259a1fa8768c9826fe700048c54963..42eda96b02f7e81d77aa31c4e87b1ab0c6dbe17f 100644 --- a/mindspore/ccsrc/kernel/gpu/nn/lstm_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/nn/lstm_gpu_kernel.h @@ -89,7 +89,7 @@ class LstmGpuKernel : public GpuKernel { } bool Init(const CNodePtr &kernel_node) override { InitResource(); - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); auto input_shape = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0); seq_len_ = SizeToInt(input_shape[0]); batch_size_ = SizeToInt(input_shape[1]); diff --git a/mindspore/ccsrc/kernel/gpu/nn/lstm_grad_data_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/nn/lstm_grad_data_gpu_kernel.h index 5591b0c8174fbaaeca6d10b27acba061bfe8d4eb..6eeefa262c425c25101cf95ff88b8fef0f97d83b 100644 --- a/mindspore/ccsrc/kernel/gpu/nn/lstm_grad_data_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/nn/lstm_grad_data_gpu_kernel.h @@ -105,7 +105,7 @@ class LstmGradDataGpuKernel : public GpuKernel { } bool Init(const CNodePtr &kernel_node) override { InitResource(); - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); auto input_shape = AnfAlgo::GetOutputInferShape(kernel_node, 0); seq_len_ = SizeToInt(input_shape[0]); batch_size_ = SizeToInt(input_shape[1]); diff --git a/mindspore/ccsrc/kernel/gpu/nn/lstm_grad_weight_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/nn/lstm_grad_weight_gpu_kernel.h index dd6aae9a00c7cc839f53850dbef38c9896574b62..a1a4852c842a8ab8a715d44cea903563831b2ba4 100644 --- a/mindspore/ccsrc/kernel/gpu/nn/lstm_grad_weight_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/nn/lstm_grad_weight_gpu_kernel.h @@ -84,7 +84,7 @@ class LstmGradWeightGpuKernel : public GpuKernel { } bool Init(const CNodePtr &kernel_node) override { InitResource(); - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); auto input_shape = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0); seq_len_ = SizeToInt(input_shape[0]); batch_size_ = SizeToInt(input_shape[1]); diff --git a/mindspore/ccsrc/kernel/gpu/nn/pooling_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/nn/pooling_gpu_kernel.h index faff4537756ab39e3074dd4a00aefc5a32aeb4bc..0dda1e899805554ca2b55126668660f23806e5f1 100644 --- a/mindspore/ccsrc/kernel/gpu/nn/pooling_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/nn/pooling_gpu_kernel.h @@ -88,7 +88,7 @@ class PoolingGpuFwdKernel : public GpuKernel { if (!CheckParam(kernel_node)) { return false; } - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); auto input_shape = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0); is_null_input_ = CHECK_NULL_INPUT(input_shape); if (is_null_input_) { diff --git a/mindspore/ccsrc/kernel/gpu/nn/pooling_grad_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/nn/pooling_grad_gpu_kernel.h index df3454c5819aa38b2271eff6854757281f784d1e..030d2d073886bed5d85bdc671016ef32906c7c44 100644 --- a/mindspore/ccsrc/kernel/gpu/nn/pooling_grad_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/nn/pooling_grad_gpu_kernel.h @@ -239,7 +239,7 @@ class PoolingGradGpuFwdKernel : public GpuKernel { void SetPoolingMode(const CNodePtr &kernel_node) { pad_mode_ = GetAttr(kernel_node, "padding"); stride_ = GetAttr>(kernel_node, "strides"); - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); mode_ = AnfAlgo::GetCNodeName(kernel_node); if (mode_ == "AvgPoolGradGpu") { pooling_mode_ = CUDNN_POOLING_AVERAGE_COUNT_INCLUDE_PADDING; diff --git a/mindspore/ccsrc/kernel/gpu/nn/relu_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/nn/relu_gpu_kernel.h index 4cebc4583134bb7f9a40d59b8c95216fb19f4c53..bcc8819fde35deec8d95a3bb6578689737419357 100644 --- a/mindspore/ccsrc/kernel/gpu/nn/relu_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/nn/relu_gpu_kernel.h @@ -60,7 +60,7 @@ class ReLUGpuFwdKernel : public GpuKernel { } bool Init(const CNodePtr &kernel_node) override { InitResource(); - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node); if (input_num != 1) { MS_LOG(ERROR) << "Argument number is " << input_num << ", but ReLUGpuFwdKernel needs 1."; diff --git a/mindspore/ccsrc/kernel/gpu/nn/relu_grad_kernel.h b/mindspore/ccsrc/kernel/gpu/nn/relu_grad_kernel.h index ccc037f6e780dc2e00e4a614f9be1d81a898b84d..66e80011dca374198607ff91c2bd7d57605fafa7 100644 --- a/mindspore/ccsrc/kernel/gpu/nn/relu_grad_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/nn/relu_grad_kernel.h @@ -60,7 +60,7 @@ class ReluGradGpuFwdKernel : public GpuKernel { } bool Init(const CNodePtr &kernel_node) override { InitResource(); - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node); if (input_num != 2) { MS_LOG(ERROR) << "Argument number is " << input_num << ", but ReluGradGpuFwdKernel needs 2."; diff --git a/mindspore/ccsrc/kernel/gpu/nn/softmax_cross_entropy_with_logits_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/nn/softmax_cross_entropy_with_logits_gpu_kernel.h index 6840f0a1ebdcaec436ef342455b0318f0f973512..8256174bcbafaead46cd35161f9558f2c64cd82e 100644 --- a/mindspore/ccsrc/kernel/gpu/nn/softmax_cross_entropy_with_logits_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/nn/softmax_cross_entropy_with_logits_gpu_kernel.h @@ -87,7 +87,7 @@ class SoftmaxCrossEntropyWithLogitsGpuKernel : public GpuKernel { << ", but SoftmaxCrossEntropyWithLogitsGpuKernel needs 2 output."; return false; } - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); InferInputOutputSize(kernel_node); CHECK_CUDNN_RET_WITH_EXCEPT(cudnnSetTensor4dDescriptor(logits_descriptor_, CUDNN_TENSOR_NCHW, cudnn_data_type_, diff --git a/mindspore/ccsrc/kernel/gpu/nn/softmax_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/nn/softmax_gpu_kernel.h index 060bc57d56d2a6f87c8572651ba1817eb53e4280..9d5a2a24e141cce3e2d9d412aa523b4eb8ca69f7 100644 --- a/mindspore/ccsrc/kernel/gpu/nn/softmax_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/nn/softmax_gpu_kernel.h @@ -95,7 +95,7 @@ class SoftmaxGpuKernel : public GpuKernel { bool Init(const CNodePtr &kernel_node) override { InitResource(); - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node); if (input_num != 1) { MS_LOG(ERROR) << "Input number is " << input_num << ", but softmax needs 1 input."; diff --git a/mindspore/ccsrc/kernel/gpu/nn/softmax_grad_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/nn/softmax_grad_gpu_kernel.h index 003b55c0ed1bff726ae9d6616463dbed282250fc..d73503d5a59cd4e7636f59af8bee98524784008e 100644 --- a/mindspore/ccsrc/kernel/gpu/nn/softmax_grad_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/nn/softmax_grad_gpu_kernel.h @@ -98,7 +98,7 @@ class SoftmaxGradGpuKernel : public GpuKernel { bool Init(const CNodePtr &kernel_node) override { InitResource(); - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node); if (input_num != 2) { MS_LOG(ERROR) << "Input number is " << input_num << ", but softmax grad needs 2 input."; diff --git a/mindspore/ccsrc/kernel/gpu/nn/sparse_softmax_cross_entropy_with_logits_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/nn/sparse_softmax_cross_entropy_with_logits_gpu_kernel.h index 0749172cc680975c663a0fe40fea49a502888946..6950f0e3086cf26af3de3e53877c8755ded05e15 100644 --- a/mindspore/ccsrc/kernel/gpu/nn/sparse_softmax_cross_entropy_with_logits_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/nn/sparse_softmax_cross_entropy_with_logits_gpu_kernel.h @@ -89,7 +89,7 @@ class SparseSoftmaxCrossEntropyWithLogitsGpuKernel : public GpuKernel { return false; } is_grad_ = GetAttr(kernel_node, "is_grad"); - cudnn_data_type_ = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnn_data_type_ = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); InferInputOutputSize(kernel_node); CHECK_CUDNN_RET_WITH_EXCEPT(cudnnSetTensor4dDescriptor(logits_descriptor_, CUDNN_TENSOR_NCHW, cudnn_data_type_, diff --git a/mindspore/ccsrc/kernel/gpu/quant/batchnorm_fold_gpu_kernel.h b/mindspore/ccsrc/kernel/gpu/quant/batchnorm_fold_gpu_kernel.h index a90e9b47d79229a3c46e06c9f68a14b969a5dd74..c511eae549446b59a3c35e88233fda72d0bf4a3d 100644 --- a/mindspore/ccsrc/kernel/gpu/quant/batchnorm_fold_gpu_kernel.h +++ b/mindspore/ccsrc/kernel/gpu/quant/batchnorm_fold_gpu_kernel.h @@ -141,7 +141,7 @@ class BatchNormFoldGpuKernel : public GpuKernel { input_size_ = sizeof(T) * batch_ * channel_ * height_ * width_; output_size_ = sizeof(T) * channel_; - cudnnDataType_t cudnnDataType = kCudnnDtypeMap[TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))]; + cudnnDataType_t cudnnDataType = GetCudnnDataType(TypeIdLabel(AnfAlgo::GetInputDeviceDataType(kernel_node, 0))); CHECK_CUDNN_RET_WITH_EXCEPT( cudnnSetTensor4dDescriptor(x_desc_, CUDNN_TENSOR_NCHW, cudnnDataType, batch_, channel_, height_, width_), "Set x desc failed");