commit 1d9e165e516cbf324d9ac2717e56d960a4d9117a
parent a49db45bb3a3d70bfbd3f6f648206206315b66b1
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date: Sun, 26 Nov 2023 17:18:09 +0000
More tests in reduce.cpp
Diffstat:
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git a/tests/unit/base/reduce.cpp b/tests/unit/base/reduce.cpp
@@ -4,6 +4,7 @@
* See LICENSE.txt for details
*/
+#include "kfr/base/tensor.hpp"
#include <kfr/base/reduce.hpp>
#include <kfr/base/simd_expressions.hpp>
#include <kfr/base/univector.hpp>
@@ -59,5 +60,16 @@ TEST(dotproduct)
univector<float, 177> v2 = counter() * 2 + 10;
CHECK(dotproduct(v1, v2) == 3821312);
}
+
+TEST(reduce_multidim)
+{
+ CHECK(sum(tensor<int, 2>(shape{ 3, 3 }, { 1, 2, 3, 4, 5, 6, 7, 8, 9 })) == 45); //
+ CHECK(sum(tensor<int, 3>(shape{ 2, 2, 2 }, { 1, 2, 3, 4, 5, 6, 7, 8 })) == 36); //
+
+ CHECK(maxof(tensor<int, 3>(shape{ 2, 2, 2 }, { 1, 2, 3, 4, 5, 6, 7, 8 })) == 8); //
+ CHECK(minof(tensor<int, 3>(shape{ 2, 2, 2 }, { 1, 2, 3, 4, 5, 6, 7, 8 })) == 1); //
+ CHECK(product(tensor<int, 3>(shape{ 2, 2, 2 }, { 1, 2, 3, 4, 5, 6, 7, 8 })) == 40320); //
+}
+
} // namespace CMT_ARCH_NAME
} // namespace kfr