changeset 33440:27e915d3a79c stable

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 af2b017a5a7a
children 411e19dc791b c896de3fa9da
files libinterp/corefcn/conv2.cc
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/conv2.cc	Thu Apr 18 20:59:19 2024 +0200
+++ 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]);