Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Enable CUDNN for conv1D (#11194) #11270

Merged
merged 1 commit into from
Jun 14, 2018
Merged
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
17 changes: 13 additions & 4 deletions src/operator/nn/convolution.cu
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,20 @@ void ConvolutionCompute<gpu>(const nnvm::NodeAttrs& attrs,
const ConvolutionParam& param = nnvm::get<ConvolutionParam>(attrs.parsed);
int dtype = inputs[conv::kData].type_flag_;

// If 1D convolution, use MXNet implementation
if (param.kernel.ndim() == 1) {
#if CUDNN_MAJOR < 5
if (param_.layout.value() != kNCW &&
param_.layout.value() != kNCHW &&
param_.layout.value() != kNCDHW) {
// Need CuDNN > 5.0 for layout support. use MXNet implementation
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
ConvolutionOp<gpu, DType> op;
op.Init(param);
op.Forward(ctx, inputs, req, outputs);
})
return;
}
#endif

#if MXNET_USE_CUDNN == 0 || CUDNN_MAJOR < 7
if (param.num_filter == param.num_group &&
param.layout.value() == mshadow::kNCHW &&
Expand Down Expand Up @@ -162,15 +167,19 @@ void ConvolutionGradCompute<gpu>(const nnvm::NodeAttrs& attrs,
const std::vector<TBlob> &in_grad = outputs;
int dtype = out_grad.type_flag_;

// If 1D convolution, use MXNet implementation
if (param.kernel.ndim() == 1) {
#if CUDNN_MAJOR < 5
if (param_.layout.value() != kNCW &&
param_.layout.value() != kNCHW &&
param_.layout.value() != kNCDHW) {
// Need CuDNN > 5.0 for layout support. use MXNet implementation
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
ConvolutionOp<gpu, DType> op;
op.Init(param);
op.Backward(ctx, std::vector<TBlob>{out_grad}, in_data, req, in_grad);
})
return;
}
#endif
#if MXNET_USE_CUDNN == 0 || CUDNN_MAJOR < 7
if (param.num_filter == param.num_group &&
param.layout.value() == mshadow::kNCHW &&
Expand Down