diff --git a/build.sh b/build.sh index 55e1c9a47a..0708c1b89e 100755 --- a/build.sh +++ b/build.sh @@ -18,7 +18,7 @@ ARGS=$* # script, and that this script resides in the repo dir! REPODIR=$(cd $(dirname $0); pwd) -VALIDARGS="clean libraft pylibraft raft-dask docs tests bench clean -v -g --install --compile-libs --compile-nn --compile-dist --allgpuarch --no-nvtx --show_depr_warn -h --buildfaiss --minimal-deps" +VALIDARGS="clean libraft pylibraft raft-dask docs tests bench clean -v -g -n --compile-libs --compile-nn --compile-dist --allgpuarch --no-nvtx --show_depr_warn -h --buildfaiss --minimal-deps" HELP="$0 [ ...] [ ...] [--cmake-args=\"\"] [--cache-tool=] [--limit-tests=] [--limit-bench=] where is: clean - remove all existing build artifacts and configuration (start over) @@ -33,6 +33,7 @@ HELP="$0 [ ...] [ ...] [--cmake-args=\"\"] [--cache-tool= is: -v - verbose build mode -g - build for debug + -n - no install step --compile-libs - compile shared libraries for all components --compile-nn - compile shared library for nn component --compile-dist - compile shared library for distance and current random components @@ -44,7 +45,6 @@ HELP="$0 [ ...] [ ...] [--cmake-args=\"\"] [--cache-tool=\\\" - pass arbitrary list of CMake configuration options (escape all quotes in argument) @@ -72,6 +72,7 @@ COMPILE_LIBRARIES=OFF COMPILE_NN_LIBRARY=OFF COMPILE_DIST_LIBRARY=OFF ENABLE_NN_DEPENDENCIES=OFF +INSTALL_TARGET=install TEST_TARGETS="CLUSTER_TEST;CORE_TEST;DISTANCE_TEST;LABEL_TEST;LINALG_TEST;MATRIX_TEST;RANDOM_TEST;SOLVERS_TEST;SPARSE_TEST;SPARSE_DIST_TEST;SPARSE_NEIGHBORS_TEST;NEIGHBORS_TEST;STATS_TEST;UTILS_TEST" BENCH_TARGETS="CLUSTER_BENCH;NEIGHBORS_BENCH;DISTANCE_BENCH;LINALG_BENCH;MATRIX_BENCH;SPARSE_BENCH;RANDOM_BENCH" @@ -83,7 +84,6 @@ CLEAN=0 UNINSTALL=0 DISABLE_DEPRECATION_WARNINGS=ON CMAKE_TARGET="" -INSTALL_TARGET="" # Set defaults for vars that may not have been defined externally # FIXME: if INSTALL_PREFIX is not set, check PREFIX, then check @@ -191,8 +191,8 @@ if (( ${NUMARGS} != 0 )); then fi # Process flags -if hasArg --install; then - INSTALL_TARGET="install" +if hasArg -n; then + INSTALL_TARGET="" fi if hasArg --minimal-deps; then diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 53041be957..731dfcbc7a 100644 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -123,5 +123,5 @@ pytest --cache-clear --junitxml="$WORKSPACE/junit-raft-dask.xml" -v -s if [ "$(arch)" = "x86_64" ]; then gpuci_logger "Building docs" gpuci_mamba_retry install "rapids-doc-env=${MINOR_VERSION}.*" - "$WORKSPACE/build.sh" docs -v + "$WORKSPACE/build.sh" docs -v -n fi diff --git a/conda/recipes/libraft/build_libraft_distance.sh b/conda/recipes/libraft/build_libraft_distance.sh index 35a669d6df..35bf354e9b 100644 --- a/conda/recipes/libraft/build_libraft_distance.sh +++ b/conda/recipes/libraft/build_libraft_distance.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash # Copyright (c) 2022, NVIDIA CORPORATION. -./build.sh libraft --install -v --allgpuarch --compile-dist --no-nvtx +./build.sh libraft -v --allgpuarch --compile-dist --no-nvtx diff --git a/conda/recipes/libraft/build_libraft_headers.sh b/conda/recipes/libraft/build_libraft_headers.sh index 02ef674787..7bd678c07a 100644 --- a/conda/recipes/libraft/build_libraft_headers.sh +++ b/conda/recipes/libraft/build_libraft_headers.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash # Copyright (c) 2022, NVIDIA CORPORATION. -./build.sh libraft --install -v --allgpuarch --no-nvtx +./build.sh libraft -v --allgpuarch --no-nvtx diff --git a/conda/recipes/libraft/build_libraft_nn.sh b/conda/recipes/libraft/build_libraft_nn.sh index caa643a356..773d6ab02e 100644 --- a/conda/recipes/libraft/build_libraft_nn.sh +++ b/conda/recipes/libraft/build_libraft_nn.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash # Copyright (c) 2022, NVIDIA CORPORATION. -./build.sh libraft --install -v --allgpuarch --compile-nn --no-nvtx +./build.sh libraft -v --allgpuarch --compile-nn --no-nvtx diff --git a/conda/recipes/pylibraft/build.sh b/conda/recipes/pylibraft/build.sh index 4e64d031ec..2f02fb5a4c 100644 --- a/conda/recipes/pylibraft/build.sh +++ b/conda/recipes/pylibraft/build.sh @@ -2,4 +2,4 @@ #!/usr/bin/env bash # This assumes the script is executed from the root of the repo directory -./build.sh pylibraft --install --no-nvtx +./build.sh pylibraft --no-nvtx diff --git a/conda/recipes/raft-dask/build.sh b/conda/recipes/raft-dask/build.sh index 963433dd8d..ec81224e03 100644 --- a/conda/recipes/raft-dask/build.sh +++ b/conda/recipes/raft-dask/build.sh @@ -1,6 +1,5 @@ # Copyright (c) 2022, NVIDIA CORPORATION. #!/usr/bin/env bash -# Copyright (c) 2022, NVIDIA CORPORATION. # This assumes the script is executed from the root of the repo directory -./build.sh raft-dask --install --no-nvtx +./build.sh raft-dask --no-nvtx diff --git a/docs/source/_static/copybutton.css b/docs/source/_static/copybutton.css deleted file mode 100644 index 5eef6e366d..0000000000 --- a/docs/source/_static/copybutton.css +++ /dev/null @@ -1,42 +0,0 @@ -/* This contains code with copyright by the scikit-learn project, subject to -the license in /thirdparty/LICENSES/LICENSE.scikit_learn */ - -/* copybutton */ -/* Adds "Show/Hide Output" button to Examples */ - -.copybutton { - cursor: pointer; - position: absolute; - top: 0px; - right: 0px; - border: 1px solid rgb(221, 221, 221); - color: rgb(221, 221, 221); - font-family: monospace; - padding-left: 0.2rem; - padding-right: 0.2rem; -} - -div.highlight:hover span.copybutton::after { - background: #3F556B; - border-radius: 0.25rem; - color: white; - content: attr(title); - padding: 0.25rem; - position: absolute; - z-index: 98; - width: 100px; - font-size: 0.7rem; - top: 0; - right: 0; -} - -/* copy buttonn */ -div.highlight:hover span.copybutton { - background-color: #3F556B; - color: white; -} - -div.highlight:hover span.copybutton:hover { - background-color: #20252B; -} - diff --git a/docs/source/_static/example_mod.js b/docs/source/_static/example_mod.js deleted file mode 100644 index 77dc618a82..0000000000 --- a/docs/source/_static/example_mod.js +++ /dev/null @@ -1,61 +0,0 @@ -// This contains code with copyright by the scikit-learn project, subject to -// the license in /thirdparty/LICENSES/LICENSE.scikit_learn - -$(document).ready(function () { - /* Add a [>>>] button on the top-right corner of code samples to hide - * the >>> and ... prompts and the output and thus make the code - * copyable. */ - var div = $('.highlight-python .highlight,' + - '.highlight-python3 .highlight,' + - '.highlight-pycon .highlight,' + - '.highlight-default .highlight') - var pre = div.find('pre'); - - // get the styles from the current theme - pre.parent().parent().css('position', 'relative'); - var hide_text = 'Hide prompts and outputs'; - var show_text = 'Show prompts and outputs'; - - // create and add the button to all the code blocks that contain >>> - div.each(function (index) { - var jthis = $(this); - if (jthis.find('.gp').length > 0) { - var button = $('>>>'); - button.attr('title', hide_text); - button.data('hidden', 'false'); - jthis.prepend(button); - } - // tracebacks (.gt) contain bare text elements that need to be - // wrapped in a span to work with .nextUntil() (see later) - jthis.find('pre:has(.gt)').contents().filter(function () { - return ((this.nodeType == 3) && (this.data.trim().length > 0)); - }).wrap(''); - }); - - // define the behavior of the button when it's clicked - $('.copybutton').click(function (e) { - e.preventDefault(); - var button = $(this); - if (button.data('hidden') === 'false') { - // hide the code output - button.parent().find('.go, .gp, .gt').hide(); - button.next('pre') - .find('.gt') - .nextUntil('.gp, .go') - .css('visibility', 'hidden'); - button.css('text-decoration', 'line-through'); - button.attr('title', show_text); - button.data('hidden', 'true'); - } else { - // show the code output - button.parent().find('.go, .gp, .gt').show(); - button.next('pre') - .find('.gt') - .nextUntil('.gp, .go') - .css('visibility', 'visible'); - button.css('text-decoration', 'none'); - button.attr('title', hide_text); - button.data('hidden', 'false'); - } - }); -}); \ No newline at end of file diff --git a/docs/source/_static/infoboxes.css b/docs/source/_static/infoboxes.css deleted file mode 100644 index 4cc597bd28..0000000000 --- a/docs/source/_static/infoboxes.css +++ /dev/null @@ -1,87 +0,0 @@ -/* This contains code with copyright by the scikit-learn project, subject to -the license in /thirdparty/LICENSES/LICENSE.scikit_learn */ - -/* info boxes */ - -div.topic { - padding: 0.5rem; - background-color: #eee; - margin-bottom: 1rem; - border-radius: 0.25rem; - border: 1px solid #CCC; -} - -div.topic p { - margin-bottom: 0.25rem; -} - -div.topic dd { - margin-bottom: 0.25rem; -} - -p.topic-title { - font-weight: bold; - margin-bottom: 0.5rem; -} - -div.topic > ul.simple { - margin-bottom: 0.25rem; -} - -p.admonition-title { - margin-right: 0.5rem; - font-weight: bold; - display: inline; -} - -p.admonition-title:after { - content: ":"; -} - -div.admonition p.admonition-title + p, div.deprecated p { - display: inline; -} - -div.admonition, div.deprecated { - padding: 0.5rem; - border-radius: 0.5rem; - border: 1px solid #ddd; - margin-bottom: 1rem; -} - -div.admonition { - background-color: #eee; -} - -div.admonition p, div.admonition dl, div.admonition dd { - margin-bottom: 0 -} - -div.deprecated { - color: #b94a48; - background-color: #F3E5E5; - border: 1px solid #eed3d7; -} - -div.seealso { - background-color: #FFFBE8; - border: 1px solid #fbeed5; - color: #AF8A4B; -} - -div.versionchanged { - margin-top: 0.5rem; - padding: 0.5rem; - background-color: #FFFBE8; - border: 1px solid #fbeed5; - border-radius: 0.5rem; -} - -div.versionchanged p { - margin-bottom: 0; -} - -dt.label { - float: left; - padding-right: 0.5rem; -} \ No newline at end of file diff --git a/docs/source/build.md b/docs/source/build.md index 30acc1b399..1273fad6bf 100644 --- a/docs/source/build.md +++ b/docs/source/build.md @@ -36,9 +36,14 @@ The recommended way to build and install RAFT is to use the `build.sh` script in `build.sh` uses [rapids-cmake](https://github.com/rapidsai/rapids-cmake), which will automatically download any dependencies which are not already installed. It's important to note that while all the headers will be installed and available, some parts of the RAFT API depend on libraries like `FAISS`, which will need to be explicitly enabled in `build.sh`. -The following example will download the needed dependencies and install the RAFT headers into `$INSTALL_PREFIX/include/raft`. The `--install` flag can be omitted to just have the build download the needed dependencies. Since RAFT is primarily used at build-time, the dependencies will never be installed by the RAFT build, with the exception of building FAISS statically into the shared libraries. +The following example will download the needed dependencies and install the RAFT headers into `$INSTALL_PREFIX/include/raft`. ```bash -./build.sh libraft --install +./build.sh libraft + +``` +The `-n` flag can be passed to just have the build download the needed dependencies. Since RAFT is primarily used at build-time, the dependencies will never be installed by the RAFT build, with the exception of building FAISS statically into the shared libraries. +```bash +./build.sh libraft -n ``` ### C++ Shared Libraries (optional) @@ -53,7 +58,7 @@ Individual shared libraries have their own flags and multiple can be used (thoug ./build.sh libraft --compile-nn --compile-dist ``` -Add the `--install` flag to the above example to also install the shared libraries into `$INSTALL_PREFIX/lib`. +In above example the shared libraries are installed by default into `$INSTALL_PREFIX/lib`. To disable this, pass `-n` flag. ### ccache and sccache @@ -148,9 +153,9 @@ The Python APIs can be built and installed using the `build.sh` script: ```bash # to build pylibraft -./build.sh libraft pylibraft --install --compile-libs +./build.sh libraft pylibraft --compile-libs # to build raft-dask -./build.sh libraft raft-dask --install --compile-libs +./build.sh libraft raft-dask --compile-libs ``` `setup.py` can also be used to build the Python APIs manually: @@ -181,7 +186,7 @@ The documentation requires that the C++ headers and python packages have been bu The following will build the docs along with the C++ and Python packages: ``` -./build.sh libraft pylibraft raft-dask docs --compile-libs --install +./build.sh libraft pylibraft raft-dask docs --compile-libs ``` diff --git a/docs/source/conf.py b/docs/source/conf.py index 6cef8a7a96..00cfdd7c09 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -51,6 +51,7 @@ "breathe", "recommonmark", "sphinx_markdown_tables", + "sphinx_copybutton" ] breathe_default_project = "RAFT" @@ -112,32 +113,27 @@ # a list of builtin themes. # -html_theme = "sphinx_rtd_theme" +html_theme = "pydata_sphinx_theme" -# on_rtd is whether we are on readthedocs.org -on_rtd = os.environ.get("READTHEDOCS", None) == "True" - -if not on_rtd: - # only import and set the theme if we're building docs locally - # otherwise, readthedocs.org uses their theme by default, - # so no need to specify it - import sphinx_rtd_theme - - html_theme = "sphinx_rtd_theme" - html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # -# html_theme_options = {} +html_theme_options = { + "external_links": [], + "github_url": "https://github.com/rapidsai/raft", + "twitter_url": "https://twitter.com/rapidsai", + "show_toc_level": 1, + "navbar_align": "right", +} # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ["_static"] -html_js_files = ["example_mod.js"] +html_js_files = [] # -- Options for HTMLHelp output ------------------------------------------ @@ -203,8 +199,6 @@ def setup(app): - app.add_css_file("copybutton.css") - app.add_css_file("infoboxes.css") app.add_css_file("references.css") app.add_css_file("https://docs.rapids.ai/assets/css/custom.css") app.add_js_file( diff --git a/python/pylibraft/pylibraft/distance/pairwise_distance.pyx b/python/pylibraft/pylibraft/distance/pairwise_distance.pyx index dde18315ce..7bdf52df99 100644 --- a/python/pylibraft/pylibraft/distance/pairwise_distance.pyx +++ b/python/pylibraft/pylibraft/distance/pairwise_distance.pyx @@ -116,62 +116,54 @@ def distance(X, Y, out=None, metric="euclidean", p=2.0, handle=None): Examples -------- - To compute pairwise distances on cupy arrays: - .. code-block:: python - - import cupy as cp - - from pylibraft.common import Handle - from pylibraft.distance import pairwise_distance - - n_samples = 5000 - n_features = 50 - in1 = cp.random.random_sample((n_samples, n_features), + >>> import cupy as cp + >>> from pylibraft.common import Handle + >>> from pylibraft.distance import pairwise_distance + >>> n_samples = 5000 + >>> n_features = 50 + >>> in1 = cp.random.random_sample((n_samples, n_features), dtype=cp.float32) - in2 = cp.random.random_sample((n_samples, n_features), + >>> in2 = cp.random.random_sample((n_samples, n_features), dtype=cp.float32) - # A single RAFT handle can optionally be reused across - # pylibraft functions. - handle = Handle() - ... - output = pairwise_distance(in1, in2, metric="euclidean", handle=handle) - ... - # pylibraft functions are often asynchronous so the - # handle needs to be explicitly synchronized - handle.sync() + A single RAFT handle can optionally be reused across + pylibraft functions. - It's also possible to write to a pre-allocated output array: - .. code-block:: python + >>> handle = Handle() + >>> output = pairwise_distance(in1, in2, metric="euclidean", handle=handle) - import cupy as cp + pylibraft functions are often asynchronous so the + handle needs to be explicitly synchronized - from pylibraft.common import Handle - from pylibraft.distance import pairwise_distance + >>> handle.sync() - n_samples = 5000 - n_features = 50 + It's also possible to write to a pre-allocated output array: - in1 = cp.random.random_sample((n_samples, n_features), + >>> import cupy as cp + >>> from pylibraft.common import Handle + >>> from pylibraft.distance import pairwise_distance + >>> n_samples = 5000 + >>> n_features = 50 + >>> in1 = cp.random.random_sample((n_samples, n_features), dtype=cp.float32) - in2 = cp.random.random_sample((n_samples, n_features), + >>> in2 = cp.random.random_sample((n_samples, n_features), dtype=cp.float32) - output = cp.empty((n_samples, n_samples), dtype=cp.float32) + >>> output = cp.empty((n_samples, n_samples), dtype=cp.float32) - # A single RAFT handle can optionally be reused across - # pylibraft functions. - handle = Handle() - ... - pairwise_distance(in1, in2, out=output, + A single RAFT handle can optionally be reused across + pylibraft functions. + + >>> handle = Handle() + >>> pairwise_distance(in1, in2, out=output, metric="euclidean", handle=handle) - ... - # pylibraft functions are often asynchronous so the - # handle needs to be explicitly synchronized - handle.sync() - """ + pylibraft functions are often asynchronous so the + handle needs to be explicitly synchronized + + >>> handle.sync() + """ x_cai = cai_wrapper(X) y_cai = cai_wrapper(Y)