提交 2afe6609 编写于 作者: H hedaoyuan

multi-gpu training with sparse input.

ISSUE=4586833

git-svn-id: https://svn.baidu.com/idl/trunk/paddle@1429 1ad973e4-5ce8-4261-8a94-b56d1f490c56
上级 20b1f3fe
...@@ -14,6 +14,7 @@ limitations under the License. */ ...@@ -14,6 +14,7 @@ limitations under the License. */
#include "Argument.h" #include "Argument.h"
#include "paddle/math/SparseMatrix.h"
#include <algorithm> #include <algorithm>
...@@ -68,7 +69,15 @@ static void resizeAndCopy(MatrixPtr& dest, const MatrixPtr& src, ...@@ -68,7 +69,15 @@ static void resizeAndCopy(MatrixPtr& dest, const MatrixPtr& src,
dest->resize(height, width); dest->resize(height, width);
} }
MatrixPtr submat = src->subMatrix(startRow, copySize); 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 { } else {
dest.reset(); dest.reset();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册