Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HIPIFY][#584][DNN][MIOpen] cuDNN -> MIOpen - Part 19 - cuDNN Dropout functions #842

Merged
merged 1 commit into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/CUDA2HIP_DNN_API_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ const std::map<llvm::StringRef, hipCounter> CUDA_DNN_FUNCTION_MAP {
{"cudnnSpatialTfSamplerBackward", {"hipdnnSpatialTfSamplerBackward", "", CONV_LIB_FUNC, API_DNN, 2, HIP_UNSUPPORTED}},

// cuDNN Dropout functions
{"cudnnCreateDropoutDescriptor", {"hipdnnCreateDropoutDescriptor", "", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnDestroyDropoutDescriptor", {"hipdnnDestroyDropoutDescriptor", "", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnDropoutGetStatesSize", {"hipdnnDropoutGetStatesSize", "", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnDropoutGetReserveSpaceSize", {"hipdnnDropoutGetReserveSpaceSize", "", CONV_LIB_FUNC, API_DNN, 2, HIP_UNSUPPORTED}},
{"cudnnSetDropoutDescriptor", {"hipdnnSetDropoutDescriptor", "", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnGetDropoutDescriptor", {"hipdnnGetDropoutDescriptor", "", CONV_LIB_FUNC, API_DNN, 2, HIP_UNSUPPORTED}},
{"cudnnRestoreDropoutDescriptor", {"hipdnnRestoreDropoutDescriptor", "", CONV_LIB_FUNC, API_DNN, 2, HIP_UNSUPPORTED}},
{"cudnnDropoutForward", {"hipdnnDropoutForward", "", CONV_LIB_FUNC, API_DNN, 2, HIP_UNSUPPORTED}},
{"cudnnDropoutBackward", {"hipdnnDropoutBackward", "", CONV_LIB_FUNC, API_DNN, 2, HIP_UNSUPPORTED}},
{"cudnnCreateDropoutDescriptor", {"hipdnnCreateDropoutDescriptor", "miopenCreateDropoutDescriptor", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnDestroyDropoutDescriptor", {"hipdnnDestroyDropoutDescriptor", "miopenDestroyDropoutDescriptor", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnDropoutGetStatesSize", {"hipdnnDropoutGetStatesSize", "miopenDropoutGetStatesSize", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnDropoutGetReserveSpaceSize", {"hipdnnDropoutGetReserveSpaceSize", "miopenDropoutGetReserveSpaceSize", CONV_LIB_FUNC, API_DNN, 2, HIP_UNSUPPORTED}},
{"cudnnSetDropoutDescriptor", {"hipdnnSetDropoutDescriptor", "miopenSetDropoutDescriptor", CONV_LIB_FUNC, API_DNN, 2}},
{"cudnnGetDropoutDescriptor", {"hipdnnGetDropoutDescriptor", "miopenGetDropoutDescriptor", CONV_LIB_FUNC, API_DNN, 2, HIP_UNSUPPORTED}},
{"cudnnRestoreDropoutDescriptor", {"hipdnnRestoreDropoutDescriptor", "miopenRestoreDropoutDescriptor", CONV_LIB_FUNC, API_DNN, 2, HIP_UNSUPPORTED}},
{"cudnnDropoutForward", {"hipdnnDropoutForward", "miopenDropoutForward", CONV_LIB_FUNC, API_DNN, 2, HIP_UNSUPPORTED}},
{"cudnnDropoutBackward", {"hipdnnDropoutBackward", "miopenDropoutBackward", CONV_LIB_FUNC, API_DNN, 2, HIP_UNSUPPORTED}},

// cuDNN RNN functions
{"cudnnCreateRNNDescriptor", {"hipdnnCreateRNNDescriptor", "miopenCreateRNNDescriptor", CONV_LIB_FUNC, API_DNN, 2}},
Expand Down
54 changes: 54 additions & 0 deletions tests/unit_tests/synthetic/libraries/cudnn2miopen.cu
Original file line number Diff line number Diff line change
Expand Up @@ -746,5 +746,59 @@ int main() {
// CHECK: status = miopenCTCLoss(handle, probsD, probs, &labels, &labelLengths, &inputLengths, losses, gradientsD, gradients, CTCLossAlgo, CTCLossDescriptor, workSpace , workSpaceSizeInBytes);
status = cudnnCTCLoss(handle, probsD, probs, &labels, &labelLengths, &inputLengths, losses, gradientsD, gradients, CTCLossAlgo, CTCLossDescriptor, workSpace , workSpaceSizeInBytes);

// CUDA: cudnnStatus_t CUDNNWINAPI cudnnCreateDropoutDescriptor(cudnnDropoutDescriptor_t* dropoutDesc);
// MIOPEN: MIOPEN_EXPORT miopenStatus_t miopenCreateDropoutDescriptor(miopenDropoutDescriptor_t* dropoutDesc);
// CHECK: status = miopenCreateDropoutDescriptor(&DropoutDescriptor);
status = cudnnCreateDropoutDescriptor(&DropoutDescriptor);

// CUDA: cudnnStatus_t CUDNNWINAPI cudnnDestroyDropoutDescriptor(cudnnDropoutDescriptor_t dropoutDesc);
// MIOPEN: MIOPEN_EXPORT miopenStatus_t miopenDestroyDropoutDescriptor(miopenDropoutDescriptor_t dropoutDesc);
// CHECK: status = miopenDestroyDropoutDescriptor(DropoutDescriptor);
status = cudnnDestroyDropoutDescriptor(DropoutDescriptor);

// CUDA: cudnnStatus_t CUDNNWINAPI cudnnDropoutGetReserveSpaceSize(cudnnTensorDescriptor_t xdesc, size_t* sizeInBytes);
// MIOPEN: MIOPEN_EXPORT miopenStatus_t miopenDropoutGetReserveSpaceSize(const miopenTensorDescriptor_t xDesc, size_t* reserveSpaceSizeInBytes);
// CHECK: status = miopenDropoutGetReserveSpaceSize(xD, &reserveSpaceNumBytes);
status = cudnnDropoutGetReserveSpaceSize(xD, &reserveSpaceNumBytes);

// CUDA: cudnnStatus_t CUDNNWINAPI cudnnDropoutGetStatesSize(cudnnHandle_t handle, size_t* sizeInBytes);
// MIOPEN: MIOPEN_EXPORT miopenStatus_t miopenDropoutGetStatesSize(miopenHandle_t handle, size_t* stateSizeInBytes);
// CHECK: status = miopenDropoutGetStatesSize(handle, &reserveSpaceNumBytes);
status = cudnnDropoutGetStatesSize(handle, &reserveSpaceNumBytes);

float dropout = 0.0f;
void* states = nullptr;
unsigned long long seed = 0;

// TODO [#837]: Insert float* dropout, void** states, unsigned long long* seed in the hipified miopenGetDropoutDescriptor: will need variable declaration
// CUDA: cudnnStatus_t CUDNNWINAPI cudnnGetDropoutDescriptor(cudnnDropoutDescriptor_t dropoutDesc, cudnnHandle_t handle, float* dropout, void** states, unsigned long long* seed);
// MIOPEN: MIOPEN_EXPORT miopenStatus_t miopenGetDropoutDescriptor(miopenDropoutDescriptor_t dropoutDesc, miopenHandle_t handle, float* dropout, void** states, unsigned long long* seed, bool* use_mask, bool* state_evo, miopenRNGType_t* rng_mode);
// CHECK: status = miopenGetDropoutDescriptor(DropoutDescriptor, handle, &dropout, &states, &seed);
status = cudnnGetDropoutDescriptor(DropoutDescriptor, handle, &dropout, &states, &seed);

// TODO [#837]: Insert bool use_mask, bool state_evo, miopenRNGType_t rng_mode in the hipified miopenGetDropoutDescriptor: will need variable declaration
// CUDA: cudnnStatus_t CUDNNWINAPI cudnnSetDropoutDescriptor(cudnnDropoutDescriptor_t dropoutDesc, cudnnHandle_t handle, float dropout, void* states, size_t stateSizeInBytes, unsigned long long seed);
// MIOPEN: MIOPEN_EXPORT miopenStatus_t miopenSetDropoutDescriptor(miopenDropoutDescriptor_t dropoutDesc, miopenHandle_t handle, float dropout, void* states, size_t stateSizeInBytes, unsigned long long seed, bool use_mask, bool state_evo, miopenRNGType_t rng_mode);
// CHECK: status = miopenSetDropoutDescriptor(DropoutDescriptor, handle, dropout, states, reserveSpaceNumBytes, seed);
status = cudnnSetDropoutDescriptor(DropoutDescriptor, handle, dropout, states, reserveSpaceNumBytes, seed);

// TODO [#837]: Insert bool use_mask, bool state_evo, miopenRNGType_t rng_mode in the hipified miopenRestoreDropoutDescriptor: will need variable declaration
// CUDA: cudnnStatus_t CUDNNWINAPI cudnnRestoreDropoutDescriptor(cudnnDropoutDescriptor_t dropoutDesc, cudnnHandle_t handle, float dropout, void* states, size_t stateSizeInBytes, unsigned long long seed);
// MIOPEN: MIOPEN_EXPORT miopenStatus_t miopenRestoreDropoutDescriptor(miopenDropoutDescriptor_t dropoutDesc, miopenHandle_t handle, float dropout, void* states, size_t stateSizeInBytes, unsigned long long seed, bool use_mask, bool state_evo, miopenRNGType_t rng_mode);
// CHECK: status = miopenRestoreDropoutDescriptor(DropoutDescriptor, handle, dropout, states, reserveSpaceNumBytes, seed);
status = cudnnRestoreDropoutDescriptor(DropoutDescriptor, handle, dropout, states, reserveSpaceNumBytes, seed);

// TODO [#837]: Insert const miopenTensorDescriptor_t noise_shape in the hipified miopenDropoutForward: will need variable declaration
// CUDA: cudnnStatus_t CUDNNWINAPI cudnnDropoutForward(cudnnHandle_t handle, const cudnnDropoutDescriptor_t dropoutDesc, const cudnnTensorDescriptor_t xdesc, const void* x, const cudnnTensorDescriptor_t ydesc, void* y, void* reserveSpace, size_t reserveSpaceSizeInBytes);
// MIOPEN: MIOPEN_EXPORT miopenStatus_t miopenDropoutForward(miopenHandle_t handle, const miopenDropoutDescriptor_t dropoutDesc, const miopenTensorDescriptor_t noise_shape, const miopenTensorDescriptor_t xDesc, const void* x, const miopenTensorDescriptor_t yDesc, void* y, void* reserveSpace, size_t reserveSpaceSizeInBytes);
// CHECK: status = miopenDropoutForward(handle, DropoutDescriptor, xD, x, yD, y, reserveSpace, reserveSpaceNumBytes);
status = cudnnDropoutForward(handle, DropoutDescriptor, xD, x, yD, y, reserveSpace, reserveSpaceNumBytes);

// TODO [#837]: Insert const miopenTensorDescriptor_t noise_shape in the hipified miopenDropoutBackward: will need variable declaration
// CUDA: cudnnStatus_t CUDNNWINAPI cudnnDropoutBackward(cudnnHandle_t handle, const cudnnDropoutDescriptor_t dropoutDesc, const cudnnTensorDescriptor_t dydesc, const void* dy, const cudnnTensorDescriptor_t dxdesc, void* dx, void* reserveSpace, size_t reserveSpaceSizeInBytes);
// MIOPNE: MIOPEN_EXPORT miopenStatus_t miopenDropoutBackward(miopenHandle_t handle, const miopenDropoutDescriptor_t dropoutDesc, const miopenTensorDescriptor_t noise_shape, const miopenTensorDescriptor_t dyDesc, const void* dy, const miopenTensorDescriptor_t dxDesc, void* dx, void* reserveSpace, size_t reserveSpaceSizeInBytes);
// CHECK: status = miopenDropoutBackward(handle, DropoutDescriptor, yD, y, xD, x, reserveSpace, reserveSpaceNumBytes);
status = cudnnDropoutBackward(handle, DropoutDescriptor, yD, y, xD, x, reserveSpace, reserveSpaceNumBytes);

return 0;
}