Skip to content

Commit

Permalink
deepSwap
Browse files Browse the repository at this point in the history
  • Loading branch information
xutianbing committed Nov 29, 2016
1 parent fc32721 commit cf205d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions paddle/math/BaseMatrix.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,12 @@ void BaseMatrixT<T>::assignAtOffset(BaseMatrixT& b, int64_t columnOffset) {
}
}

DEFINE_MATRIX_BINARY_OP(DeepSwap, T tmp = a; a = b; b = tmp);
template<class T>
void BaseMatrixT<T>::deepSwap(BaseMatrixT& b) {
applyBinary(binary::DeepSwap<T>(), b);
}

template<>
void BaseMatrixT<real>::rowDotMul(size_t destCol,
BaseMatrixT& b,
Expand Down
7 changes: 7 additions & 0 deletions paddle/math/BaseMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,13 @@ class BaseMatrixT {
*/
void assign(T p);

/**
* @code
* swap(this, b)
* @endcode
*/
void deepSwap(BaseMatrixT& b);

/**
* @code
* this = this + p
Expand Down

0 comments on commit cf205d0

Please sign in to comment.