Commit 99e948db authored by Davis King's avatar Davis King

Added tensor spec.

parent 37d493e2
...@@ -16,23 +16,23 @@ namespace dlib ...@@ -16,23 +16,23 @@ namespace dlib
/*! /*!
WHAT THIS OBJECT REPRESENTS WHAT THIS OBJECT REPRESENTS
This object is a block of size() floats, all stored contiguously in memory. This object is a block of size() floats, all stored contiguously in memory.
In particular, it keeps two copies of the floats, one on the host CPU side Importantly, it keeps two copies of the floats, one on the host CPU side
and another on the GPU device side. It automatically performs the necessary and another on the GPU device side. It automatically performs the necessary
host/device transfers to keep these two copies of the data in sync. host/device transfers to keep these two copies of the data in sync.
All transfers to the device happen asynchronously so that CUDA kernel All transfers to the device happen asynchronously with respect to the
computations can overlap with data transfers. However, any transfers from default CUDA stream so that CUDA kernel computations can overlap with data
the device to the host happen synchronously in the default CUDA stream. transfers. However, any transfers from the device to the host happen
Therefore, you should perform all your CUDA kernel launches on the default synchronously in the default CUDA stream. Therefore, you should perform
stream so that transfers back to the host do not happen before the all your CUDA kernel launches on the default stream so that transfers back
computations have completed. to the host do not happen before the relevant computations have completed.
If DLIB_USE_CUDA is not #defined then this object will not use CUDA at all. If DLIB_USE_CUDA is not #defined then this object will not use CUDA at all.
Instead, it will simply store one host side memory block of floats. Instead, it will simply store one host side memory block of floats.
THREAD SAFETY THREAD SAFETY
This object is not thread-safe. Don't touch it from multiple threads at Instances of this object are not thread-safe. So don't touch one from
the same time. multiple threads at the same time.
!*/ !*/
public: public:
......
...@@ -367,6 +367,7 @@ namespace dlib ...@@ -367,6 +367,7 @@ namespace dlib
const tensor& b const tensor& b
) )
{ {
// TODO, do on GPU?
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();
......
This diff is collapsed.
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