-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note that a zero-size shape represents a unknown shape in mxnet. Please turn on numpy compatibility switch to use 0 as zero dim size.
@with_seed() | ||
def test_zero_sized_min_max(): | ||
def min(): | ||
a = mx.nd.zeros(shape=(5, 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should have already failed here in the infer-shape function of zeros
. If you want to use 0 as zero dim size, please turn numpy compatibility by adding a decorator to the test function so that it will fail in ReduceMinMaxAxesShape
when a.min()
is called.
@with_seed()
@use_np_compat
def test_zero_size_min_max():
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reminisce You'are right. After #14661, the error I reported will only be triggered in numpy mode.
@@ -6990,6 +6990,20 @@ def test_float16_min_max(): | |||
assert np.finfo('float16').max == mx.nd.max(a).asscalar() | |||
|
|||
|
|||
@with_seed() | |||
def test_zero_sized_min_max(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_zero_sized_min_max -> test_zero_size_min_max
99b70ea
to
31e0048
Compare
An unrelated custom operator error happens in CI, I'll create another PR to address it. |
5b8e819
to
92f993f
Compare
fix min max on zero-sized ndarray (apache#14745)
* fix min max of zero-sized ndarray * add test * turn on numpy mode * trigger CI
Description
Calling min or max operator on zero-sized ndarray will return invalid value:
In numpy, the same situation will trigger ValueError, this PR replicates this behavior by throwing MXNetError.
Edit:
This error will only be triggered in numpy mode:
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Comments