From a5494fa82621f9205b7f2873a21e311eb8de03d0 Mon Sep 17 00:00:00 2001 From: hedaoyuan Date: Tue, 31 Oct 2017 21:03:31 +0800 Subject: [PATCH] Remove SparseRowMatrix in mobile inference. --- paddle/math/SparseRowMatrix.h | 26 ++++++++++++++++++++++++++ paddle/parameter/Parameter.cpp | 8 ++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/paddle/math/SparseRowMatrix.h b/paddle/math/SparseRowMatrix.h index 8704eb038d..ca7a6806da 100644 --- a/paddle/math/SparseRowMatrix.h +++ b/paddle/math/SparseRowMatrix.h @@ -14,6 +14,8 @@ limitations under the License. */ #pragma once +#ifndef PADDLE_MOBILE_INFERENCE + #include #include #include @@ -313,3 +315,27 @@ private: }; } // namespace paddle + +#else +namespace paddle { + +class SparseRowCpuMatrix : public CpuMatrix { +public: + void reserveStore() {} + void clearIndices() {} +}; + +class SparsePrefetchRowCpuMatrix : public SparseRowCpuMatrix { +public: + void setupIndices() {} + void addRows(MatrixPtr input) {} + void addRows(IVectorPtr ids) {} +}; + +class SparseAutoGrowRowCpuMatrix : public SparseRowCpuMatrix {}; +class CacheRowCpuMatrix : public SparseAutoGrowRowCpuMatrix {}; +class SparseRowIdsCpuMatrix : public CpuMatrix {}; + +} // namespace paddle + +#endif diff --git a/paddle/parameter/Parameter.cpp b/paddle/parameter/Parameter.cpp index f031109501..449afe306f 100644 --- a/paddle/parameter/Parameter.cpp +++ b/paddle/parameter/Parameter.cpp @@ -217,7 +217,9 @@ void Parameter::setMat(ParameterType pType, int matType) { bufs_[pType]->getMemoryHandle()), height, width); - } else if (matType == MAT_SPARSE_ROW_IDS) { + } +#ifndef PADDLE_MOBILE_INFERENCE + else if (matType == MAT_SPARSE_ROW_IDS) { CHECK_EQ(height * width, bufs_[pType]->getSize()); mats_[pType] = std::make_shared( std::dynamic_pointer_cast( @@ -259,7 +261,9 @@ void Parameter::setMat(ParameterType pType, int matType) { } else if (matType == MAT_SPARSE_ROW_AUTO_GROW) { CHECK(isGradSparseUpdate()); mats_[pType] = std::make_shared(height, width); - } else { + } +#endif + else { LOG(FATAL) << "Unsupported mat type" << matType; } } -- GitLab