You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by sx...@apache.org on 2019/10/27 17:22:04 UTC
[incubator-mxnet] branch master updated: RNNOp only call cuda/cudnn
if GPU ctx is requested (#16632)
This is an automated email from the ASF dual-hosted git repository.
sxjscience pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push:
new 9f21cdd RNNOp only call cuda/cudnn if GPU ctx is requested (#16632)
9f21cdd is described below
commit 9f21cddb3f6cc81e67a192f313066f7e9edd7fa8
Author: Leonard Lausen <la...@amazon.com>
AuthorDate: Sun Oct 27 10:21:14 2019 -0700
RNNOp only call cuda/cudnn if GPU ctx is requested (#16632)
---
src/operator/rnn-inl.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/operator/rnn-inl.h b/src/operator/rnn-inl.h
index ead7501..b448261 100644
--- a/src/operator/rnn-inl.h
+++ b/src/operator/rnn-inl.h
@@ -422,6 +422,8 @@ class RNNOp {
init_mem_ = false;
reserve_mem_size_ = 0;
#endif
+
+ if (ctx_.dev_type == kGPU) {
#if MXNET_USE_CUDNN == 1
init_cudnn_ = false;
dtype_ = mshadow::DataType<DType>::kCudnnFlag;
@@ -505,6 +507,7 @@ class RNNOp {
LOG(FATAL) << "RNN on GPU is only available for cuDNN at the moment.";
}
#endif // MXNET_USE_CUDNN == 1
+ }
if (ctx_.dev_type == kCPU) {
this->init_space_ = false;
@@ -523,6 +526,7 @@ class RNNOp {
}
~RNNOp() {
+ if (ctx_.dev_type == kGPU) {
#if MXNET_USE_CUDNN == 1
CUDNN_CALL(cudnnDestroyTensorDescriptor(hx_desc_));
CUDNN_CALL(cudnnDestroyTensorDescriptor(cx_desc_));
@@ -557,6 +561,7 @@ class RNNOp {
CUDNN_CALL(cudnnDestroyRNNDataDescriptor(dy_data_desc_));
#endif // MXNET_USE_CUDNN_GE_7200
#endif // MXNET_USE_CUDNN
+ }
}
void Forward(const OpContext &ctx, const std::vector<TBlob> &in_data,