You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by zh...@apache.org on 2020/12/09 02:25:31 UTC
[incubator-mxnet] branch master updated: Enable large tensor inputs
for Deconvolution layer (#19626)
This is an automated email from the ASF dual-hosted git repository.
zha0q1 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 1f07693 Enable large tensor inputs for Deconvolution layer (#19626)
1f07693 is described below
commit 1f076931f537a43881004c95718f26bace83d192
Author: Rohit Kumar Srivastava <sr...@osu.edu>
AuthorDate: Tue Dec 8 18:23:29 2020 -0800
Enable large tensor inputs for Deconvolution layer (#19626)
Co-authored-by: Rohit Kumar Srivastava <sr...@buckeyemail.osu.edu>
---
src/operator/nn/deconvolution-inl.h | 2 +-
tests/nightly/test_np_large_array.py | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/operator/nn/deconvolution-inl.h b/src/operator/nn/deconvolution-inl.h
index 0aac39a..f1e684e 100644
--- a/src/operator/nn/deconvolution-inl.h
+++ b/src/operator/nn/deconvolution-inl.h
@@ -454,7 +454,7 @@ class DeconvolutionOp {
private:
inline index_t InitTemp(const mshadow::Shape<4> &ishape,
const mshadow::Shape<4> &oshape) {
- const int ksize = param_.kernel.Size();
+ const index_t ksize = param_.kernel.Size();
shape_colunit_ = mshadow::Shape2(ishape[1] * ksize,
oshape[2] * oshape[3]);
shape_dstunit_ = mshadow::Shape3(param_.num_group,
diff --git a/tests/nightly/test_np_large_array.py b/tests/nightly/test_np_large_array.py
index b37c401..19ed36c 100644
--- a/tests/nightly/test_np_large_array.py
+++ b/tests/nightly/test_np_large_array.py
@@ -2372,3 +2372,25 @@ def test_convolution():
assert inp.grad.shape == inp.shape
assert inp.grad[0][0][0][0] == 0
+
+@use_np
+def test_deconvolution():
+ dim = 2
+ batch_size = 1
+ channel = 3
+ height = SMALL_Y
+ width = LARGE_X // 5
+ num_filter = 4
+ kernel = (4,) * dim # => shape = (3, 3)
+
+ inp=mx.np.ones(shape=(batch_size, channel, 1, width))
+ weight = mx.np.ones(shape=(channel, num_filter, kernel[0], kernel[1]))
+ bias = mx.np.array(num_filter,)
+ inp.attach_grad()
+ with mx.autograd.record():
+ out = mx.npx.deconvolution(data=inp, weight=weight, num_filter=num_filter, \
+ kernel=kernel, no_bias=True)
+ assert out.shape == (batch_size, channel + 1, kernel[0], width + 3)
+ assert out[0][0][kernel[0]//2][kernel[1]] == channel * num_filter
+ assert inp.grad.shape == inp.shape
+ assert inp.grad[0][0][0][0] == 0