Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for cupyx.optimizing.optimize #3397

Merged
merged 7 commits into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions cupyx/optimizing/_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,33 @@ def objective(trial):

@contextlib.contextmanager
def optimize(*, key=None, **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.

Args:
key (string or None): The cache key of optimizations.
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.

Examples
--------
>>> import cupy
>>> from cupyx import optimizing
>>>
>>> x = cupy.arange(100)
>>> with optimizing.optimize():
... cupy.sum(x)
...
array(4950)
"""
old_context = _optimize_config.get_current_context()
context = _optimize_config.get_new_context(key, _optimize, config_dict)
_optimize_config.set_current_context(context)
Expand Down
1 change: 1 addition & 0 deletions docs/source/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ This is the official reference of CuPy, a multi-dimensional array on CUDA with a
cuda
memoize
kernel
optimize
interoperability
testing
prof
Expand Down
8 changes: 8 additions & 0 deletions docs/source/reference/optimize.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Automatic Kernel Parameters Optimizations
asi1024 marked this conversation as resolved.
Show resolved Hide resolved
=========================================

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some more information here?

  • Optuna installation is required
  • Currently it works for reduction ops only

.. autosummary::
:toctree: generated/
:nosignatures:

cupyx.optimizing.optimize