aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eval/src/vespa/eval/eval/simple_value.cpp20
-rw-r--r--eval/src/vespa/eval/eval/simple_value.h10
2 files changed, 29 insertions, 1 deletions
diff --git a/eval/src/vespa/eval/eval/simple_value.cpp b/eval/src/vespa/eval/eval/simple_value.cpp
index 17faa635941..113f89f77fb 100644
--- a/eval/src/vespa/eval/eval/simple_value.cpp
+++ b/eval/src/vespa/eval/eval/simple_value.cpp
@@ -2,6 +2,8 @@
#include "simple_value.h"
#include "inline_operation.h"
+#include "value_codec.h"
+#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/vespalib/util/typify.h>
#include <vespa/vespalib/stllike/hash_map.hpp>
@@ -203,6 +205,24 @@ SimpleValue::create_view(const std::vector<size_t> &dims) const
}
}
+std::unique_ptr<Value>
+SimpleValue::from_spec(const TensorSpec &spec)
+{
+ return value_from_spec(spec, SimpleValueBuilderFactory::get());
+}
+
+std::unique_ptr<Value>
+SimpleValue::from_value(const Value& value)
+{
+ return from_spec(spec_from_value(value));
+}
+
+std::unique_ptr<Value>
+SimpleValue::from_stream(nbostream &stream)
+{
+ return decode_value(stream, SimpleValueBuilderFactory::get());
+}
+
//-----------------------------------------------------------------------------
template <typename T>
diff --git a/eval/src/vespa/eval/eval/simple_value.h b/eval/src/vespa/eval/eval/simple_value.h
index a8e84a95419..590c0b4ef16 100644
--- a/eval/src/vespa/eval/eval/simple_value.h
+++ b/eval/src/vespa/eval/eval/simple_value.h
@@ -7,10 +7,15 @@
#include <vector>
#include <map>
-namespace vespalib { class Stash; }
+namespace vespalib {
+class Stash;
+class nbostream;
+}
namespace vespalib::eval {
+class TensorSpec;
+
/**
* A simple implementation of a generic value that can also be used to
* build new values. This class focuses on simplicity over speed and
@@ -39,6 +44,9 @@ public:
const Value::Index &index() const override { return *this; }
size_t size() const override { return _index.size(); }
std::unique_ptr<View> create_view(const std::vector<size_t> &dims) const override;
+ static Value::UP from_spec(const TensorSpec &spec);
+ static Value::UP from_value(const Value &value);
+ static Value::UP from_stream(nbostream &stream);
};
/**