summaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorHÃ¥vard Pettersen <3535158+havardpe@users.noreply.github.com>2021-03-11 15:23:18 +0100
committerGitHub <noreply@github.com>2021-03-11 15:23:18 +0100
commit0d3d06ca2d5b49763d493f7ba2c00a84cf0a90eb (patch)
tree257be669e5261fe9cbf20e495949fe20f279596e /eval
parent0514c6f97518b2b9eb06225c6601abe91ede5679 (diff)
parent78a0555c821f49c5a8fa0d1bce45b6483869f342 (diff)
Merge pull request #16901 from vespa-engine/arnej/use-more-cell-meta-2
Arnej/use more cell meta 2
Diffstat (limited to 'eval')
-rw-r--r--eval/src/vespa/eval/instruction/dense_single_reduce_function.cpp25
-rw-r--r--eval/src/vespa/eval/instruction/generic_concat.cpp10
-rw-r--r--eval/src/vespa/eval/instruction/generic_merge.cpp10
-rw-r--r--eval/src/vespa/eval/instruction/generic_peek.cpp8
-rw-r--r--eval/src/vespa/eval/instruction/generic_rename.cpp7
-rw-r--r--eval/src/vespa/eval/instruction/mixed_map_function.cpp12
6 files changed, 47 insertions, 25 deletions
diff --git a/eval/src/vespa/eval/instruction/dense_single_reduce_function.cpp b/eval/src/vespa/eval/instruction/dense_single_reduce_function.cpp
index 53e91f729ee..492b6380ad2 100644
--- a/eval/src/vespa/eval/instruction/dense_single_reduce_function.cpp
+++ b/eval/src/vespa/eval/instruction/dense_single_reduce_function.cpp
@@ -119,12 +119,13 @@ void my_single_reduce_op(InterpretedFunction::State &state, uint64_t param) {
struct MyGetFun {
template <typename R1, typename R2, typename R3, typename R4> static auto invoke() {
- using AggrType = typename R2::template templ<R1>;
- return my_single_reduce_op<R1, AggrType, R3::value, R4::value>;
+ using OCT = CellValueType<R1::value.decay().cell_type>;
+ using AggrType = typename R2::template templ<OCT>;
+ return my_single_reduce_op<OCT, AggrType, R3::value, R4::value>;
}
};
-using MyTypify = TypifyValue<TypifyCellType,TypifyAggr,TypifyBool>;
+using MyTypify = TypifyValue<TypifyCellMeta,TypifyAggr,TypifyBool>;
std::pair<std::vector<vespalib::string>,ValueType> sort_and_drop_trivial(const std::vector<vespalib::string> &list_in, const ValueType &type_in) {
std::vector<vespalib::string> dropped;
@@ -220,6 +221,7 @@ DenseSingleReduceFunction::DenseSingleReduceFunction(const DenseSingleReduceSpec
_inner_size(spec.inner_size),
_aggr(spec.aggr)
{
+ assert(result_type().cell_meta().is_scalar == false);
}
DenseSingleReduceFunction::~DenseSingleReduceFunction() = default;
@@ -227,7 +229,8 @@ DenseSingleReduceFunction::~DenseSingleReduceFunction() = default;
InterpretedFunction::Instruction
DenseSingleReduceFunction::compile_self(const ValueBuilderFactory &, Stash &stash) const
{
- auto op = typify_invoke<4,MyTypify,MyGetFun>(result_type().cell_type(), _aggr,
+ auto op = typify_invoke<4,MyTypify,MyGetFun>(child().result_type().cell_meta().limit().not_scalar(),
+ _aggr,
(_reduce_size >= 8), (_inner_size == 1));
auto &params = stash.create<Params>(result_type(), _outer_size, _reduce_size, _inner_size);
return InterpretedFunction::Instruction(op, wrap_param<Params>(params));
@@ -238,13 +241,15 @@ DenseSingleReduceFunction::optimize(const TensorFunction &expr, Stash &stash)
{
if (auto reduce = as<Reduce>(expr)) {
const auto &child = reduce->child();
- auto spec_list = make_dense_single_reduce_list(child.result_type(), reduce->aggr(), reduce->dimensions());
- if (!spec_list.empty()) {
- const auto *prev = &child;
- for (const auto &spec: spec_list) {
- prev = &stash.create<DenseSingleReduceFunction>(spec, *prev);
+ if (reduce->result_type().cell_meta().eq(child.result_type().cell_meta())) {
+ auto spec_list = make_dense_single_reduce_list(child.result_type(), reduce->aggr(), reduce->dimensions());
+ if (!spec_list.empty()) {
+ const auto *prev = &child;
+ for (const auto &spec: spec_list) {
+ prev = &stash.create<DenseSingleReduceFunction>(spec, *prev);
+ }
+ return *prev;
}
- return *prev;
}
}
return expr;
diff --git a/eval/src/vespa/eval/instruction/generic_concat.cpp b/eval/src/vespa/eval/instruction/generic_concat.cpp
index 61f736d43d2..dcd806e5de1 100644
--- a/eval/src/vespa/eval/instruction/generic_concat.cpp
+++ b/eval/src/vespa/eval/instruction/generic_concat.cpp
@@ -142,7 +142,11 @@ void my_dense_simple_concat_op(State &state, uint64_t param_in) {
}
struct SelectGenericConcatOp {
- template <typename LCT, typename RCT, typename OCT> static auto invoke(const ConcatParam &param) {
+ template <typename LCM, typename RCM> static auto invoke(const ConcatParam &param) {
+ using LCT = CellValueType<LCM::value.cell_type>;
+ using RCT = CellValueType<RCM::value.cell_type>;
+ constexpr CellMeta ocm = CellMeta::concat(LCM::value, RCM::value);
+ using OCT = CellValueType<ocm.cell_type>;
if (param.sparse_plan.sources.empty() && param.res_type.is_dense()) {
auto & dp = param.dense_plan;
if ((dp.output_size == (dp.left.input_size + dp.right.input_size))
@@ -246,8 +250,8 @@ GenericConcat::make_instruction(const ValueType &result_type,
{
auto &param = stash.create<ConcatParam>(result_type, lhs_type, rhs_type, dimension, factory);
assert(result_type == ValueType::concat(lhs_type, rhs_type, dimension));
- auto fun = typify_invoke<3,TypifyCellType,SelectGenericConcatOp>(
- lhs_type.cell_type(), rhs_type.cell_type(), param.res_type.cell_type(),
+ auto fun = typify_invoke<2,TypifyCellMeta,SelectGenericConcatOp>(
+ lhs_type.cell_meta(), rhs_type.cell_meta(),
param);
return Instruction(fun, wrap_param<ConcatParam>(param));
}
diff --git a/eval/src/vespa/eval/instruction/generic_merge.cpp b/eval/src/vespa/eval/instruction/generic_merge.cpp
index 218746d492a..9bff85d27c7 100644
--- a/eval/src/vespa/eval/instruction/generic_merge.cpp
+++ b/eval/src/vespa/eval/instruction/generic_merge.cpp
@@ -90,7 +90,11 @@ void my_mixed_merge_op(State &state, uint64_t param_in) {
};
struct SelectGenericMergeOp {
- template <typename LCT, typename RCT, typename OCT, typename Fun> static auto invoke() {
+ template <typename LCM, typename RCM, typename Fun> static auto invoke() {
+ using LCT = CellValueType<LCM::value.cell_type>;
+ using RCT = CellValueType<RCM::value.cell_type>;
+ constexpr CellMeta ocm = CellMeta::merge(LCM::value, RCM::value);
+ using OCT = CellValueType<ocm.cell_type>;
return my_mixed_merge_op<LCT,RCT,OCT,Fun>;
}
};
@@ -99,7 +103,7 @@ struct SelectGenericMergeOp {
} // namespace <unnamed>
-using MergeTypify = TypifyValue<TypifyCellType,operation::TypifyOp2>;
+using MergeTypify = TypifyValue<TypifyCellMeta,operation::TypifyOp2>;
Instruction
GenericMerge::make_instruction(const ValueType &result_type,
@@ -108,7 +112,7 @@ GenericMerge::make_instruction(const ValueType &result_type,
{
const auto &param = stash.create<MergeParam>(result_type, lhs_type, rhs_type, function, factory);
assert(result_type == ValueType::merge(lhs_type, rhs_type));
- auto fun = typify_invoke<4,MergeTypify,SelectGenericMergeOp>(lhs_type.cell_type(), rhs_type.cell_type(), param.res_type.cell_type(), function);
+ auto fun = typify_invoke<3,MergeTypify,SelectGenericMergeOp>(lhs_type.cell_meta(), rhs_type.cell_meta(), function);
return Instruction(fun, wrap_param<MergeParam>(param));
}
diff --git a/eval/src/vespa/eval/instruction/generic_peek.cpp b/eval/src/vespa/eval/instruction/generic_peek.cpp
index c8198526b3d..ae5897257df 100644
--- a/eval/src/vespa/eval/instruction/generic_peek.cpp
+++ b/eval/src/vespa/eval/instruction/generic_peek.cpp
@@ -346,7 +346,10 @@ void my_generic_peek_op(State &state, uint64_t param_in) {
}
struct SelectGenericPeekOp {
- template <typename ICT, typename OCT> static auto invoke() {
+ template <typename ICM, typename OutIsScalar> static auto invoke() {
+ using ICT = CellValueType<ICM::value.cell_type>;
+ constexpr CellMeta ocm = CellMeta::peek(ICM::value.cell_type, OutIsScalar::value);
+ using OCT = CellValueType<ocm.cell_type>;
return my_generic_peek_op<ICT,OCT>;
}
};
@@ -362,8 +365,9 @@ GenericPeek::make_instruction(const ValueType &result_type,
const ValueBuilderFactory &factory,
Stash &stash)
{
+ using PeekTypify = TypifyValue<TypifyCellMeta,TypifyBool>;
const auto &param = stash.create<PeekParam>(result_type, input_type, spec, factory);
- auto fun = typify_invoke<2,TypifyCellType,SelectGenericPeekOp>(input_type.cell_type(), result_type.cell_type());
+ auto fun = typify_invoke<2,PeekTypify,SelectGenericPeekOp>(input_type.cell_meta().not_scalar(), result_type.is_double());
return Instruction(fun, wrap_param<PeekParam>(param));
}
diff --git a/eval/src/vespa/eval/instruction/generic_rename.cpp b/eval/src/vespa/eval/instruction/generic_rename.cpp
index 81fc6cfce42..9d617720a4c 100644
--- a/eval/src/vespa/eval/instruction/generic_rename.cpp
+++ b/eval/src/vespa/eval/instruction/generic_rename.cpp
@@ -123,7 +123,8 @@ void my_mixed_rename_dense_only_op(State &state, uint64_t param_in) {
}
struct SelectGenericRenameOp {
- template <typename CT> static auto invoke(const RenameParam &param) {
+ template <typename CM> static auto invoke(const RenameParam &param) {
+ using CT = CellValueType<CM::value.cell_type>;
if (param.sparse_plan.can_forward_index) {
return my_mixed_rename_dense_only_op<CT>;
}
@@ -211,9 +212,9 @@ GenericRename::make_instruction(const ValueType &result_type,
rename_dimension_from, rename_dimension_to,
factory);
assert(result_type == param.res_type);
- auto fun = typify_invoke<1,TypifyCellType,SelectGenericRenameOp>(param.res_type.cell_type(), param);
+ assert(result_type.cell_meta().eq(input_type.cell_meta()));
+ auto fun = typify_invoke<1,TypifyCellMeta,SelectGenericRenameOp>(param.res_type.cell_meta().not_scalar(), param);
return Instruction(fun, wrap_param<RenameParam>(param));
}
} // namespace
-
diff --git a/eval/src/vespa/eval/instruction/mixed_map_function.cpp b/eval/src/vespa/eval/instruction/mixed_map_function.cpp
index 23d5809fbca..22dfb15be20 100644
--- a/eval/src/vespa/eval/instruction/mixed_map_function.cpp
+++ b/eval/src/vespa/eval/instruction/mixed_map_function.cpp
@@ -28,12 +28,15 @@ void my_inplace_map_op(State &state, uint64_t param) {
//-----------------------------------------------------------------------------
struct MyGetFun {
- template <typename CT, typename Fun> static auto invoke() {
- return my_inplace_map_op<CT, Fun>;
+ template <typename ICM, typename Fun> static auto invoke() {
+ using ICT = CellValueType<ICM::value.cell_type>;
+ using OCT = CellValueType<ICM::value.map().cell_type>;
+ assert((std::is_same_v<ICT,OCT>));
+ return my_inplace_map_op<OCT, Fun>;
}
};
-using MyTypify = TypifyValue<TypifyCellType,TypifyOp1>;
+using MyTypify = TypifyValue<TypifyCellMeta,TypifyOp1>;
} // namespace vespalib::eval::<unnamed>
@@ -51,7 +54,8 @@ MixedMapFunction::~MixedMapFunction() = default;
Instruction
MixedMapFunction::compile_self(const ValueBuilderFactory &, Stash &) const
{
- auto op = typify_invoke<2,MyTypify,MyGetFun>(result_type().cell_type(), function());
+ auto input_cell_meta = child().result_type().cell_meta().limit().not_scalar();
+ auto op = typify_invoke<2,MyTypify,MyGetFun>(input_cell_meta, function());
static_assert(sizeof(uint64_t) == sizeof(function()));
return Instruction(op, (uint64_t)(function()));
}