Skip to content

Commit

Permalink
build: add search compile feature (VowpalWabbit#4561)
Browse files Browse the repository at this point in the history
* build: add search compile feature

* formatting
  • Loading branch information
jackgerrits authored Apr 17, 2023
1 parent d67f476 commit bfc21df
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 32 deletions.
3 changes: 2 additions & 1 deletion cmake/VowpalWabbitFeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
# - The cmake variable VW_FEAT_X is set to ON, otherwise it is OFF
# - The C++ macro VW_FEAT_X_ENABLED is defined if the feature is enabled, otherwise it is not defined

set(VW_ALL_FEATURES "CSV;FLATBUFFERS;LDA;CB_GRAPH_FEEDBACK;LAS_SIMD")
set(VW_ALL_FEATURES "CSV;FLATBUFFERS;LDA;CB_GRAPH_FEEDBACK;SEARCH;LAS_SIMD")

option(VW_FEAT_FLATBUFFERS "Enable flatbuffers support" OFF)
option(VW_FEAT_CSV "Enable csv parser" OFF)
option(VW_FEAT_CB_GRAPH_FEEDBACK "Enable cb with graph feedback reduction" OFF)
option(VW_FEAT_LDA "Enable lda reduction" ON)
option(VW_FEAT_SEARCH "Enable search reductions" ON)
option(VW_FEAT_LAS_SIMD "Enable large action space with explicit simd (only works with linux for now)" ON)

# Legacy options for feature enablement
Expand Down
39 changes: 23 additions & 16 deletions vowpalwabbit/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,6 @@ set(vw_core_headers
include/vw/core/reductions/recall_tree.h
include/vw/core/reductions/sample_pdf.h
include/vw/core/reductions/scorer.h
include/vw/core/reductions/search/search_dep_parser.h
include/vw/core/reductions/search/search_entityrelationtask.h
include/vw/core/reductions/search/search_graph.h
include/vw/core/reductions/search/search_hooktask.h
include/vw/core/reductions/search/search_meta.h
include/vw/core/reductions/search/search_multiclasstask.h
include/vw/core/reductions/search/search_sequencetask.h
include/vw/core/reductions/search/search.h
include/vw/core/reductions/sender.h
include/vw/core/reductions/shared_feature_merger.h
include/vw/core/reductions/slates.h
Expand Down Expand Up @@ -333,14 +325,6 @@ set(vw_core_sources
src/reductions/recall_tree.cc
src/reductions/sample_pdf.cc
src/reductions/scorer.cc
src/reductions/search/search_dep_parser.cc
src/reductions/search/search_entityrelationtask.cc
src/reductions/search/search_graph.cc
src/reductions/search/search_hooktask.cc
src/reductions/search/search_meta.cc
src/reductions/search/search_multiclasstask.cc
src/reductions/search/search_sequencetask.cc
src/reductions/search/search.cc
src/reductions/sender.cc
src/reductions/shared_feature_merger.cc
src/reductions/slates.cc
Expand All @@ -364,6 +348,29 @@ if(VW_FEAT_LDA)
list(APPEND vw_core_sources src/reductions/lda_core.cc)
endif()

if(VW_FEAT_SEARCH)
list(APPEND vw_core_headers
include/vw/core/reductions/search/search_dep_parser.h
include/vw/core/reductions/search/search_entityrelationtask.h
include/vw/core/reductions/search/search_graph.h
include/vw/core/reductions/search/search_hooktask.h
include/vw/core/reductions/search/search_meta.h
include/vw/core/reductions/search/search_multiclasstask.h
include/vw/core/reductions/search/search_sequencetask.h
include/vw/core/reductions/search/search.h
)
list(APPEND vw_core_sources
src/reductions/search/search_dep_parser.cc
src/reductions/search/search_entityrelationtask.cc
src/reductions/search/search_graph.cc
src/reductions/search/search_hooktask.cc
src/reductions/search/search_meta.cc
src/reductions/search/search_multiclasstask.cc
src/reductions/search/search_sequencetask.cc
src/reductions/search/search.cc
)
endif()

if(VW_FEAT_CB_GRAPH_FEEDBACK)
list(APPEND vw_core_headers include/vw/core/reductions/cb/cb_explore_adf_graph_feedback.h)
list(APPEND vw_core_sources src/reductions/cb/cb_explore_adf_graph_feedback.cc)
Expand Down
8 changes: 6 additions & 2 deletions vowpalwabbit/core/include/vw/core/reductions/search/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
// individual contributors. All rights reserved. Released under a BSD (revised)
// license as described in the file LICENSE.
#pragma once
#include "vw/core/example.h"
#include "vw/core/global_data.h"

#ifdef VW_FEAT_SEARCH_ENABLED

# include "vw/core/example.h"
# include "vw/core/global_data.h"

// TODO: Search is using some macro-enabled logging logic for cdbg
// (going to clog [which in turn goes to err, with some differences])
Expand Down Expand Up @@ -374,3 +377,4 @@ namespace reductions
std::shared_ptr<VW::LEARNER::learner> search_setup(VW::setup_base_i& stack_builder);
}
} // namespace VW
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
// individual contributors. All rights reserved. Released under a BSD (revised)
// license as described in the file LICENSE.
#pragma once
#include "search.h"

#ifdef VW_FEAT_SEARCH_ENABLED

# include "search.h"

namespace DepParserTask
{
Expand All @@ -11,3 +14,5 @@ void run(Search::search&, VW::multi_ex&);
void setup(Search::search&, VW::multi_ex&);
extern Search::search_task task;
} // namespace DepParserTask

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
// individual contributors. All rights reserved. Released under a BSD (revised)
// license as described in the file LICENSE.
#pragma once
#include "search.h"

#ifdef VW_FEAT_SEARCH_ENABLED
# include "search.h"

namespace EntityRelationTask
{
void initialize(Search::search&, size_t&, VW::config::options_i&);
void run(Search::search&, VW::multi_ex&);
extern Search::search_task task;
} // namespace EntityRelationTask

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// individual contributors. All rights reserved. Released under a BSD (revised)
// license as described in the file LICENSE.
#pragma once
#include "search.h"

#ifdef VW_FEAT_SEARCH_ENABLED
# include "search.h"

namespace GraphTask
{
Expand All @@ -12,3 +14,4 @@ void run(Search::search&, VW::multi_ex&);
void takedown(Search::search&, VW::multi_ex&);
extern Search::search_task task;
} // namespace GraphTask
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// individual contributors. All rights reserved. Released under a BSD (revised)
// license as described in the file LICENSE.
#pragma once
#include "search.h"
#ifdef VW_FEAT_SEARCH_ENABLED
# include "search.h"

namespace HookTask
{
Expand All @@ -28,3 +29,5 @@ class task_data
size_t num_actions = 0; // cache for easy access
};
} // namespace HookTask

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
// individual contributors. All rights reserved. Released under a BSD (revised)
// license as described in the file LICENSE.
#pragma once
#include "search.h"

#define DECLARE_METATASK(X) \
namespace X \
{ \
extern Search::search_metatask metatask; \
}
#ifdef VW_FEAT_SEARCH_ENABLED
# include "search.h"

# define DECLARE_METATASK(X) \
namespace X \
{ \
extern Search::search_metatask metatask; \
}

DECLARE_METATASK(DebugMT)
DECLARE_METATASK(SelectiveBranchingMT)

// namespace DebugMT { extern Search::search_metatask metatask; }
// namespace SelectiveBranchingMT { extern Search::search_metatask metatask; }
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
// individual contributors. All rights reserved. Released under a BSD (revised)
// license as described in the file LICENSE.
#pragma once
#include "search.h"
#ifdef VW_FEAT_SEARCH_ENABLED
# include "search.h"

namespace MulticlassTask
{
void initialize(Search::search&, size_t&, VW::config::options_i&);
void run(Search::search&, VW::multi_ex&);
extern Search::search_task task;
} // namespace MulticlassTask
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// individual contributors. All rights reserved. Released under a BSD (revised)
// license as described in the file LICENSE.
#pragma once
#include "search.h"
#ifdef VW_FEAT_SEARCH_ENABLED
# include "search.h"

namespace SequenceTask
{
Expand Down Expand Up @@ -43,3 +44,4 @@ void finish(Search::search&);
void run(Search::search&, VW::multi_ex&);
extern Search::search_task task;
} // namespace SequenceTask_DemoLDF
#endif
6 changes: 5 additions & 1 deletion vowpalwabbit/core/src/reduction_stack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@
#include "vw/core/reductions/recall_tree.h"
#include "vw/core/reductions/sample_pdf.h"
#include "vw/core/reductions/scorer.h"
#include "vw/core/reductions/search/search.h"
#ifdef VW_FEAT_SEARCH_ENABLED
# include "vw/core/reductions/search/search.h"
#endif
#include "vw/core/reductions/sender.h"
#include "vw/core/reductions/shared_feature_merger.h"
#include "vw/core/reductions/slates.h"
Expand Down Expand Up @@ -236,7 +238,9 @@ void prepare_reductions(std::vector<std::tuple<std::string, VW::reduction_setup_
reductions.push_back(VW::reductions::cb_to_cb_adf_setup);
reductions.push_back(VW::reductions::offset_tree_setup);
reductions.push_back(VW::reductions::expreplay_setup<'c', VW::cs_label_parser_global>);
#ifdef VW_FEAT_SEARCH_ENABLED
reductions.push_back(VW::reductions::search_setup);
#endif
reductions.push_back(VW::reductions::audit_regressor_setup);
reductions.push_back(VW::reductions::metrics_setup);
reductions.push_back(VW::reductions::count_label_setup);
Expand Down

0 comments on commit bfc21df

Please sign in to comment.