Skip to content

Commit 2368377

Browse files
committed
Bug fix.
1 parent 6a14f52 commit 2368377

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

paddle/math/tests/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
add_simple_unittest(test_ExecViaCpu)
44
add_simple_unittest(test_SIMDFunctions)
55
add_simple_unittest(test_TrainingAlgorithm)
6-
add_simple_unittest(test_SparseMatrix)
76
add_simple_unittest(test_RowBuffer)
7+
if(NOT MOBILE_INFERENCE)
8+
add_simple_unittest(test_SparseMatrix)
9+
endif()
810

911
# TODO(yuyang18): Refactor TestUtil.cpp. Remove this cross module reference.
1012
add_unittest(test_matrixCompare

paddle/parameter/Parameter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ void Parameter::setMat(ParameterType pType, int matType) {
200200
false,
201201
useGpu_);
202202
}
203-
} else if (matType == MAT_NORMAL_SHARED) {
203+
}
204+
#ifndef PADDLE_MOBILE_INFERENCE
205+
else if (matType == MAT_NORMAL_SHARED) {
204206
CHECK_EQ(height * width, bufs_[pType]->getSize());
205207
size_t blockNum = 0;
206208
CHECK(isGradShared(&blockNum));
@@ -217,9 +219,7 @@ void Parameter::setMat(ParameterType pType, int matType) {
217219
bufs_[pType]->getMemoryHandle()),
218220
height,
219221
width);
220-
}
221-
#ifndef PADDLE_MOBILE_INFERENCE
222-
else if (matType == MAT_SPARSE_ROW_IDS) {
222+
} else if (matType == MAT_SPARSE_ROW_IDS) {
223223
CHECK_EQ(height * width, bufs_[pType]->getSize());
224224
mats_[pType] = std::make_shared<SparseRowIdsCpuMatrix>(
225225
std::dynamic_pointer_cast<CpuMemoryHandle>(

paddle/testing/TestUtil.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ MatrixPtr makeRandomSparseMatrix(size_t height,
3333
bool withValue,
3434
bool useGpu,
3535
bool equalNnzPerSample) {
36+
#ifndef PADDLE_MOBILE_INFERENCE
3637
std::vector<int64_t> ids(height);
3738
std::vector<int64_t> indices(height + 1);
3839
indices[0] = 0;
@@ -84,6 +85,8 @@ MatrixPtr makeRandomSparseMatrix(size_t height,
8485
}
8586
return mat;
8687
}
88+
#endif
89+
return nullptr;
8790
}
8891

8992
void generateSequenceStartPositions(size_t batchSize,

0 commit comments

Comments
 (0)