multi-gpu training with sparse input.

ISSUE=4586833

git-svn-id: https://svn.baidu.com/idl/trunk/paddle@1429 1ad973e4-5ce8-4261-8a94-b56d1f490c56
avx_docs
hedaoyuan 9 years ago
parent 20b1f3fe30
commit 2afe66093a

@ -14,6 +14,7 @@ limitations under the License. */
#include "Argument.h"
#include "paddle/math/SparseMatrix.h"
#include <algorithm>
@ -68,7 +69,15 @@ static void resizeAndCopy(MatrixPtr& dest, const MatrixPtr& src,
dest->resize(height, width);
}
MatrixPtr submat = src->subMatrix(startRow, copySize);
dest->copyFrom(*submat, stream);
if (dynamic_cast<GpuSparseMatrix*>(dest.get())) {
// copy a subMatrix of CpuSparseMatrix to GpuSparseMatrix.
// First copy it to CPU, and then copy it to the GPU.
MatrixPtr tmp = src->clone(height, width, false);
tmp->copyFrom(*submat, stream);
dest->copyFrom(*tmp, stream);
} else {
dest->copyFrom(*submat, stream);
}
} else {
dest.reset();
}

Loading…
Cancel
Save