Commit 9cbbe7b7 authored by Davis King's avatar Davis King

Made a tensor iterable

parent 00e18a8d
...@@ -35,6 +35,13 @@ namespace dlib ...@@ -35,6 +35,13 @@ namespace dlib
long nc() const { return m_nc; } long nc() const { return m_nc; }
size_t size() const { return data.size(); } size_t size() const { return data.size(); }
typedef float* iterator;
typedef const float* const_iterator;
iterator begin() { return host(); }
const_iterator begin() const { return host(); }
iterator end() { return host()+size(); }
const_iterator end() const { return host()+size(); }
void async_copy_to_device() const void async_copy_to_device() const
{ {
data.async_copy_to_device(); data.async_copy_to_device();
......
...@@ -98,6 +98,17 @@ namespace dlib ...@@ -98,6 +98,17 @@ namespace dlib
async_copy_to_device() and then immediately call device(). async_copy_to_device() and then immediately call device().
!*/ !*/
typedef float* iterator;
typedef const float* const_iterator;
iterator begin() { return host(); }
const_iterator begin() const { return host(); }
iterator end() { return host()+size(); }
const_iterator end() const { return host()+size(); }
/*!
ensures
- makes a tensor iterable just like the STL containers.
!*/
const float* host( const float* host(
) const; ) const;
/*! /*!
......
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