Commit 21e3e81f authored by Davis King's avatar Davis King

Changed dot() so it doesn't call cublasSdot anymore since cublasSdot gives the

wrong outputs sometimes.
parent 24687a9e
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "cublas_dlibapi.h" #include "cublas_dlibapi.h"
#include "cuda_utils.h" #include "cuda_utils.h"
#include "tensor.h"
#include <cublas_v2.h> #include <cublas_v2.h>
...@@ -89,23 +88,6 @@ namespace dlib ...@@ -89,23 +88,6 @@ namespace dlib
return c.get_handle(); return c.get_handle();
} }
// -----------------------------------------------------------------------------------
float dot (
const tensor& a,
const tensor& b
)
{
DLIB_CASSERT(a.size() == b.size(), "");
float result = 0;
CHECK_CUBLAS(cublasSdot(context(),
a.size(),
a.device(), 1,
b.device(), 1,
&result));
return result;
}
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
void gemm ( void gemm (
......
...@@ -5,30 +5,14 @@ ...@@ -5,30 +5,14 @@
#ifdef DLIB_USE_CUDA #ifdef DLIB_USE_CUDA
#include "tensor.h"
#include "cuda_errors.h" #include "cuda_errors.h"
namespace dlib namespace dlib
{ {
class tensor;
namespace cuda namespace cuda
{ {
// -----------------------------------------------------------------------------------
float dot (
const tensor& a,
const tensor& b
);
/*!
requires
- a.size() == b.size()
ensures
- returns the dot product between a and b when they are both treated as
a.size() dimensional vectors. That is, this function pointwise
multiplies the vectors together, then sums the result and returns it.
!*/
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
void gemm ( void gemm (
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include <cstring> #include <cstring>
#include "../matrix.h" #include "../matrix.h"
#include "cudnn_dlibapi.h" #include "cudnn_dlibapi.h"
#include "cublas_dlibapi.h"
#include "gpu_data.h" #include "gpu_data.h"
#include <memory> #include <memory>
...@@ -408,9 +407,7 @@ namespace dlib ...@@ -408,9 +407,7 @@ namespace dlib
const tensor& b const tensor& b
) )
{ {
#ifdef DLIB_USE_CUDA // TODO, do on GPU?
return cuda::dot(a,b);
#else
DLIB_CASSERT(a.size() == b.size(), ""); DLIB_CASSERT(a.size() == b.size(), "");
const float* da = a.host(); const float* da = a.host();
const float* db = b.host(); const float* db = b.host();
...@@ -418,7 +415,6 @@ namespace dlib ...@@ -418,7 +415,6 @@ namespace dlib
for (size_t i = 0; i < a.size(); ++i) for (size_t i = 0; i < a.size(); ++i)
sum += da[i]*db[i]; sum += da[i]*db[i];
return sum; return sum;
#endif
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
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