提交 a5494fa8 编写于 作者: H hedaoyuan

Remove SparseRowMatrix in mobile inference.

上级 f122a5da
...@@ -14,6 +14,8 @@ limitations under the License. */ ...@@ -14,6 +14,8 @@ limitations under the License. */
#pragma once #pragma once
#ifndef PADDLE_MOBILE_INFERENCE
#include <gflags/gflags.h> #include <gflags/gflags.h>
#include <string.h> #include <string.h>
#include <algorithm> #include <algorithm>
...@@ -313,3 +315,27 @@ private: ...@@ -313,3 +315,27 @@ private:
}; };
} // namespace paddle } // 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
...@@ -217,7 +217,9 @@ void Parameter::setMat(ParameterType pType, int matType) { ...@@ -217,7 +217,9 @@ void Parameter::setMat(ParameterType pType, int matType) {
bufs_[pType]->getMemoryHandle()), bufs_[pType]->getMemoryHandle()),
height, height,
width); 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()); CHECK_EQ(height * width, bufs_[pType]->getSize());
mats_[pType] = std::make_shared<SparseRowIdsCpuMatrix>( mats_[pType] = std::make_shared<SparseRowIdsCpuMatrix>(
std::dynamic_pointer_cast<CpuMemoryHandle>( std::dynamic_pointer_cast<CpuMemoryHandle>(
...@@ -259,7 +261,9 @@ void Parameter::setMat(ParameterType pType, int matType) { ...@@ -259,7 +261,9 @@ void Parameter::setMat(ParameterType pType, int matType) {
} else if (matType == MAT_SPARSE_ROW_AUTO_GROW) { } else if (matType == MAT_SPARSE_ROW_AUTO_GROW) {
CHECK(isGradSparseUpdate()); CHECK(isGradSparseUpdate());
mats_[pType] = std::make_shared<SparseAutoGrowRowCpuMatrix>(height, width); mats_[pType] = std::make_shared<SparseAutoGrowRowCpuMatrix>(height, width);
} else { }
#endif
else {
LOG(FATAL) << "Unsupported mat type" << matType; LOG(FATAL) << "Unsupported mat type" << matType;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册