Commit e2a67dec authored by Davis King's avatar Davis King

Added more gemm() tests

parent fb6c59e4
......@@ -74,6 +74,18 @@ namespace
cuda::gemm(2, c, 1, a, false, b, true);
DLIB_TEST(max(abs(truth-mat(c))) < 1e-6);
}
{
resizable_tensor a(3,4), b(3,4), c(3,3);
c = 1;
a = matrix_cast<float>(gaussian_randm(a.num_samples(),a.size()/a.num_samples()));
b = matrix_cast<float>(gaussian_randm(b.num_samples(),b.size()/b.num_samples()));
matrix<float> truth = mat(c)+mat(a)*trans(mat(b));
cuda::gemm(1, c, 1, a, false, b, true);
DLIB_TEST(max(abs(truth-mat(c))) < 1e-6);
}
{
resizable_tensor a(3,4), b(4,3), c(3,3);
......@@ -86,6 +98,18 @@ namespace
cuda::gemm(2, c, 1, a, false, b, false);
DLIB_TEST(max(abs(truth-mat(c))) < 1e-6);
}
{
resizable_tensor a(3,4), b(4,3), c(3,3);
c = std::numeric_limits<float>::infinity();
a = matrix_cast<float>(gaussian_randm(a.num_samples(),a.size()/a.num_samples()));
b = matrix_cast<float>(gaussian_randm(b.num_samples(),b.size()/b.num_samples()));
matrix<float> truth = mat(a)*mat(b);
cuda::gemm(0, c, 1, a, false, b, false);
DLIB_TEST(max(abs(truth-mat(c))) < 1e-6);
}
{
resizable_tensor a(3,4), b(4,4), c(3,4);
......@@ -125,6 +149,19 @@ namespace
DLIB_TEST(get_rect(truth) == get_rect(mat(c)));
DLIB_TEST(max(abs(truth-mat(c))) < 1e-6);
}
{
resizable_tensor a(4,3), b(4,5), c(3,5);
c = std::numeric_limits<float>::infinity();
a = matrix_cast<float>(gaussian_randm(a.num_samples(),a.size()/a.num_samples()));
b = matrix_cast<float>(gaussian_randm(b.num_samples(),b.size()/b.num_samples()));
matrix<float> truth = trans(mat(a))*mat(b);
cuda::gemm(0, c, 1, a, true, b, false);
DLIB_TEST(get_rect(truth) == get_rect(mat(c)));
DLIB_TEST(max(abs(truth-mat(c))) < 1e-6);
}
}
} a;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment