New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make b c-contiguous in backward for deconvolution #2666

merged 1 commit into from May 1, 2017


None yet
2 participants

soramichi commented Apr 30, 2017

Currently b is not converted into c-contiguous in the backward functions of deconvolution (although it is made c-contiguous in the forward functions), because b is used as gb = cuda.cupy.empty_like(b) and cuda.cupy.empty_like always returns a c-contiguous array.

However, this behavior of cuda.cupy.empty_like is implementation specific that is different from how numpy.empty_like behaves. For a fortran array x, numpy.empty_like(x) returns a fortran array if the order argument is not given, as documented in

numpy.empty_like(a, dtype=None, order='K', subok=True)
order : {‘C’, ‘F’, ‘A’, or ‘K’}, optional
Overrides the memory layout of the result. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if a is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of a as closely as possible.

Given this, I believe converting b into c-contiguous here is a good thing to make the code more robust, especially against future extensions of cupy.


This comment has been minimized.


gwtnb commented May 1, 2017


@gwtnb gwtnb merged commit a98bace into chainer:master May 1, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed

@gwtnb gwtnb added the bug label May 1, 2017

@gwtnb gwtnb added this to the v1.24.0 milestone May 1, 2017

@gwtnb gwtnb self-assigned this May 1, 2017

@soramichi soramichi deleted the soramichi:c_contiguous_bias_backward branch May 1, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment