diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2016-09-11 15:00:38 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2016-09-11 15:00:38 +0000 |
commit | 1262673ffcc013191dd7d9f08c9bc03f52b58ef6 (patch) | |
tree | 38249aa252abe01306ce86494579e59376331c8a /searchlib | |
parent | fe723e684f6bff17d698131806d3ae11688b9e17 (diff) |
Split out tensor and llvm part of eval to avoid bringing in llvm everywhere where it is not needed.
Diffstat (limited to 'searchlib')
5 files changed, 68 insertions, 76 deletions
diff --git a/searchlib/CMakeLists.txt b/searchlib/CMakeLists.txt index c99c3c36bd1..c03969bc928 100644 --- a/searchlib/CMakeLists.txt +++ b/searchlib/CMakeLists.txt @@ -4,6 +4,7 @@ vespa_define_module( fastos vespalog vespalib + vespalib_vespalib_eval_llvm staging_vespalib fnet configdefinitions @@ -16,6 +17,7 @@ vespa_define_module( EXTERNAL_DEPENDS icui18n + rt LIBS src/vespa/searchlib diff --git a/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp b/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp index 50de984e392..0766bac2465 100644 --- a/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp +++ b/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp @@ -4,16 +4,16 @@ #include <map> #include <vespa/searchlib/features/rankingexpression/feature_name_extractor.h> #include <vector> -#include <vespa/vespalib/eval/compiled_function.h> +#include <vespa/vespalib/eval/llvm/compiled_function.h> #include <vespa/vespalib/eval/function.h> #include <vespa/vespalib/eval/interpreted_function.h> #include <vespa/vespalib/eval/basic_nodes.h> #include <vespa/vespalib/eval/call_nodes.h> #include <vespa/vespalib/eval/operator_nodes.h> #include <vespa/vespalib/util/benchmark_timer.h> -#include <vespa/vespalib/eval/gbdt.h> -#include <vespa/vespalib/eval/vm_forest.h> -#include <vespa/vespalib/eval/deinline_forest.h> +#include <vespa/vespalib/eval/llvm/gbdt.h> +#include <vespa/vespalib/eval/llvm/vm_forest.h> +#include <vespa/vespalib/eval/llvm/deinline_forest.h> #include <vespa/vespalib/tensor/default_tensor_engine.h> #include <cmath> diff --git a/searchlib/src/vespa/searchlib/features/element_similarity_feature.cpp b/searchlib/src/vespa/searchlib/features/element_similarity_feature.cpp index a0b294d390e..8597184dcaf 100644 --- a/searchlib/src/vespa/searchlib/features/element_similarity_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/element_similarity_feature.cpp @@ -4,8 +4,8 @@ #include <vespa/log/log.h> LOG_SETUP(".features.elementsimilarity"); #include "element_similarity_feature.h" -#include <vespa/vespalib/eval/compiled_function.h> -#include <vespa/vespalib/eval/compile_cache.h> +#include <vespa/vespalib/eval/llvm/compiled_function.h> +#include <vespa/vespalib/eval/llvm/compile_cache.h> namespace search { namespace features { diff --git a/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp b/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp index 80724d2d3ba..6c90d6d4148 100644 --- a/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp @@ -8,8 +8,9 @@ LOG_SETUP(".features.rankingexpression"); #include <vespa/searchlib/features/rankingexpression/feature_name_extractor.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/eval/function.h> -#include <vespa/vespalib/eval/compiled_function.h> -#include <vespa/vespalib/eval/compile_cache.h> +#include <vespa/vespalib/eval/interpreted_function.h> +#include <vespa/vespalib/eval/llvm/compiled_function.h> +#include <vespa/vespalib/eval/llvm/compile_cache.h> #include <vespa/vespalib/eval/node_types.h> #include "rankingexpressionfeature.h" #include "utils.h" @@ -33,14 +34,47 @@ namespace features { //----------------------------------------------------------------------------- -CompiledRankingExpressionExecutor::CompiledRankingExpressionExecutor(const vespalib::eval::CompiledFunction &compiled_function) +/** + * Implements the executor for compiled ranking expressions + **/ +class CompiledRankingExpressionExecutor : public fef::FeatureExecutor +{ +private: + typedef double (*arr_function)(const double *); + arr_function _ranking_function; + std::vector<double> _params; + +public: + CompiledRankingExpressionExecutor(const CompiledFunction &compiled_function); + void execute(fef::MatchData &data) override; +}; + +//----------------------------------------------------------------------------- + +/** + * Implements the executor for interpreted ranking expressions (with tensor support) + **/ +class InterpretedRankingExpressionExecutor : public fef::FeatureExecutor +{ +private: + InterpretedFunction::Context _context; + const InterpretedFunction &_function; + +public: + InterpretedRankingExpressionExecutor(const InterpretedFunction &function); + void execute(fef::MatchData &data) override; +}; + +//----------------------------------------------------------------------------- + +CompiledRankingExpressionExecutor::CompiledRankingExpressionExecutor(const CompiledFunction &compiled_function) : _ranking_function(compiled_function.get_function()), _params(compiled_function.num_params(), 0.0) { } void -CompiledRankingExpressionExecutor::execute(search::fef::MatchData &data) +CompiledRankingExpressionExecutor::execute(fef::MatchData &data) { for (size_t i = 0; i < _params.size(); ++i) { _params[i] = *data.resolveFeature(inputs()[i]); @@ -50,14 +84,14 @@ CompiledRankingExpressionExecutor::execute(search::fef::MatchData &data) //----------------------------------------------------------------------------- -InterpretedRankingExpressionExecutor::InterpretedRankingExpressionExecutor(const vespalib::eval::InterpretedFunction &function) +InterpretedRankingExpressionExecutor::InterpretedRankingExpressionExecutor(const InterpretedFunction &function) : _context(), _function(function) { } void -InterpretedRankingExpressionExecutor::execute(search::fef::MatchData &data) +InterpretedRankingExpressionExecutor::execute(fef::MatchData &data) { _context.clear_params(); for (size_t i = 0; i < _function.num_params(); ++i) { @@ -73,26 +107,26 @@ InterpretedRankingExpressionExecutor::execute(search::fef::MatchData &data) //----------------------------------------------------------------------------- RankingExpressionBlueprint::RankingExpressionBlueprint() - : search::fef::Blueprint("rankingExpression"), + : fef::Blueprint("rankingExpression"), _interpreted_function(), _compile_token() { } void -RankingExpressionBlueprint::visitDumpFeatures(const search::fef::IIndexEnvironment &, - search::fef::IDumpFeatureVisitor &) const +RankingExpressionBlueprint::visitDumpFeatures(const fef::IIndexEnvironment &, + fef::IDumpFeatureVisitor &) const { // empty } bool -RankingExpressionBlueprint::setup(const search::fef::IIndexEnvironment &env, - const search::fef::ParameterList ¶ms) +RankingExpressionBlueprint::setup(const fef::IIndexEnvironment &env, + const fef::ParameterList ¶ms) { // Retrieve and concatenate whatever config is available. vespalib::string script = ""; - search::fef::Property property = env.getProperties().lookup(getName(), "rankingScript"); + fef::Property property = env.getProperties().lookup(getName(), "rankingScript"); if (property.size() > 0) { for (uint32_t i = 0; i < property.size(); ++i) { script.append(property.getAt(i)); @@ -148,20 +182,20 @@ RankingExpressionBlueprint::setup(const search::fef::IIndexEnvironment &env, return true; } -search::fef::Blueprint::UP +fef::Blueprint::UP RankingExpressionBlueprint::createInstance() const { - return search::fef::Blueprint::UP(new RankingExpressionBlueprint()); + return fef::Blueprint::UP(new RankingExpressionBlueprint()); } -search::fef::FeatureExecutor::LP -RankingExpressionBlueprint::createExecutor(const search::fef::IQueryEnvironment &) const +fef::FeatureExecutor::LP +RankingExpressionBlueprint::createExecutor(const fef::IQueryEnvironment &) const { if (_interpreted_function) { - return search::fef::FeatureExecutor::LP(new InterpretedRankingExpressionExecutor(*_interpreted_function)); + return fef::FeatureExecutor::LP(new InterpretedRankingExpressionExecutor(*_interpreted_function)); } assert(_compile_token.get() != nullptr); // will be nullptr for VERIFY_SETUP feature motivation - return search::fef::FeatureExecutor::LP(new CompiledRankingExpressionExecutor(_compile_token->get())); + return fef::FeatureExecutor::LP(new CompiledRankingExpressionExecutor(_compile_token->get())); } //----------------------------------------------------------------------------- diff --git a/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.h b/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.h index af60c0de456..0451795b1c8 100644 --- a/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.h +++ b/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.h @@ -3,9 +3,8 @@ #include <vespa/searchlib/fef/blueprint.h> #include <vespa/searchlib/fef/featureexecutor.h> -#include <vespa/vespalib/eval/compiled_function.h> #include <vespa/vespalib/eval/interpreted_function.h> -#include <vespa/vespalib/eval/compile_cache.h> +#include <vespa/vespalib/eval/llvm/compile_cache.h> namespace search { namespace features { @@ -13,42 +12,9 @@ namespace features { //----------------------------------------------------------------------------- /** - * Implements the executor for compiled ranking expressions - **/ -class CompiledRankingExpressionExecutor : public search::fef::FeatureExecutor -{ -private: - typedef double (*arr_function)(const double *); - arr_function _ranking_function; - std::vector<double> _params; - -public: - CompiledRankingExpressionExecutor(const vespalib::eval::CompiledFunction &compiled_function); - virtual void execute(search::fef::MatchData &data); -}; - -//----------------------------------------------------------------------------- - -/** - * Implements the executor for interpreted ranking expressions (with tensor support) - **/ -class InterpretedRankingExpressionExecutor : public search::fef::FeatureExecutor -{ -private: - vespalib::eval::InterpretedFunction::Context _context; - const vespalib::eval::InterpretedFunction &_function; - -public: - InterpretedRankingExpressionExecutor(const vespalib::eval::InterpretedFunction &function); - virtual void execute(search::fef::MatchData &data); -}; - -//----------------------------------------------------------------------------- - -/** * Implements the blueprint for ranking expression. */ -class RankingExpressionBlueprint : public search::fef::Blueprint +class RankingExpressionBlueprint : public fef::Blueprint { private: vespalib::eval::InterpretedFunction::UP _interpreted_function; @@ -60,26 +26,16 @@ public: */ RankingExpressionBlueprint(); - // Inherit doc from Blueprint. - virtual void visitDumpFeatures(const search::fef::IIndexEnvironment &env, - search::fef::IDumpFeatureVisitor &visitor) const; - - // Inherit doc from Blueprint. - virtual search::fef::Blueprint::UP createInstance() const; - - // Inherit doc from Blueprint. - virtual search::fef::ParameterDescriptions getDescriptions() const { - return search::fef::ParameterDescriptions(). + void visitDumpFeatures(const fef::IIndexEnvironment &env, fef::IDumpFeatureVisitor &visitor) const override; + fef::Blueprint::UP createInstance() const override; + fef::ParameterDescriptions getDescriptions() const override { + return fef::ParameterDescriptions(). desc(). desc().string(); } - // Inherit doc from Blueprint. - virtual bool setup(const search::fef::IIndexEnvironment & env, - const search::fef::ParameterList & params); - - // Inherit doc from Blueprint. - virtual search::fef::FeatureExecutor::LP createExecutor(const search::fef::IQueryEnvironment &env) const; + bool setup(const fef::IIndexEnvironment & env, const fef::ParameterList & params) override; + fef::FeatureExecutor::LP createExecutor(const fef::IQueryEnvironment &env) const override; }; //----------------------------------------------------------------------------- |