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

Commit

Permalink
[BACKPORT][BUGFIX][FEATURE] Add oneDNN 1D and 3D deconvolution suppor…
Browse files Browse the repository at this point in the history
…t 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
  • Loading branch information
PawelGlomski-Intel authored Sep 29, 2021
1 parent 80d72b5 commit ab22211
Show file tree
Hide file tree
Showing 13 changed files with 1,082 additions and 828 deletions.
4 changes: 2 additions & 2 deletions python/mxnet/ndarray/numpy_extension/_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,9 @@ def convolution(data=None, weight=None, bias=None, kernel=None, stride=None, dil
@set_module('mxnet.ndarray.numpy_extension')
def deconvolution(data=None, weight=None, bias=None, kernel=None, stride=None, dilate=None,
pad=None, adj=None, target_shape=None, num_filter=1, num_group=1,
workspace=512, no_bias=False, cudnn_tune=None,
workspace=1024, no_bias=False, cudnn_tune=None,
cudnn_off=False, layout=None):
r"""Computes 1D or 2D transposed convolution (aka fractionally strided convolution) of
r"""Computes 1D, 2D or 3D transposed convolution (aka fractionally strided convolution) of
the input tensor. This operation can be seen as the gradient of Convolution operation
with respect to its input. Convolution usually reduces the size of the input.
Transposed convolution works the other way, going from a smaller input
Expand Down
4 changes: 2 additions & 2 deletions python/mxnet/numpy_extension/_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,9 @@ def convolution(data=None, weight=None, bias=None, kernel=None, stride=None, dil
@set_module('mxnet.numpy_extension')
def deconvolution(data=None, weight=None, bias=None, kernel=None, stride=None, dilate=None,
pad=None, adj=None, target_shape=None, num_filter=1, num_group=1,
workspace=512, no_bias=False, cudnn_tune=None,
workspace=1024, no_bias=False, cudnn_tune=None,
cudnn_off=False, layout=None):
r"""Computes 1D or 2D transposed convolution (aka fractionally strided convolution) of
r"""Computes 1D, 2D or 3D transposed convolution (aka fractionally strided convolution) of
the input tensor. This operation can be seen as the gradient of Convolution operation
with respect to its input. Convolution usually reduces the size of the input.
Transposed convolution works the other way, going from a smaller input
Expand Down
2 changes: 1 addition & 1 deletion src/operator/deformable_convolution-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class DeformableConvolutionOp : public Operator {
index_t num_kernels_col2im_;
bool bias_term_; // has bias term?
bool is_1x1_;
}; // class ConvolutionOp
}; // class DeformableConvolutionOp

template <typename xpu>
Operator* CreateOp(DeformableConvolutionParam param,
Expand Down
2 changes: 1 addition & 1 deletion src/operator/modulated_deformable_convolution-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ class ModulatedDeformableConvolutionOp : public Operator {
index_t im2col_step_;
bool bias_term_; // has bias term?
bool is_1x1_;
}; // class ConvolutionOp
}; // class ModulatedDeformableConvolutionOp

template <typename xpu>
Operator* CreateOp(ModulatedDeformableConvolutionParam param,
Expand Down
224 changes: 155 additions & 69 deletions src/operator/nn/convolution-inl.h

Large diffs are not rendered by default.

295 changes: 68 additions & 227 deletions src/operator/nn/deconvolution-inl.h

Large diffs are not rendered by default.

12 changes: 3 additions & 9 deletions src/operator/nn/deconvolution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,6 @@ static bool DeconvolutionShape(const nnvm::NodeAttrs& attrs,
mxnet::ShapeVector* in_shape,
mxnet::ShapeVector* out_shape) {
const DeconvolutionParam& param_ = nnvm::get<DeconvolutionParam>(attrs.parsed);
#if MXNET_USE_CUDNN == 0
if (param_.kernel.ndim() > 2) {
LOG(FATAL) << "If not using CUDNN, only 1D or 2D Deconvolution is supported";
return false;
}
#endif // CUDNN

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

0 comments on commit ab22211

Please sign in to comment.