summaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2017-10-26 08:51:40 +0000
committerHåvard Pettersen <havardpe@oath.com>2017-10-26 08:51:40 +0000
commit5ae6c1e24bbe54daa705d646774d4d90a48dd971 (patch)
tree8fc5ff4fdf3bcbbc4ddcbe7801e07dc042e17582 /eval
parent106567609a5b0efc3285187582acf45a0899b5ef (diff)
it is not allowed to reduce over a non-existing dimension
Diffstat (limited to 'eval')
-rw-r--r--eval/src/vespa/eval/tensor/default_tensor_engine.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/eval/src/vespa/eval/tensor/default_tensor_engine.cpp b/eval/src/vespa/eval/tensor/default_tensor_engine.cpp
index 6a536497bdd..b004ce5bfde 100644
--- a/eval/src/vespa/eval/tensor/default_tensor_engine.cpp
+++ b/eval/src/vespa/eval/tensor/default_tensor_engine.cpp
@@ -288,9 +288,13 @@ const Value &
DefaultTensorEngine::reduce(const Value &a, Aggr aggr, const std::vector<vespalib::string> &dimensions, Stash &stash) const
{
if (a.is_double()) {
- Aggregator &aggregator = Aggregator::create(aggr, stash);
- aggregator.first(a.as_double());
- return stash.create<DoubleValue>(aggregator.result());
+ if (dimensions.empty()) {
+ Aggregator &aggregator = Aggregator::create(aggr, stash);
+ aggregator.first(a.as_double());
+ return stash.create<DoubleValue>(aggregator.result());
+ } else {
+ return ErrorValue::instance;
+ }
} else if (auto tensor = a.as_tensor()) {
assert(&tensor->engine() == this);
const tensor::Tensor &my_a = static_cast<const tensor::Tensor &>(*tensor);