summaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorHaavard <havardpe@yahoo-inc.com>2017-06-23 11:54:21 +0000
committerHaavard <havardpe@yahoo-inc.com>2017-06-23 11:54:21 +0000
commit37646b3997d5da17b6ff793b5b5efd1a4a3cf3a2 (patch)
tree452cc28744561a5cfa049bd9d08b28345317dc25 /eval
parent9f9197329379b633a103d58d6cf0d1cda0ac260b (diff)
support tensor results
Diffstat (limited to 'eval')
-rw-r--r--eval/src/apps/eval_expr/eval_expr.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/eval/src/apps/eval_expr/eval_expr.cpp b/eval/src/apps/eval_expr/eval_expr.cpp
index bc2d2ba8952..5200e37fe5e 100644
--- a/eval/src/apps/eval_expr/eval_expr.cpp
+++ b/eval/src/apps/eval_expr/eval_expr.cpp
@@ -2,6 +2,8 @@
#include <vespa/eval/eval/function.h>
#include <vespa/eval/eval/interpreted_function.h>
+#include <vespa/eval/eval/tensor_spec.h>
+
using namespace vespalib::eval;
@@ -21,7 +23,14 @@ int main(int argc, char **argv) {
InterpretedFunction interpreted(SimpleTensorEngine::ref(), function, NodeTypes());
InterpretedFunction::Context ctx(interpreted);
InterpretedFunction::SimpleParams params({});
- double result = interpreted.eval(ctx, params).as_double();
- fprintf(stdout, "%.32g\n", result);
+ const Value &result = interpreted.eval(ctx, params);
+ if (result.is_double()) {
+ fprintf(stdout, "%.32g\n", result.as_double());
+ } else if (result.is_tensor()) {
+ vespalib::string str = SimpleTensorEngine::ref().to_spec(*result.as_tensor()).to_string();
+ fprintf(stdout, "%s\n", str.c_str());
+ } else {
+ fprintf(stdout, "error\n");
+ }
return 0;
}