in example_opt_root/opentuner_optimizer.py [0:0]
def __init__(self, api_config, techniques=DEFAULT_TECHNIQUES, n_suggestions=1):
"""Build wrapper class to use opentuner optimizer in benchmark.
Parameters
----------
api_config : dict-like of dict-like
Configuration of the optimization variables. See API description.
techniques : iterable of strings
A list or tuple of techniques to use in opentuner. If the list
has only one technique, then that technique will be used. If the
list has multiple techniques a bandit over those techniques
will be used.
n_suggestions : int
Default number of suggestions to be made in parallel.
"""
AbstractOptimizer.__init__(self, api_config)
# Opentuner requires DesiredResult to reference suggestion when making
# its observation. x_to_dr maps the dict suggestion to DesiredResult.
self.x_to_dr = {}
# Keep last suggested x and repeat it whenever opentuner gives up.
self.dummy_suggest = None
"""Setting up the arguments for opentuner. You can see all possible
arguments using:
```
>>> import opentuner
>>> opentuner.default_argparser().parse_args(['-h'])
```
We only change a few arguments (other arguments are set to defaults):
* database = MEMORY_ONLY_DB: to use an in-memory sqlite database
* parallelism = n_suggestions: num of suggestions to give in parallel
* technique = techniques: a list of techniques to be used by opentuner
* print_params = False: to avoid opentuner from exiting after printing
param spaces
"""
args = Namespace(
bail_threshold=500,
database=MEMORY_ONLY_DB,
display_frequency=10,
generate_bandit_technique=False,
label=None,
list_techniques=False,
machine_class=None,
no_dups=False,
parallel_compile=False,
parallelism=n_suggestions,
pipelining=0,
print_params=False,
print_search_space_size=False,
quiet=False,
results_log=None,
results_log_details=None,
seed_configuration=[],
stop_after=None,
technique=techniques,
test_limit=5000,
)
# Setup some dummy classes required by opentuner to actually run.
manipulator = OpentunerOptimizer.build_manipulator(api_config)
interface = DMI(args=args, manipulator=manipulator)
self.api = TuningRunManager(interface, args)