summaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorArne H Juul <arnej27959@users.noreply.github.com>2020-11-20 08:28:15 +0100
committerGitHub <noreply@github.com>2020-11-20 08:28:15 +0100
commit3f608915e0398da415a9a48934e27fcbb8124c39 (patch)
tree36123b9844c569fd7c4a1b6863efe06ef7a05db3 /eval
parentb7f88b27a8e2183981a8bc8966f181e816e0dc56 (diff)
parentc120f133f9a4497b55271043cc50e13966b585e9 (diff)
Merge pull request #15391 from vespa-engine/arnej/move-celltype-out-1
move CellType up to eval namespace
Diffstat (limited to 'eval')
-rw-r--r--eval/src/vespa/eval/eval/CMakeLists.txt1
-rw-r--r--eval/src/vespa/eval/eval/cell_type.cpp3
-rw-r--r--eval/src/vespa/eval/eval/cell_type.h39
-rw-r--r--eval/src/vespa/eval/eval/value_type.h31
4 files changed, 45 insertions, 29 deletions
diff --git a/eval/src/vespa/eval/eval/CMakeLists.txt b/eval/src/vespa/eval/eval/CMakeLists.txt
index d27de8e3d21..5cf7440237b 100644
--- a/eval/src/vespa/eval/eval/CMakeLists.txt
+++ b/eval/src/vespa/eval/eval/CMakeLists.txt
@@ -5,6 +5,7 @@ vespa_add_library(eval_eval OBJECT
array_array_map.cpp
basic_nodes.cpp
call_nodes.cpp
+ cell_type.cpp
compile_tensor_function.cpp
delete_node.cpp
double_value_builder.cpp
diff --git a/eval/src/vespa/eval/eval/cell_type.cpp b/eval/src/vespa/eval/eval/cell_type.cpp
new file mode 100644
index 00000000000..e5729c547b0
--- /dev/null
+++ b/eval/src/vespa/eval/eval/cell_type.cpp
@@ -0,0 +1,3 @@
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "cell_type.h"
diff --git a/eval/src/vespa/eval/eval/cell_type.h b/eval/src/vespa/eval/eval/cell_type.h
new file mode 100644
index 00000000000..0e878f26f47
--- /dev/null
+++ b/eval/src/vespa/eval/eval/cell_type.h
@@ -0,0 +1,39 @@
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include <vespa/vespalib/util/typify.h>
+#include <cstdlib>
+
+namespace vespalib::eval {
+
+enum class CellType : char { FLOAT, DOUBLE };
+
+// utility templates
+
+template <typename CT> inline bool check_cell_type(CellType type);
+template <> inline bool check_cell_type<double>(CellType type) { return (type == CellType::DOUBLE); }
+template <> inline bool check_cell_type<float>(CellType type) { return (type == CellType::FLOAT); }
+
+template <typename LCT, typename RCT> struct UnifyCellTypes{};
+template <> struct UnifyCellTypes<double, double> { using type = double; };
+template <> struct UnifyCellTypes<double, float> { using type = double; };
+template <> struct UnifyCellTypes<float, double> { using type = double; };
+template <> struct UnifyCellTypes<float, float> { using type = float; };
+
+template <typename CT> inline CellType get_cell_type();
+template <> inline CellType get_cell_type<double>() { return CellType::DOUBLE; }
+template <> inline CellType get_cell_type<float>() { return CellType::FLOAT; }
+
+struct TypifyCellType {
+ template <typename T> using Result = TypifyResultType<T>;
+ template <typename F> static decltype(auto) resolve(CellType value, F &&f) {
+ switch(value) {
+ case CellType::DOUBLE: return f(Result<double>());
+ case CellType::FLOAT: return f(Result<float>());
+ }
+ abort();
+ }
+};
+
+} // namespace
diff --git a/eval/src/vespa/eval/eval/value_type.h b/eval/src/vespa/eval/eval/value_type.h
index 38f4705edf2..ae69b5a3349 100644
--- a/eval/src/vespa/eval/eval/value_type.h
+++ b/eval/src/vespa/eval/eval/value_type.h
@@ -2,7 +2,7 @@
#pragma once
-#include <vespa/vespalib/util/typify.h>
+#include "cell_type.h"
#include <vespa/vespalib/stllike/string.h>
#include <vector>
@@ -16,7 +16,7 @@ namespace vespalib::eval {
class ValueType
{
public:
- enum class CellType : char { FLOAT, DOUBLE };
+ using CellType = vespalib::eval::CellType;
struct Dimension {
using size_type = uint32_t;
static constexpr size_type npos = -1;
@@ -110,31 +110,4 @@ public:
std::ostream &operator<<(std::ostream &os, const ValueType &type);
-// utility templates
-
-template <typename CT> inline bool check_cell_type(ValueType::CellType type);
-template <> inline bool check_cell_type<double>(ValueType::CellType type) { return (type == ValueType::CellType::DOUBLE); }
-template <> inline bool check_cell_type<float>(ValueType::CellType type) { return (type == ValueType::CellType::FLOAT); }
-
-template <typename LCT, typename RCT> struct UnifyCellTypes{};
-template <> struct UnifyCellTypes<double, double> { using type = double; };
-template <> struct UnifyCellTypes<double, float> { using type = double; };
-template <> struct UnifyCellTypes<float, double> { using type = double; };
-template <> struct UnifyCellTypes<float, float> { using type = float; };
-
-template <typename CT> inline ValueType::CellType get_cell_type();
-template <> inline ValueType::CellType get_cell_type<double>() { return ValueType::CellType::DOUBLE; }
-template <> inline ValueType::CellType get_cell_type<float>() { return ValueType::CellType::FLOAT; }
-
-struct TypifyCellType {
- template <typename T> using Result = TypifyResultType<T>;
- template <typename F> static decltype(auto) resolve(ValueType::CellType value, F &&f) {
- switch(value) {
- case ValueType::CellType::DOUBLE: return f(Result<double>());
- case ValueType::CellType::FLOAT: return f(Result<float>());
- }
- abort();
- }
-};
-
} // namespace