Commit 3f542861 authored by Davis King's avatar Davis King

merged

parents 95182765 6afc9233
...@@ -34,6 +34,10 @@ namespace dlib ...@@ -34,6 +34,10 @@ namespace dlib
training data and it will output a new network instance that has hopefully training data and it will output a new network instance that has hopefully
learned something useful from your training data. learned something useful from your training data.
If you are compiling with CUDA then this object will use the GPU that is
currently selected (i.e. the one indicated by cudaGetDevice()) when
dnn_trainer is constructed. It will continue to use that device even if
you later change it by a call to cudaSetDevice().
!*/ !*/
public: public:
......
...@@ -1114,14 +1114,42 @@ namespace dlib ...@@ -1114,14 +1114,42 @@ namespace dlib
#ifdef DLIB_HAS_RVALUE_REFERENCES #ifdef DLIB_HAS_RVALUE_REFERENCES
matrix(matrix&& item) matrix(matrix&& item)
{ {
#ifdef MATLAB_MEX_FILE
// You can't move memory around when compiled in a matlab mex file and the
// different locations have different persistence settings.
if (data._private_is_persistent() == item.data._private_is_persistent())
{
swap(item);
}
else
{
data.set_size(item.nr(),item.nc());
matrix_assign(*this, item);
}
#else
swap(item); swap(item);
#endif
} }
matrix& operator= ( matrix& operator= (
matrix&& rhs matrix&& rhs
) )
{ {
#ifdef MATLAB_MEX_FILE
// You can't move memory around when compiled in a matlab mex file and the
// different locations have different persistence settings.
if (data._private_is_persistent() == rhs.data._private_is_persistent())
{
swap(rhs);
}
else
{
data.set_size(rhs.nr(),rhs.nc());
matrix_assign(*this, rhs);
}
#else
swap(rhs); swap(rhs);
#endif
return *this; return *this;
} }
#endif #endif
......
...@@ -188,6 +188,7 @@ namespace dlib ...@@ -188,6 +188,7 @@ namespace dlib
void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); } void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); }
mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); } mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); }
void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); } void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
bool _private_is_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
#endif #endif
private: private:
...@@ -257,6 +258,7 @@ namespace dlib ...@@ -257,6 +258,7 @@ namespace dlib
void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); } void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); }
mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); } mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); }
void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); } void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
bool _private_is_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
#endif #endif
private: private:
...@@ -338,6 +340,7 @@ namespace dlib ...@@ -338,6 +340,7 @@ namespace dlib
void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); } void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); }
mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); } mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); }
void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); } void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
bool _private_is_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
#endif #endif
private: private:
...@@ -422,6 +425,7 @@ namespace dlib ...@@ -422,6 +425,7 @@ namespace dlib
void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); } void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); }
mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); } mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); }
void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); } void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
bool _private_is_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
#endif #endif
private: private:
...@@ -508,6 +512,7 @@ namespace dlib ...@@ -508,6 +512,7 @@ namespace dlib
void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); } void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); }
mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); } mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); }
void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); } void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
bool _private_is_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
#endif #endif
private: private:
T* data; T* data;
...@@ -630,6 +635,7 @@ namespace dlib ...@@ -630,6 +635,7 @@ namespace dlib
void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); } void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); }
mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); } mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); }
void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); } void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
bool _private_is_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
#endif #endif
private: private:
...@@ -699,6 +705,7 @@ namespace dlib ...@@ -699,6 +705,7 @@ namespace dlib
void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); } void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); }
mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); } mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); }
void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); } void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
bool _private_is_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
#endif #endif
private: private:
...@@ -780,6 +787,7 @@ namespace dlib ...@@ -780,6 +787,7 @@ namespace dlib
void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); } void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); }
mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); } mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); }
void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); } void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
bool _private_is_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
#endif #endif
private: private:
...@@ -864,6 +872,7 @@ namespace dlib ...@@ -864,6 +872,7 @@ namespace dlib
void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); } void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); }
mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); } mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); }
void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); } void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
bool _private_is_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
#endif #endif
private: private:
...@@ -930,6 +939,7 @@ namespace dlib ...@@ -930,6 +939,7 @@ namespace dlib
void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); } void _private_set_mxArray ( mxArray* ) { DLIB_CASSERT(false, "This function should never be called."); }
mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); } mxArray* _private_release_mxArray(){DLIB_CASSERT(false, "This function should never be called."); }
void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); } void _private_mark_non_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
bool _private_is_persistent() {DLIB_CASSERT(false, "This function should never be called."); }
#endif #endif
long nr ( long nr (
...@@ -1031,6 +1041,10 @@ namespace dlib ...@@ -1031,6 +1041,10 @@ namespace dlib
DLIB_CASSERT(mem == 0,"You can't convert a persistent matlab array to non-persistent."); DLIB_CASSERT(mem == 0,"You can't convert a persistent matlab array to non-persistent.");
make_persistent = false; make_persistent = false;
} }
bool _private_is_persistent()
{
return make_persistent;
}
void swap( void swap(
layout& item layout& item
...@@ -1153,6 +1167,10 @@ namespace dlib ...@@ -1153,6 +1167,10 @@ namespace dlib
DLIB_CASSERT(mem == 0,"You can't convert a persistent matlab array to non-persistent."); DLIB_CASSERT(mem == 0,"You can't convert a persistent matlab array to non-persistent.");
make_persistent = false; make_persistent = false;
} }
bool _private_is_persistent()
{
return make_persistent;
}
void swap( void swap(
layout& item layout& item
......
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