diff options
author | Håvard Pettersen <havardpe@oath.com> | 2021-03-11 14:56:32 +0000 |
---|---|---|
committer | Håvard Pettersen <havardpe@oath.com> | 2021-03-11 14:56:32 +0000 |
commit | a6ad5906a291a59e9258db531c66dd76a8146439 (patch) | |
tree | 59a9156f2cb57fb33607f1203c729f35392b39e6 /eval | |
parent | 0d3d06ca2d5b49763d493f7ba2c00a84cf0a90eb (diff) |
limit template expansion for generic cell cast
Diffstat (limited to 'eval')
-rw-r--r-- | eval/src/vespa/eval/eval/interpreted_function.cpp | 8 | ||||
-rw-r--r-- | eval/src/vespa/eval/eval/interpreted_function.h | 1 | ||||
-rw-r--r-- | eval/src/vespa/eval/instruction/generic_cell_cast.cpp | 24 |
3 files changed, 26 insertions, 7 deletions
diff --git a/eval/src/vespa/eval/eval/interpreted_function.cpp b/eval/src/vespa/eval/eval/interpreted_function.cpp index 5ac401aee39..10801f276d7 100644 --- a/eval/src/vespa/eval/eval/interpreted_function.cpp +++ b/eval/src/vespa/eval/eval/interpreted_function.cpp @@ -29,6 +29,8 @@ const Function *get_lambda(const nodes::Node &node) { return nullptr; } +void my_nop(InterpretedFunction::State &, uint64_t) {} + } // namespace vespalib::<unnamed> @@ -58,6 +60,12 @@ InterpretedFunction::Context::Context(const InterpretedFunction &ifun) { } +InterpretedFunction::Instruction +InterpretedFunction::Instruction::nop() +{ + return Instruction(my_nop); +} + InterpretedFunction::InterpretedFunction(const ValueBuilderFactory &factory, const TensorFunction &function) : _program(), _stash(), diff --git a/eval/src/vespa/eval/eval/interpreted_function.h b/eval/src/vespa/eval/eval/interpreted_function.h index eca434b1260..829ae6e3b12 100644 --- a/eval/src/vespa/eval/eval/interpreted_function.h +++ b/eval/src/vespa/eval/eval/interpreted_function.h @@ -82,6 +82,7 @@ public: static Instruction fetch_param(size_t param_idx) { return Instruction(nullptr, param_idx); } + static Instruction nop(); }; private: diff --git a/eval/src/vespa/eval/instruction/generic_cell_cast.cpp b/eval/src/vespa/eval/instruction/generic_cell_cast.cpp index da14a585141..b5f957c5168 100644 --- a/eval/src/vespa/eval/instruction/generic_cell_cast.cpp +++ b/eval/src/vespa/eval/instruction/generic_cell_cast.cpp @@ -33,8 +33,13 @@ void my_generic_cell_cast_op(State &state, uint64_t param_in) { struct SelectGenericCellCastOp { template <typename ICT, typename OCT> - static auto invoke() { - return my_generic_cell_cast_op<ICT, OCT>; + static InterpretedFunction::op_function invoke() { + if constexpr (std::is_same_v<ICT,OCT>) { + // handeled by nop case below + abort(); + } else { + return my_generic_cell_cast_op<ICT, OCT>; + } } }; @@ -46,12 +51,17 @@ GenericCellCast::make_instruction(const ValueType &result_type, CellType to_cell_type, Stash &stash) { - CellType from = input_type.cell_type(); assert(result_type == input_type.cell_cast(to_cell_type)); - auto ¶m = stash.create<ValueType>(result_type); - CellType to = result_type.cell_type(); - auto op = typify_invoke<2,TypifyCellType,SelectGenericCellCastOp>(from, to); - return Instruction(op, wrap_param<ValueType>(param)); + auto from = input_type.cell_type(); + auto to = result_type.cell_type(); + if (to == from) { + return Instruction::nop(); + } else { + assert(!input_type.is_double()); + auto ¶m = stash.create<ValueType>(result_type); + auto op = typify_invoke<2,TypifyCellType,SelectGenericCellCastOp>(from, to); + return Instruction(op, wrap_param<ValueType>(param)); + } } } // namespace |