aboutsummaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2021-03-25 16:56:57 +0000
committerArne Juul <arnej@verizonmedia.com>2021-03-25 16:56:57 +0000
commit33eaada44ae6117c1fccf45188b3c7aa45b75e00 (patch)
tree5830fe305b76fe2d2614608b1bc046143e1601bc /eval
parentea3383e5ebecf584f6f4406c4ec5568f5dd024aa (diff)
review follow-up:
* reorder enum and lists from largest to smallest cell type * add utilities for listing stable and ustable cell types (with simple test)
Diffstat (limited to 'eval')
-rw-r--r--eval/src/tests/eval/value_type/value_type_test.cpp12
-rw-r--r--eval/src/vespa/eval/eval/cell_type.cpp14
-rw-r--r--eval/src/vespa/eval/eval/cell_type.h4
3 files changed, 27 insertions, 3 deletions
diff --git a/eval/src/tests/eval/value_type/value_type_test.cpp b/eval/src/tests/eval/value_type/value_type_test.cpp
index 554cfba8c94..a2b25a12b4b 100644
--- a/eval/src/tests/eval/value_type/value_type_test.cpp
+++ b/eval/src/tests/eval/value_type/value_type_test.cpp
@@ -572,12 +572,22 @@ TEST("require that cell array size can be calculated") {
}
TEST("require that all cell types can be listed") {
- std::vector<CellType> expect = { CellType::INT8, CellType::BFLOAT16, CellType::FLOAT, CellType::DOUBLE };
+ std::vector<CellType> expect = { CellType::DOUBLE, CellType::FLOAT, CellType::BFLOAT16, CellType::INT8 };
+ std::vector<CellType> expect_stable;
+ std::vector<CellType> expect_unstable;
auto list = CellTypeUtils::list_types();
ASSERT_EQUAL(list.size(), expect.size());
for (size_t i = 0; i < list.size(); ++i) {
EXPECT_TRUE(list[i] == expect[i]);
+ CellMeta cm(expect[i], false);
+ if (cm.decay().eq(cm)) {
+ expect_stable.push_back(cm.cell_type);
+ } else {
+ expect_unstable.push_back(cm.cell_type);
+ }
}
+ EXPECT_TRUE(expect_stable == CellTypeUtils::list_stable_types());
+ EXPECT_TRUE(expect_unstable == CellTypeUtils::list_unstable_types());
}
TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/eval/src/vespa/eval/eval/cell_type.cpp b/eval/src/vespa/eval/eval/cell_type.cpp
index 95bbecaa6ee..94bd0b14573 100644
--- a/eval/src/vespa/eval/eval/cell_type.cpp
+++ b/eval/src/vespa/eval/eval/cell_type.cpp
@@ -33,7 +33,19 @@ CellTypeUtils::mem_size(CellType cell_type, size_t sz)
std::vector<CellType>
CellTypeUtils::list_types()
{
- return {CellType::INT8, CellType::BFLOAT16, CellType::FLOAT, CellType::DOUBLE};
+ return {CellType::DOUBLE, CellType::FLOAT, CellType::BFLOAT16, CellType::INT8 };
+}
+
+std::vector<CellType>
+CellTypeUtils::list_stable_types()
+{
+ return {CellType::DOUBLE, CellType::FLOAT};
+}
+
+std::vector<CellType>
+CellTypeUtils::list_unstable_types()
+{
+ return {CellType::BFLOAT16, CellType::INT8 };
}
}
diff --git a/eval/src/vespa/eval/eval/cell_type.h b/eval/src/vespa/eval/eval/cell_type.h
index 02e321ac744..79750c5c875 100644
--- a/eval/src/vespa/eval/eval/cell_type.h
+++ b/eval/src/vespa/eval/eval/cell_type.h
@@ -11,7 +11,7 @@
namespace vespalib::eval {
-enum class CellType : char { FLOAT, DOUBLE, BFLOAT16, INT8 };
+enum class CellType : char { DOUBLE, FLOAT, BFLOAT16, INT8 };
// converts actual cell type to CellType enum value
template <typename CT> constexpr CellType get_cell_type();
@@ -199,6 +199,8 @@ struct CellTypeUtils {
static uint32_t alignment(CellType cell_type);
static size_t mem_size(CellType cell_type, size_t sz);
static std::vector<CellType> list_types();
+ static std::vector<CellType> list_stable_types();
+ static std::vector<CellType> list_unstable_types();
};
} // namespace