Skip to content

Commit a5494fa

Browse files
committed
Remove SparseRowMatrix in mobile inference.
1 parent f122a5d commit a5494fa

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

paddle/math/SparseRowMatrix.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ limitations under the License. */
1414

1515
#pragma once
1616

17+
#ifndef PADDLE_MOBILE_INFERENCE
18+
1719
#include <gflags/gflags.h>
1820
#include <string.h>
1921
#include <algorithm>
@@ -313,3 +315,27 @@ class SparseRowIdsCpuMatrix : public CpuMatrix {
313315
};
314316

315317
} // namespace paddle
318+
319+
#else
320+
namespace paddle {
321+
322+
class SparseRowCpuMatrix : public CpuMatrix {
323+
public:
324+
void reserveStore() {}
325+
void clearIndices() {}
326+
};
327+
328+
class SparsePrefetchRowCpuMatrix : public SparseRowCpuMatrix {
329+
public:
330+
void setupIndices() {}
331+
void addRows(MatrixPtr input) {}
332+
void addRows(IVectorPtr ids) {}
333+
};
334+
335+
class SparseAutoGrowRowCpuMatrix : public SparseRowCpuMatrix {};
336+
class CacheRowCpuMatrix : public SparseAutoGrowRowCpuMatrix {};
337+
class SparseRowIdsCpuMatrix : public CpuMatrix {};
338+
339+
} // namespace paddle
340+
341+
#endif

paddle/parameter/Parameter.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ void Parameter::setMat(ParameterType pType, int matType) {
217217
bufs_[pType]->getMemoryHandle()),
218218
height,
219219
width);
220-
} else if (matType == MAT_SPARSE_ROW_IDS) {
220+
}
221+
#ifndef PADDLE_MOBILE_INFERENCE
222+
else if (matType == MAT_SPARSE_ROW_IDS) {
221223
CHECK_EQ(height * width, bufs_[pType]->getSize());
222224
mats_[pType] = std::make_shared<SparseRowIdsCpuMatrix>(
223225
std::dynamic_pointer_cast<CpuMemoryHandle>(
@@ -259,7 +261,9 @@ void Parameter::setMat(ParameterType pType, int matType) {
259261
} else if (matType == MAT_SPARSE_ROW_AUTO_GROW) {
260262
CHECK(isGradSparseUpdate());
261263
mats_[pType] = std::make_shared<SparseAutoGrowRowCpuMatrix>(height, width);
262-
} else {
264+
}
265+
#endif
266+
else {
263267
LOG(FATAL) << "Unsupported mat type" << matType;
264268
}
265269
}

0 commit comments

Comments
 (0)