提交 a30c5373 编写于 作者: S sneaxiy

use std::is_sorted

fix comment
test=develop
上级 b8051e79
......@@ -157,17 +157,9 @@ bool CheckLoD(const LoD &in, int tensor_height) {
if (level.size() < 2) return false;
// check: the first offset(the begin offset) of each level should be 0.
if (level.front() != 0) return false;
// check: all the offsets in a level should be ascending(no same items
// allows).
auto beg = level.begin();
auto end = level.end();
// Do not use std::is_sorted, because we need strictly sorted lod
if (beg != end) {
for (auto it = beg + 1; it != end; ++it) {
if (*(it - 1) >= *it) {
return false;
}
}
// check: all the offsets in a level should be ascending(allow same items)
if (!std::is_sorted(level.begin(), level.end())) {
return false;
}
}
// check: the lowest level's last offset should equals `tensor_height` if
......
......@@ -218,9 +218,10 @@ TEST(LoD, CheckLoD) {
ASSERT_TRUE(CheckLoD(relative_lod, 5));
ASSERT_FALSE(CheckLoD(relative_lod, 9));
// check strictly sorted lod
// check whether lod is ascending-sorted (allow same items)
ASSERT_TRUE(CheckLoD({{0, 1, 2, 3, 4, 5}}, 5));
ASSERT_FALSE(CheckLoD({{0, 1, 3, 3, 4, 5}}, 5));
ASSERT_TRUE(CheckLoD({{0, 1, 3, 3, 4, 5}}, 5));
ASSERT_FALSE(CheckLoD({{0, 1, 3, 2, 5}}, 5));
}
TEST(LoD, CheckAbsLoD) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册