Fix _reduce_dims call in reduction#3262
Conversation
_reduce_dims call in reduction_reduce_dims call in reduction
_reduce_dims call in reduction_reduce_dims call in reduction
|
Fixed, PTAL |
cupy/core/_reduction.pyx
Outdated
| out_shape = _get_out_shape(a_shape, reduce_axis, out_axis, keepdims) | ||
| # Needs to create the empty arrays first and access them for the | ||
| # _reduce_dims to work. | ||
| out_args_ = self._get_out_args(out_args, out_types, out_shape) |
There was a problem hiding this comment.
This is where the actual out arrays are instantiated when out=None
|
Could you add a test for this case? |
|
The behavior is not exposed externally, so It's hard to test. |
|
It can be tested with a mock test, but I think it is OK to do it in another PR. |
|
Jenkins, test this please. |
|
Successfully created a job for commit f2bb128: |
f2bb128 to
eb88eab
Compare
|
Sorry, I just pushed a test based on the original error now 😆 |
|
Jenkins, test this please. |
|
Successfully created a job for commit eb88eab: |
|
pfnCI is appearing but Jenkins is missing from the checks 😂 |
|
Jenkins, test this please. |
|
Successfully created a job for commit eb88eab: |
|
pfnCI, test this please. |
|
Successfully created a job for commit eb88eab: |
|
pfnCI, test this please. |
|
Successfully created a job for commit eb88eab: |
|
Jenkins CI test (for commit eb88eab, target branch master) failed with status FAILURE. |
eb88eab to
f6e470d
Compare
|
Fixed, PTAL |
|
Jenkins, test this please. |
|
Successfully created a job for commit f6e470d: |
|
pfnCI, test this please. |
|
Successfully created a job for commit f6e470d: |
|
Jenkins CI test (for commit f6e470d, target branch master) succeeded! |
|
Jenkins CI test (for commit f6e470d, target branch master) succeeded! |
Closes #3258
When calling
_reduce_dims, the out_args tuple was empty, so dimensions were never reduced._get_out_argsis the function that initializes the actual arrays if theoutparameter is an empty list, and it wasn't called until later.This PR calls
_get_out_argsbefore and then retrieves itsndarrayobjects, so that dimensions can be effectively reduced. Then it recreates the outputArgsas the dimensionality might have changed and the kernel generated code can be wrong.Another way to solve this could be to make
_reduce_dimsallow a list ofArgobjects as the parameter and modify it accordingly.ElementwiseKerneldoes not suffer from this issue