diff options
author | Rasmus Munk Larsen <rmlarsen@google.com> | 2020-04-24 17:29:25 -0700 |
---|---|---|
committer | Rasmus Munk Larsen <rmlarsen@google.com> | 2020-04-28 16:12:47 +0000 |
commit | ab773c7e914633ec4a3ee1f7cdea8b168d3bce1a (patch) | |
tree | 5a82a3071e3c5de39e934ce144023c20f62b2de4 /test/product_small.cpp | |
parent | b47c7779937c1984b7cd2f1d2f8df33d67c396f7 (diff) |
Extend support for Packet16b:
* Add ptranspose<*,4> to support matmul and add unit test for Matrix<bool> * Matrix<bool>
* work around a bug in slicing of Tensor<bool>.
* Add tensor tests
This speeds up matmul for boolean matrices by about 10x
name old time/op new time/op delta
BM_MatMul<bool>/8 267ns ± 0% 479ns ± 0% +79.25% (p=0.008 n=5+5)
BM_MatMul<bool>/32 6.42µs ± 0% 0.87µs ± 0% -86.50% (p=0.008 n=5+5)
BM_MatMul<bool>/64 43.3µs ± 0% 5.9µs ± 0% -86.42% (p=0.008 n=5+5)
BM_MatMul<bool>/128 315µs ± 0% 44µs ± 0% -85.98% (p=0.008 n=5+5)
BM_MatMul<bool>/256 2.41ms ± 0% 0.34ms ± 0% -85.68% (p=0.008 n=5+5)
BM_MatMul<bool>/512 18.8ms ± 0% 2.7ms ± 0% -85.53% (p=0.008 n=5+5)
BM_MatMul<bool>/1k 149ms ± 0% 22ms ± 0% -85.40% (p=0.008 n=5+5)
Diffstat (limited to 'test/product_small.cpp')
-rw-r--r-- | test/product_small.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/test/product_small.cpp b/test/product_small.cpp index b8ce37d90..93876dba4 100644 --- a/test/product_small.cpp +++ b/test/product_small.cpp @@ -56,6 +56,31 @@ test_lazy_single(int rows, int cols, int depth) VERIFY_IS_APPROX(C+=A.lazyProduct(B), ref_prod(D,A,B)); } +template<typename T> +void test_dynamic_exact() +{ + int rows = internal::random<int>(1,64); + int cols = internal::random<int>(1,64); + int depth = internal::random<int>(1,65); + + typedef Matrix<T,Dynamic,Dynamic> MatrixX; + MatrixX A(rows,depth); A.setRandom(); + MatrixX B(depth,cols); B.setRandom(); + MatrixX C(rows,cols); C.setRandom(); + MatrixX D(C); + for(Index i=0;i<C.rows();++i) + for(Index j=0;j<C.cols();++j) + for(Index k=0;k<A.cols();++k) + D.coeffRef(i,j) |= A.coeff(i,k) & B.coeff(k,j); + C += A * B; + VERIFY_IS_EQUAL(C, D); + + MatrixX E = B.transpose(); + for(Index i=0;i<B.rows();++i) + for(Index j=0;j<B.cols();++j) + VERIFY_IS_EQUAL(B(i,j), E(j,i)); +} + template<typename T, int Rows, int Cols, int Depth, int OC, int OA, int OB> typename internal::enable_if< ( (Rows ==1&&Depth!=1&&OA==ColMajor) || (Depth==1&&Rows !=1&&OA==RowMajor) @@ -78,7 +103,7 @@ void test_lazy_all_layout(int rows=Rows, int cols=Cols, int depth=Depth) CALL_SUBTEST(( test_lazy_single<T,Rows,Cols,Depth,RowMajor,ColMajor,RowMajor>(rows,cols,depth) )); CALL_SUBTEST(( test_lazy_single<T,Rows,Cols,Depth,ColMajor,RowMajor,RowMajor>(rows,cols,depth) )); CALL_SUBTEST(( test_lazy_single<T,Rows,Cols,Depth,RowMajor,RowMajor,RowMajor>(rows,cols,depth) )); -} +} template<typename T> void test_lazy_l1() @@ -291,6 +316,8 @@ EIGEN_DECLARE_TEST(product_small) CALL_SUBTEST_6( bug_1311<3>() ); CALL_SUBTEST_6( bug_1311<5>() ); + + CALL_SUBTEST_9( test_dynamic_exact<bool>() ); } CALL_SUBTEST_6( product_small_regressions<0>() ); |