aboutsummaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2018-03-05 10:30:06 +0000
committerHåvard Pettersen <havardpe@oath.com>2018-03-05 10:30:06 +0000
commitc57ab80840bf7eceea7eca3773841b0914c9246a (patch)
tree768874dca8bd4bf39c11521efc1155ae89676a7d /eval
parentaca4faecd8e5e2c28dbfd1db9ae9116792098020 (diff)
appropriately tag various tensor function nodes as mutable (or not)
Diffstat (limited to 'eval')
-rw-r--r--eval/src/vespa/eval/eval/tensor_function.h13
-rw-r--r--eval/src/vespa/eval/tensor/dense/dense_dot_product_function.h1
-rw-r--r--eval/src/vespa/eval/tensor/dense/dense_fast_rename_function.h1
-rw-r--r--eval/src/vespa/eval/tensor/dense/vector_from_doubles_function.h1
4 files changed, 15 insertions, 1 deletions
diff --git a/eval/src/vespa/eval/eval/tensor_function.h b/eval/src/vespa/eval/eval/tensor_function.h
index 35f4e8073b3..4e989d251c1 100644
--- a/eval/src/vespa/eval/eval/tensor_function.h
+++ b/eval/src/vespa/eval/eval/tensor_function.h
@@ -69,7 +69,7 @@ struct TensorFunction
void set(const TensorFunction &child) const { ptr = &child; }
};
virtual const ValueType &result_type() const = 0;
- virtual bool result_is_mutable() const { return false; }
+ virtual bool result_is_mutable() const = 0;
/**
* Push references to all children (NB: implementation must use
@@ -162,6 +162,7 @@ private:
const Value &_value;
public:
ConstValue(const Value &value_in) : Leaf(value_in.type()), _value(value_in) {}
+ bool result_is_mutable() const override { return false; }
InterpretedFunction::Instruction compile_self(Stash &stash) const final override;
};
@@ -175,6 +176,7 @@ public:
Inject(const ValueType &result_type_in, size_t param_idx_in)
: Leaf(result_type_in), _param_idx(param_idx_in) {}
size_t param_idx() const { return _param_idx; }
+ bool result_is_mutable() const override { return false; }
InterpretedFunction::Instruction compile_self(Stash &stash) const final override;
};
@@ -193,6 +195,7 @@ public:
: Op1(result_type_in, child_in), _aggr(aggr_in), _dimensions(dimensions_in) {}
Aggr aggr() const { return _aggr; }
const std::vector<vespalib::string> &dimensions() const { return _dimensions; }
+ bool result_is_mutable() const override { return true; }
InterpretedFunction::Instruction compile_self(Stash &stash) const final override;
};
@@ -208,6 +211,7 @@ public:
map_fun_t function_in)
: Op1(result_type_in, child_in), _function(function_in) {}
map_fun_t function() const { return _function; }
+ bool result_is_mutable() const override { return true; }
InterpretedFunction::Instruction compile_self(Stash &stash) const override;
};
@@ -224,6 +228,7 @@ public:
join_fun_t function_in)
: Op2(result_type_in, lhs_in, rhs_in), _function(function_in) {}
join_fun_t function() const { return _function; }
+ bool result_is_mutable() const override { return true; }
InterpretedFunction::Instruction compile_self(Stash &stash) const override;
};
@@ -240,6 +245,7 @@ public:
const vespalib::string &dimension_in)
: Op2(result_type_in, lhs_in, rhs_in), _dimension(dimension_in) {}
const vespalib::string &dimension() const { return _dimension; }
+ bool result_is_mutable() const override { return true; }
InterpretedFunction::Instruction compile_self(Stash &stash) const final override;
};
@@ -258,6 +264,7 @@ public:
: Op1(result_type_in, child_in), _from(from_in), _to(to_in) {}
const std::vector<vespalib::string> &from() const { return _from; }
const std::vector<vespalib::string> &to() const { return _to; }
+ bool result_is_mutable() const override { return true; }
InterpretedFunction::Instruction compile_self(Stash &stash) const final override;
};
@@ -279,6 +286,10 @@ public:
const TensorFunction &true_child() const { return _true_child.get(); }
const TensorFunction &false_child() const { return _false_child.get(); }
void push_children(std::vector<Child::CREF> &children) const final override;
+ bool result_is_mutable() const override {
+ return (true_child().result_is_mutable() &&
+ false_child().result_is_mutable());
+ }
InterpretedFunction::Instruction compile_self(Stash &stash) const final override;
};
diff --git a/eval/src/vespa/eval/tensor/dense/dense_dot_product_function.h b/eval/src/vespa/eval/tensor/dense/dense_dot_product_function.h
index eec7448f041..46b04a446d4 100644
--- a/eval/src/vespa/eval/tensor/dense/dense_dot_product_function.h
+++ b/eval/src/vespa/eval/tensor/dense/dense_dot_product_function.h
@@ -19,6 +19,7 @@ public:
DenseDotProductFunction(const eval::TensorFunction &lhs_in,
const eval::TensorFunction &rhs_in);
eval::InterpretedFunction::Instruction compile_self(Stash &stash) const override;
+ bool result_is_mutable() const override { return true; }
static const eval::TensorFunction &optimize(const eval::TensorFunction &expr, Stash &stash);
};
diff --git a/eval/src/vespa/eval/tensor/dense/dense_fast_rename_function.h b/eval/src/vespa/eval/tensor/dense/dense_fast_rename_function.h
index e7de8e95ff0..1ca61d52915 100644
--- a/eval/src/vespa/eval/tensor/dense/dense_fast_rename_function.h
+++ b/eval/src/vespa/eval/tensor/dense/dense_fast_rename_function.h
@@ -17,6 +17,7 @@ public:
const eval::TensorFunction &child);
~DenseFastRenameFunction();
eval::InterpretedFunction::Instruction compile_self(Stash &stash) const override;
+ bool result_is_mutable() const override { return child().result_is_mutable(); }
static const eval::TensorFunction &optimize(const eval::TensorFunction &expr, Stash &stash);
};
diff --git a/eval/src/vespa/eval/tensor/dense/vector_from_doubles_function.h b/eval/src/vespa/eval/tensor/dense/vector_from_doubles_function.h
index 417c60c2aca..378c9026f84 100644
--- a/eval/src/vespa/eval/tensor/dense/vector_from_doubles_function.h
+++ b/eval/src/vespa/eval/tensor/dense/vector_from_doubles_function.h
@@ -31,6 +31,7 @@ public:
}
size_t size() const { return _self.resultSize; }
eval::InterpretedFunction::Instruction compile_self(Stash &stash) const override;
+ bool result_is_mutable() const override { return true; }
static const eval::TensorFunction &optimize(const eval::TensorFunction &expr, Stash &stash);
};