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

Commit ab22211

Browse files
[BACKPORT][BUGFIX][FEATURE] Add oneDNN 1D and 3D deconvolution support and fix bias (#20292)
* [v1.x][BUGFIX] Implement oneDNN deconvolution primitives to deconvolution 2D (#20107) * Use mkldnn deconvolution primitive in deconvolution * Apply clang-format * Refactor deconvolution version 1 * Refactor deconvolution version 2 and use permute_axes in IOLogicalSwapDesc * Refactor deconvolution version 3 * Enable Deconvolution2D test * Fix sanity * Fix windows builds * Fix deconvolution with bias test * [v1.x][FEATURE] Add MKLDNN Deconvolution 1D and 3D support (#20137) * Use MXNET_USE_ONEDNN * Fix test * Apply formatter * Add native support for 3D deconvolution * Remove outdated check * Replace math.prod with np.prod * Check convolution layout only when it has value * Remove outdated check * Change tests * Increase default workspace size to mach convolution * Fix deconv workspace size * Increase default deconv workspace size in python API * Disable 3D tests for GPU * Add deconv arguments checks * Remove next_impl calls until it is fixed * Share workspace * Fix documentation * Add test_deconv_dilation * Fix check * Fix include order
1 parent 80d72b5 commit ab22211

13 files changed

+1082
-828
lines changed

Diff for: python/mxnet/ndarray/numpy_extension/_op.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -617,9 +617,9 @@ def convolution(data=None, weight=None, bias=None, kernel=None, stride=None, dil
617617
@set_module('mxnet.ndarray.numpy_extension')
618618
def deconvolution(data=None, weight=None, bias=None, kernel=None, stride=None, dilate=None,
619619
pad=None, adj=None, target_shape=None, num_filter=1, num_group=1,
620-
workspace=512, no_bias=False, cudnn_tune=None,
620+
workspace=1024, no_bias=False, cudnn_tune=None,
621621
cudnn_off=False, layout=None):
622-
r"""Computes 1D or 2D transposed convolution (aka fractionally strided convolution) of
622+
r"""Computes 1D, 2D or 3D transposed convolution (aka fractionally strided convolution) of
623623
the input tensor. This operation can be seen as the gradient of Convolution operation
624624
with respect to its input. Convolution usually reduces the size of the input.
625625
Transposed convolution works the other way, going from a smaller input

Diff for: python/mxnet/numpy_extension/_op.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,9 @@ def convolution(data=None, weight=None, bias=None, kernel=None, stride=None, dil
586586
@set_module('mxnet.numpy_extension')
587587
def deconvolution(data=None, weight=None, bias=None, kernel=None, stride=None, dilate=None,
588588
pad=None, adj=None, target_shape=None, num_filter=1, num_group=1,
589-
workspace=512, no_bias=False, cudnn_tune=None,
589+
workspace=1024, no_bias=False, cudnn_tune=None,
590590
cudnn_off=False, layout=None):
591-
r"""Computes 1D or 2D transposed convolution (aka fractionally strided convolution) of
591+
r"""Computes 1D, 2D or 3D transposed convolution (aka fractionally strided convolution) of
592592
the input tensor. This operation can be seen as the gradient of Convolution operation
593593
with respect to its input. Convolution usually reduces the size of the input.
594594
Transposed convolution works the other way, going from a smaller input

Diff for: src/operator/deformable_convolution-inl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ class DeformableConvolutionOp : public Operator {
328328
index_t num_kernels_col2im_;
329329
bool bias_term_; // has bias term?
330330
bool is_1x1_;
331-
}; // class ConvolutionOp
331+
}; // class DeformableConvolutionOp
332332

333333
template <typename xpu>
334334
Operator* CreateOp(DeformableConvolutionParam param,

Diff for: src/operator/modulated_deformable_convolution-inl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ class ModulatedDeformableConvolutionOp : public Operator {
389389
index_t im2col_step_;
390390
bool bias_term_; // has bias term?
391391
bool is_1x1_;
392-
}; // class ConvolutionOp
392+
}; // class ModulatedDeformableConvolutionOp
393393

394394
template <typename xpu>
395395
Operator* CreateOp(ModulatedDeformableConvolutionParam param,

Diff for: src/operator/nn/convolution-inl.h

+155-69
Large diffs are not rendered by default.

Diff for: src/operator/nn/deconvolution-inl.h

+68-227
Large diffs are not rendered by default.

Diff for: src/operator/nn/deconvolution.cc

+3-9
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,6 @@ static bool DeconvolutionShape(const nnvm::NodeAttrs& attrs,
9797
mxnet::ShapeVector* in_shape,
9898
mxnet::ShapeVector* out_shape) {
9999
const DeconvolutionParam& param_ = nnvm::get<DeconvolutionParam>(attrs.parsed);
100-
#if MXNET_USE_CUDNN == 0
101-
if (param_.kernel.ndim() > 2) {
102-
LOG(FATAL) << "If not using CUDNN, only 1D or 2D Deconvolution is supported";
103-
return false;
104-
}
105-
#endif // CUDNN
106100

107101
using namespace mshadow;
108102
if (!param_.no_bias) {
@@ -412,9 +406,9 @@ DMLC_REGISTER_PARAMETER(DeconvolutionParam);
412406
NNVM_REGISTER_OP(Deconvolution)
413407
.add_alias("_npx_deconvolution")
414408
.describe(
415-
"Computes 1D or 2D transposed convolution (aka fractionally strided convolution) of the "
416-
"input tensor. This operation can be seen as the gradient of Convolution operation with "
417-
"respect to its input. Convolution usually reduces the size of the input. Transposed "
409+
"Computes 1D, 2D or 3D transposed convolution (aka fractionally strided convolution) of "
410+
"the input tensor. This operation can be seen as the gradient of Convolution operation "
411+
"with respect to its input. Convolution usually reduces the size of the input. Transposed "
418412
"convolution works the other way, going from a smaller input to a larger output while "
419413
"preserving the connectivity pattern.")
420414
.set_num_inputs([](const NodeAttrs& attrs) {

0 commit comments

Comments
 (0)