optimize(*, key=None, path=None, readonly=False, **config_dict)¶
Context manager that optimizes kernel launch parameters.
In this context, CuPy’s routines find the best kernel launch parameter values (e.g., the number of threads and blocks). The found values are cached and reused with keys as the shapes, strides and dtypes of the given inputs arrays.
key (string or None) – The cache key of optimizations.
path (string or None) – The path to save optimization cache records. When path is specified and exists, records will be loaded from the path. When readonly option is set to
False, optimization cache records will be saved to the path after the optimization.
readonly (bool) – See the description of
max_trials (int) – The number of trials that defaults to 100.
timeout (float) – Stops study after the given number of seconds. Default is 1.
max_total_time_per_trial (float) – Repeats measuring the execution time of the routine for the given number of seconds. Default is 0.1.
>>> import cupy >>> from cupyx import optimizing >>> >>> x = cupy.arange(100) >>> with optimizing.optimize(): ... cupy.sum(x) ... array(4950)
Optuna (https://optuna.org) installation is required. Currently it works for reduction operations only.