Mercurial > octave
changeset 33304:acef2a35ba7c
test: speed up BIST for the central part of convn with 'full' shape.
The test for bug #39314 requires a particularly long array. That array has
176,800 elements (size of [13 17 8 10 10]). The test checks if the central
part of a "full" convolution is the same as the "valid" convolution (it is not,
this is bug #39314). The assert command then shows all the elements that are
different (effectively all) which makes it extremely slow for such a large
array. This commit changes the test so it does the comparison first, and only
passes a true/false to "assert".
The end performance improvement will be machine and options dependent but in my
machine it reduces the test time from 6 to 0.7 seconds. On Discourse
(https://octave.discourse.group/t/conv2-test-time-rather-long/5446/18) some
people were experiencing 15 minutes for this test alone.
* conv2.cc: Check equality of observed and expected arrays and pass true/false
result to assert.
author | David Miguel Susano Pinto <carandraug@octave.org> |
---|---|
date | Wed, 03 Apr 2024 13:28:52 +0100 |
parents | eeb900fb16fc |
children | 0b4118c91dc9 3454c18569c2 |
files | libinterp/corefcn/conv2.cc |
diffstat | 1 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/conv2.cc Wed Apr 03 08:31:10 2024 -0700 +++ b/libinterp/corefcn/conv2.cc Wed Apr 03 13:28:52 2024 +0100 @@ -435,7 +435,8 @@ %! c = convn (a, b, "full"); %!assert (convn (a, b, "same"), c(2:11,2:11,2:11)) %!test <39314> -%! assert (convn (a, b, "valid"), c(3:10,3:10,3:10)); +%! assert (all ((convn (a, b, "valid") == c(3:10,3:10,3:10))(:)), +%! "central part of convn 'full' differs from convn 'valid'"); %! %!test %! old_state = rand ("state"); @@ -447,7 +448,8 @@ %! c = convn (a, b, "full"); %!assert (convn (a, b, "same"), c(2:11,2:11,:)) %!test <39314> -%! assert (convn (a, b, "valid"), c(3:10,3:10,:)); +%! assert (all ((convn (a, b, "valid") == c(3:10,3:10,:))(:)), +%! "central part of convn 'full' differs from convn 'valid'"); %! %!test %! old_state = rand ("state"); @@ -470,7 +472,8 @@ %! c = convn (a, b, "full"); %!assert (convn (a, b, "same"), c(3:12,2:16,2:8,2:9,:)) %!test <39314> -%! assert (convn (a, b, "valid"), c(4:10,3:15,2:7,3:8,:)); +%! assert (all ((convn (a, b, "valid") == c(4:10,3:15,2:7,3:8,:))(:)), +%! "central part of convn 'full' differs from convn 'valid'"); %!test %! a = reshape (floor (magic (16) /10), [4 8 4 2]);