Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
e2a67dec
"git@developer.sourcefind.cn:OpenDAS/dlib.git" did not exist on "310478521be031afd7d972d29895c75ad0e82a15"
Commit
e2a67dec
authored
Nov 21, 2015
by
Davis King
Browse files
Added more gemm() tests
parent
fb6c59e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
dlib/test/cublas.cpp
dlib/test/cublas.cpp
+37
-0
No files found.
dlib/test/cublas.cpp
View file @
e2a67dec
...
@@ -74,6 +74,18 @@ namespace
...
@@ -74,6 +74,18 @@ namespace
cuda
::
gemm
(
2
,
c
,
1
,
a
,
false
,
b
,
true
);
cuda
::
gemm
(
2
,
c
,
1
,
a
,
false
,
b
,
true
);
DLIB_TEST
(
max
(
abs
(
truth
-
mat
(
c
)))
<
1e-6
);
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
);
resizable_tensor
a
(
3
,
4
),
b
(
4
,
3
),
c
(
3
,
3
);
...
@@ -86,6 +98,18 @@ namespace
...
@@ -86,6 +98,18 @@ namespace
cuda
::
gemm
(
2
,
c
,
1
,
a
,
false
,
b
,
false
);
cuda
::
gemm
(
2
,
c
,
1
,
a
,
false
,
b
,
false
);
DLIB_TEST
(
max
(
abs
(
truth
-
mat
(
c
)))
<
1e-6
);
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
);
resizable_tensor
a
(
3
,
4
),
b
(
4
,
4
),
c
(
3
,
4
);
...
@@ -125,6 +149,19 @@ namespace
...
@@ -125,6 +149,19 @@ namespace
DLIB_TEST
(
get_rect
(
truth
)
==
get_rect
(
mat
(
c
)));
DLIB_TEST
(
get_rect
(
truth
)
==
get_rect
(
mat
(
c
)));
DLIB_TEST
(
max
(
abs
(
truth
-
mat
(
c
)))
<
1e-6
);
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
;
}
a
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment