Skip to content

Commit

Permalink
Merge pull request #697 from emankov/HIPIFY
Browse files Browse the repository at this point in the history
[HIPIFY][#584][DNN][MIOpen] cuDNN -> MIOpen - Part 5
  • Loading branch information
emankov authored Nov 20, 2022
2 parents 2a1fb8c + efbac47 commit a92fecf
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/CUDA2HIP_DNN_API_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ const std::map<llvm::StringRef, hipCounter> CUDA_DNN_FUNCTION_MAP {
{"cudnnOpsTrainVersionCheck", {"hipdnnOpsTrainVersionCheck", "", CONV_LIB_FUNC, API_DNN, 2, HIP_UNSUPPORTED}},

// cuDNN Tensor functions
{"cudnnCreateTensorDescriptor", {"hipdnnCreateTensorDescriptor", "", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnCreateTensorDescriptor", {"hipdnnCreateTensorDescriptor", "miopenCreateTensorDescriptor", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnSetTensor4dDescriptor", {"hipdnnSetTensor4dDescriptor", "", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnSetTensor4dDescriptorEx", {"hipdnnSetTensor4dDescriptorEx", "", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnGetTensor4dDescriptor", {"hipdnnGetTensor4dDescriptor", "", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnSetTensor4dDescriptorEx", {"hipdnnSetTensor4dDescriptorEx", "miopenSet4dTensorDescriptorEx", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnGetTensor4dDescriptor", {"hipdnnGetTensor4dDescriptor", "miopenGet4dTensorDescriptor", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnSetTensorNdDescriptor", {"hipdnnSetTensorNdDescriptor", "", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnSetTensorNdDescriptorEx", {"hipdnnSetTensorNdDescriptorEx", "", CONV_LIB_FUNC, API_DNN, 2, HIP_UNSUPPORTED}},
{"cudnnGetTensorNdDescriptor", {"hipdnnGetTensorNdDescriptor", "", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnGetTensorSizeInBytes", {"hipdnnGetTensorSizeInBytes", "", CONV_LIB_FUNC, API_DNN, 2, HIP_UNSUPPORTED}},
{"cudnnDestroyTensorDescriptor", {"hipdnnDestroyTensorDescriptor", "", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnDestroyTensorDescriptor", {"hipdnnDestroyTensorDescriptor", "miopenDestroyTensorDescriptor", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnTransformTensor", {"hipdnnTransformTensor", "", CONV_LIB_FUNC, API_DNN, 2, HIP_UNSUPPORTED}},
{"cudnnTransformTensorEx", {"hipdnnTransformTensorEx", "", CONV_LIB_FUNC, API_DNN, 2, HIP_UNSUPPORTED}},
{"cudnnInitTransformDest", {"hipdnnInitTransformDest", "", CONV_LIB_FUNC, API_DNN, 2, HIP_UNSUPPORTED}},
Expand Down
22 changes: 11 additions & 11 deletions src/CUDA2HIP_DNN_API_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ const std::map<llvm::StringRef, hipCounter> CUDA_DNN_TYPE_NAME_MAP {
{"CUDNN_TENSOR_OP_MATH", {"HIPDNN_TENSOR_OP_MATH", "", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 1
{"CUDNN_TENSOR_OP_MATH_ALLOW_CONVERSION", {"HIPDNN_TENSOR_OP_MATH_ALLOW_CONVERSION", "", CONV_NUMERIC_LITERAL, API_DNN, 1, HIP_UNSUPPORTED}}, // 2
{"CUDNN_FMA_MATH", {"HIPDNN_FMA_MATH", "", CONV_NUMERIC_LITERAL, API_DNN, 1, HIP_UNSUPPORTED}}, // 3
{"cudnnNanPropagation_t", {"hipdnnNanPropagation_t", "", CONV_TYPE, API_DNN, 1}},
{"CUDNN_NOT_PROPAGATE_NAN", {"HIPDNN_NOT_PROPAGATE_NAN", "", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 0
{"CUDNN_PROPAGATE_NAN", {"HIPDNN_PROPAGATE_NAN", "", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 1
{"cudnnNanPropagation_t", {"hipdnnNanPropagation_t", "miopenNanPropagation_t", CONV_TYPE, API_DNN, 1}},
{"CUDNN_NOT_PROPAGATE_NAN", {"HIPDNN_NOT_PROPAGATE_NAN", "MIOPEN_NOT_PROPAGATE_NAN", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 0
{"CUDNN_PROPAGATE_NAN", {"HIPDNN_PROPAGATE_NAN", "MIOPEN_PROPAGATE_NAN", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 1
{"cudnnConvolutionBwdDataAlgo_t", {"hipdnnConvolutionBwdDataAlgo_t", "", CONV_TYPE, API_DNN, 1}},
{"CUDNN_CONVOLUTION_BWD_DATA_ALGO_0", {"HIPDNN_CONVOLUTION_BWD_DATA_ALGO_0", "", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 0
{"CUDNN_CONVOLUTION_BWD_DATA_ALGO_1", {"HIPDNN_CONVOLUTION_BWD_DATA_ALGO_1", "", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 1
Expand Down Expand Up @@ -202,18 +202,18 @@ const std::map<llvm::StringRef, hipCounter> CUDA_DNN_TYPE_NAME_MAP {
{"CUDNN_REDUCE_TENSOR_NORM1", {"HIPDNN_REDUCE_TENSOR_NORM1", "MIOPEN_REDUCE_TENSOR_NORM1", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 6
{"CUDNN_REDUCE_TENSOR_NORM2", {"HIPDNN_REDUCE_TENSOR_NORM2", "MIOPEN_REDUCE_TENSOR_NORM2", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 7
{"CUDNN_REDUCE_TENSOR_MUL_NO_ZEROS", {"HIPDNN_REDUCE_TENSOR_MUL_NO_ZEROS", "", CONV_NUMERIC_LITERAL, API_DNN, 1, ROC_UNSUPPORTED}}, // 8
{"cudnnReduceTensorIndices_t", {"hipdnnReduceTensorIndices_t", "", CONV_TYPE, API_DNN, 1}},
{"CUDNN_REDUCE_TENSOR_NO_INDICES", {"HIPDNN_REDUCE_TENSOR_NO_INDICES", "", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 0
{"CUDNN_REDUCE_TENSOR_FLATTENED_INDICES", {"HIPDNN_REDUCE_TENSOR_FLATTENED_INDICES", "", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 1
{"cudnnReduceTensorIndices_t", {"hipdnnReduceTensorIndices_t", "miopenReduceTensorIndices_t", CONV_TYPE, API_DNN, 1}},
{"CUDNN_REDUCE_TENSOR_NO_INDICES", {"HIPDNN_REDUCE_TENSOR_NO_INDICES", "MIOPEN_REDUCE_TENSOR_NO_INDICES", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 0
{"CUDNN_REDUCE_TENSOR_FLATTENED_INDICES", {"HIPDNN_REDUCE_TENSOR_FLATTENED_INDICES", "MIOPEN_REDUCE_TENSOR_FLATTENED_INDICES", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 1
{"cudnnConvolutionBwdDataPreference_t", {"hipdnnConvolutionBwdDataPreference_t", "", CONV_TYPE, API_DNN, 1, CUDA_DEPRECATED | CUDA_REMOVED}},
{"CUDNN_CONVOLUTION_BWD_DATA_NO_WORKSPACE", {"HIPDNN_CONVOLUTION_BWD_DATA_NO_WORKSPACE", "", CONV_NUMERIC_LITERAL, API_DNN, 1, CUDA_DEPRECATED | CUDA_REMOVED}}, // 0
{"CUDNN_CONVOLUTION_BWD_DATA_PREFER_FASTEST", {"HIPDNN_CONVOLUTION_BWD_DATA_PREFER_FASTEST", "", CONV_NUMERIC_LITERAL, API_DNN, 1, CUDA_DEPRECATED | CUDA_REMOVED}}, // 1
{"CUDNN_CONVOLUTION_BWD_DATA_SPECIFY_WORKSPACE_LIMIT", {"HIPDNN_CONVOLUTION_BWD_DATA_SPECIFY_WORKSPACE_LIMIT", "", CONV_NUMERIC_LITERAL, API_DNN, 1, CUDA_DEPRECATED | CUDA_REMOVED}}, // 2
{"cudnnIndicesType_t", {"hipdnnIndicesType_t", "", CONV_TYPE, API_DNN, 1}},
{"CUDNN_32BIT_INDICES", {"HIPDNN_32BIT_INDICES", "", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 0
{"CUDNN_64BIT_INDICES", {"HIPDNN_64BIT_INDICES", "", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 1
{"CUDNN_16BIT_INDICES", {"HIPDNN_16BIT_INDICES", "", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 2
{"CUDNN_8BIT_INDICES", {"HIPDNN_8BIT_INDICES", "", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 3
{"cudnnIndicesType_t", {"hipdnnIndicesType_t", "miopenIndicesType_t", CONV_TYPE, API_DNN, 1}},
{"CUDNN_32BIT_INDICES", {"HIPDNN_32BIT_INDICES", "MIOPEN_32BIT_INDICES", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 0
{"CUDNN_64BIT_INDICES", {"HIPDNN_64BIT_INDICES", "MIOPEN_64BIT_INDICES", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 1
{"CUDNN_16BIT_INDICES", {"HIPDNN_16BIT_INDICES", "MIOPEN_16BIT_INDICES", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 2
{"CUDNN_8BIT_INDICES", {"HIPDNN_8BIT_INDICES", "MIOPEN_8BIT_INDICES", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 3
{"cudnnSoftmaxAlgorithm_t", {"hipdnnSoftmaxAlgorithm_t", "miopenSoftmaxAlgorithm_t", CONV_TYPE, API_DNN, 1}},
{"CUDNN_SOFTMAX_FAST", {"HIPDNN_SOFTMAX_FAST", "MIOPEN_SOFTMAX_FAST", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 0
{"CUDNN_SOFTMAX_ACCURATE", {"HIPDNN_SOFTMAX_ACCURATE", "MIOPEN_SOFTMAX_ACCURATE", CONV_NUMERIC_LITERAL, API_DNN, 1}}, // 1
Expand Down
58 changes: 58 additions & 0 deletions tests/unit_tests/synthetic/libraries/cudnn2miopen.cu
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,63 @@ int main() {
cudnnReduceTensorOp_t REDUCE_TENSOR_NORM1 = CUDNN_REDUCE_TENSOR_NORM1;
cudnnReduceTensorOp_t REDUCE_TENSOR_NORM2 = CUDNN_REDUCE_TENSOR_NORM2;

// CHECK: miopenNanPropagation_t nanPropagation_t;
// CHECK-NEXT: miopenNanPropagation_t NOT_PROPAGATE_NAN = MIOPEN_NOT_PROPAGATE_NAN;
// CHECK-NEXT: miopenNanPropagation_t PROPAGATE_NAN = MIOPEN_PROPAGATE_NAN;
cudnnNanPropagation_t nanPropagation_t;
cudnnNanPropagation_t NOT_PROPAGATE_NAN = CUDNN_NOT_PROPAGATE_NAN;
cudnnNanPropagation_t PROPAGATE_NAN = CUDNN_PROPAGATE_NAN;

// CHECK: miopenReduceTensorIndices_t reduceTensorIndices;
// CHECK-NEXT: miopenReduceTensorIndices_t REDUCE_TENSOR_NO_INDICES = MIOPEN_REDUCE_TENSOR_NO_INDICES;
// CHECK-NEXT: miopenReduceTensorIndices_t REDUCE_TENSOR_FLATTENED_INDICES = MIOPEN_REDUCE_TENSOR_FLATTENED_INDICES;
cudnnReduceTensorIndices_t reduceTensorIndices;
cudnnReduceTensorIndices_t REDUCE_TENSOR_NO_INDICES = CUDNN_REDUCE_TENSOR_NO_INDICES;
cudnnReduceTensorIndices_t REDUCE_TENSOR_FLATTENED_INDICES = CUDNN_REDUCE_TENSOR_FLATTENED_INDICES;

// CHECK: miopenIndicesType_t indicesType;
// CHECK-NEXT: miopenIndicesType_t _32BIT_INDICES = MIOPEN_32BIT_INDICES;
// CHECK-NEXT: miopenIndicesType_t _64BIT_INDICES = MIOPEN_64BIT_INDICES;
// CHECK-NEXT: miopenIndicesType_t _16BIT_INDICES = MIOPEN_16BIT_INDICES;
// CHECK-NEXT: miopenIndicesType_t _8BIT_INDICES = MIOPEN_8BIT_INDICES;
cudnnIndicesType_t indicesType;
cudnnIndicesType_t _32BIT_INDICES = CUDNN_32BIT_INDICES;
cudnnIndicesType_t _64BIT_INDICES = CUDNN_64BIT_INDICES;
cudnnIndicesType_t _16BIT_INDICES = CUDNN_16BIT_INDICES;
cudnnIndicesType_t _8BIT_INDICES = CUDNN_8BIT_INDICES;

// CUDA: cudnnStatus_t CUDNNWINAPI cudnnCreateTensorDescriptor(cudnnTensorDescriptor_t* tensorDesc);
// MIOPEN: MIOPEN_EXPORT miopenStatus_t miopenCreateTensorDescriptor(miopenTensorDescriptor_t* tensorDesc);
// CHECK: status = miopenCreateTensorDescriptor(&tensorDescriptor);
status = cudnnCreateTensorDescriptor(&tensorDescriptor);

// TODO: cudnnSetTensor4dDescriptor -> miopenSet4dTensorDescriptor: different signatures
// CUDA: cudnnStatus_t CUDNNWINAPI cudnnSetTensor4dDescriptor(cudnnTensorDescriptor_t tensorDesc, cudnnTensorFormat_t format, cudnnDataType_t dataType, int n, int c, int h, int w);
// MIOPEN: MIOPEN_EXPORT miopenStatus_t miopenSet4dTensorDescriptor(miopenTensorDescriptor_t tensorDesc, miopenDataType_t dataType, int n, int c, int h, int w);

int n = 0;
int c = 0;
int h = 0;
int w = 0;
int nStride = 0;
int cStride = 0;
int hStride = 0;
int wStride = 0;

// CUDA: cudnnStatus_t CUDNNWINAPI cudnnSetTensor4dDescriptorEx(cudnnTensorDescriptor_t tensorDesc, cudnnDataType_t dataType, int n, int c, int h, int w, int nStride, int cStride, int hStride, int wStride);
// MIOPEN: MIOPEN_EXPORT miopenStatus_t miopenSet4dTensorDescriptorEx(miopenTensorDescriptor_t tensorDesc, miopenDataType_t dataType, int n, int c, int h, int w, int nStride, int cStride, int hStride, int wStride);
// CHECK: status = miopenSet4dTensorDescriptorEx(tensorDescriptor, dataType, n, c, h, w, nStride, cStride, hStride, wStride);
status = cudnnSetTensor4dDescriptorEx(tensorDescriptor, dataType, n, c, h, w, nStride, cStride, hStride, wStride);

// CUDA: cudnnStatus_t CUDNNWINAPI cudnnGetTensor4dDescriptor(const cudnnTensorDescriptor_t tensorDesc, cudnnDataType_t* dataType, int* n, int* c, int* h, int* w, int* nStride, int* cStride, int* hStride, int* wStride);
// MIOPEN: MIOPEN_EXPORT miopenStatus_t miopenGet4dTensorDescriptor(miopenTensorDescriptor_t tensorDesc, miopenDataType_t* dataType, int* n, int* c, int* h, int* w, int* nStride, int* cStride, int* hStride, int* wStride);
// CHECK: status = miopenGet4dTensorDescriptor(tensorDescriptor, &dataType, &n, &c, &h, &w, &nStride, &cStride, &hStride, &wStride);
status = cudnnGetTensor4dDescriptor(tensorDescriptor, &dataType, &n, &c, &h, &w, &nStride, &cStride, &hStride, &wStride);

// CUDA: cudnnStatus_t CUDNNWINAPI cudnnDestroyTensorDescriptor(cudnnTensorDescriptor_t tensorDesc);
// MIOPEN: MIOPEN_EXPORT miopenStatus_t miopenDestroyTensorDescriptor(miopenTensorDescriptor_t tensorDesc);
// CHECK: status = miopenDestroyTensorDescriptor(tensorDescriptor);
status = cudnnDestroyTensorDescriptor(tensorDescriptor);

return 0;
}

0 comments on commit a92fecf

Please sign in to comment.