提交 a94e2574 编写于 作者: Q qiaolongfei

optimize code

上级 6fff0d4d
...@@ -30,12 +30,12 @@ using LoDTensor = framework::LoDTensor; ...@@ -30,12 +30,12 @@ using LoDTensor = framework::LoDTensor;
using SelectedRows = framework::SelectedRows; using SelectedRows = framework::SelectedRows;
using DDim = framework::DDim; using DDim = framework::DDim;
static const int64_t kNoPadding = -1; static constexpr int64_t kNoPadding = -1;
inline size_t getIndex(const std::vector<int64_t> &rows, int64_t value) { inline size_t getIndex(const std::vector<int64_t> &rows, int64_t value) {
auto it = std::find(rows.begin(), rows.end(), value); auto it = std::find(rows.begin(), rows.end(), value);
PADDLE_ENFORCE(it != rows.end(), "id should be in rows"); PADDLE_ENFORCE(it != rows.end(), "id should be in rows");
return std::distance(rows.begin(), it); return static_cast<size_t>(std::distance(rows.begin(), it));
} }
template <typename T> template <typename T>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册