Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 7f4ed01

Browse files
Merge pull request #546 from nicolasvasilache/pr/cleanup-docs
Cleanup docs
2 parents 9f7300a + 432fe37 commit 7f4ed01

File tree

9 files changed

+66
-249
lines changed

9 files changed

+66
-249
lines changed
-265 KB
Binary file not shown.

docs/source/framework/pytorch_integration/getting_started.rst

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,7 @@ to express their operations and bridge the gap between research and engineering.
2626
Installation
2727
------------
2828

29-
We provide a :code:`conda` package for Tensor Comprehensions (only :code:`linux-64` package)
30-
to quickly get started with TC. Follow the steps below to install TC :code:`conda` package:
31-
32-
**Step 1:** Setup Anaconda
33-
Make sure :code:`conda` bin is in your :code:`$PATH`. To verify, run the following command:
34-
35-
.. code-block:: bash
36-
37-
$ which conda
38-
39-
This command should print the path of your :code:`conda` bin. If it doesn't,
40-
please activate :code:`conda` (see `installation`_).
41-
42-
**Step 2:** Install Tensor Comprehensions with Anaconda
43-
44-
Now, go ahead and install Tensor Comprehensions by running following command.
45-
46-
.. code-block:: bash
47-
48-
$ conda install -y -c pytorch -c tensorcomp tensor_comprehensions
49-
50-
You are now ready to start using Tensor Comprehensions with PyTorch. As an example,
51-
let's see a simple example of writing :code:`matmul` layer with TC in PyTorch.
29+
See instructions here: :ref:`installation_guide`.
5230

5331
Example
5432
-------

docs/source/framework/pytorch_integration/python_api.rst

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,32 @@ Comprehensions.
1313

1414
.. autofunction:: make_autograd
1515

16+
The :func:`define` function provides an implicit compilation caching
17+
functionality which alleviates the need to implement a caching mechanism at
18+
the user-facing level. The question still remains which :class:`~tclib.MappingOptions`
19+
to use to compile. Since this is still an open problem, we provide support
20+
for user-defined functions to specify this behavior. We require a user
21+
of the :func:`define` function to provide a :class:`~tclib.MappingOptions` generator
22+
function whose sole purpose is to determine the options with which to compile
23+
a particular TC def for particular input sizes.
24+
25+
To facilitate usage we provide the following generators:
26+
27+
.. autofunction:: make_naive_options_factory
28+
29+
.. autofunction:: make_load_from_cache_options_factory
30+
31+
.. autofunction:: make_autotuned_options_factory
32+
33+
Custom behavior to select :class:`~tclib.MappingOptions` may be implemented
34+
in addition to the provided defaults. The signature of custom generators must
35+
match:
36+
37+
.. code-block:: python
38+
39+
def some_generator(tc: str, entry_point: str, *inputs: torch.Tensor)
40+
-> MappingOptions:
41+
...
1642
1743
Low-level API
1844
-------------
@@ -31,7 +57,7 @@ generally useful for benchmarking.
3157

3258
.. autofunction:: autotune_and_compile
3359

34-
Additionally the :code:`assert_almost_equal` helper function is useful in
60+
Additionally the :func:`assert_almost_equal` helper function is useful in
3561
performing numerical checks.
3662

3763
.. autofunction:: assert_almost_equal

docs/source/framework/pytorch_integration/writing_layers.rst

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
Writing TC operations
22
=====================
33

4+
.. automodule:: tensor_comprehensions
5+
46
This document focuses on writing TC operations using the high-level API.
57
For examples of using the low-level API, see the Python API documentation.
68

79
To create a CUDA kernel implementing an operation backed by TC, one should:
810

911
1. Create a callable TC object by calling :func:`define`
1012
2. Create input PyTorch Tensors
11-
3. Call the helper object with the input PyTorch Tensors
13+
3. Call the TC object with the input PyTorch Tensors
1214

1315
When running, the backend ensures the TC is compiled and memoized for the
14-
given input tensor sizes (see the documentation for :func:`define` for more detals).
16+
given input tensor sizes (see the documentation for :func:`define` for more details).
1517
Calling the object returned by :func:`define` executes the
1618
corresponding operation and returns a list of outputs.
1719
If the operation has already been compiled, in the following runs, the TC
@@ -23,11 +25,11 @@ Example
2325

2426
The following example demonstrates the steps above.
2527
We use the :func:`make_naive_options_factory` builder function to provide
26-
naive :class:`MappingOptions`. Naive options result in poor performance.
27-
At this time, there is no notion of a default :class:`MappingOptions`.
28+
naive :class:`~tclib.MappingOptions`. Naive options result in poor performance.
29+
At this time, there is no notion of a default :class:`~tclib.MappingOptions`.
2830
Instead one should use the autotuner to perform an evolutionary search
29-
starting from an initial :class:`MappingOptions` object and return a better
30-
:class:`MappingOptions` object for a given TC function and sizes (more on this
31+
starting from an initial :class:`~tclib.MappingOptions` object and return a better
32+
:class:`~tclib.MappingOptions` object for a given TC function and sizes (more on this
3133
below).
3234

3335
.. code-block:: python
@@ -50,19 +52,19 @@ below).
5052
Specifying MappingOptions
5153
-------------------------
5254

53-
There are three ways to construct :class:`MappingOptions` when defining a TC:
55+
There are three ways to construct :class:`~tclib.MappingOptions` when defining a TC:
5456

5557
* **Naive MappingOptions**:
5658

5759
* :code:`naive`: this is provided to create a basic GPU mapping strategy with
5860
3-D tiling by 32x32x32, mapping to 256x256 blocks 32x8 threads. This
5961
should by no means be considered a good baseline but just a point to
6062
get started using TC. Once a correct TC is written, we recommend either
61-
using options loaded from a :class:`MappingOptionsCache` or resulting from
62-
a tuning run. One can also modify a :class:`MappingOptions` object
63+
using options loaded from a :class:`~tclib.MappingOptionsCache` or resulting from
64+
a tuning run. One can also modify a :class:`~tclib.MappingOptions` object
6365
programmatically (see the API documentation).
6466

65-
* **Loading from MappingOptionsCache**: a :class:`MappingOptionsCache` provides
67+
* **Loading from MappingOptionsCache**: a :class:`~tclib.MappingOptionsCache` provides
6668
a simple interface to load the best options from a previous tuning run.
6769

6870
* **Autotuning**: A kernel can be autotuned for fixed input tensor sizes.
@@ -73,7 +75,7 @@ There are three ways to construct :class:`MappingOptions` when defining a TC:
7375
Loading from cache
7476
------------------
7577

76-
Loading the best options from a previously serialized :class:`MappingOptionsCache`
78+
Loading the best options from a previously serialized :class:`~tclib.MappingOptionsCache`
7779
can be achieved by making a factory function with
7880
:func:`make_load_from_cache_options_factory` and passing it as an argument to the
7981
:func:`define` function:
@@ -91,7 +93,7 @@ can be achieved by making a factory function with
9193
torch.randn(G, D, device='cuda'))
9294
Sum, SumSq, O = T.group_normalization(I, gamma, beta)
9395
94-
One can also use the low-level :class:`MappingOptionsCache`.
96+
One can also use the low-level :class:`~tclib.MappingOptionsCache`.
9597

9698
Autotuning
9799
----------
@@ -121,10 +123,10 @@ Tuning can be achieved by making a factory function with
121123
that case, the compilation and evaluation jobs currently in flight will
122124
be flushed, but no new compilation job will be created. Once the jobs in
123125
flight are flushed, saving to cache occurs (if requested) and the best
124-
:class:`MappingOptions` found so far will be returned.
126+
:class:`~tclib.MappingOptions` found so far will be returned.
125127

126128
Tuning behavior can be modified by defining the TC with an optional
127-
:class:`TunerConfig` parameter constructed as such:
129+
:class:`~tclib.TunerConfig` parameter constructed as such:
128130
:code:`tuner_config=tc.TunerConfig().threads(5).generations(3).pop_size(5)`.
129131

130132
.. note::
@@ -198,6 +200,12 @@ functions. For example, assume one wants to use :code:`fmax` CUDA function in TC
198200
O = T.relu(torch.randn(100, 128, device='cuda'))
199201
200202
TC only supports a subset of built-in CUDA functions.
201-
Built-in functions supported in TC are listed `here <https://github.com/facebookresearch/TensorComprehensions/blob/master/tc/core/libraries.h#L67>`_.
203+
Built-in functions supported in TC are listed in `this file <https://github.com/facebookresearch/TensorComprehensions/blob/master/tc/core/libraries.h#L67>`_.
202204
Documentation
203-
for these functions is available as part of the official CUDA documentation `here <http://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH__SINGLE.html#group__CUDA__MATH__SINGLE>`_.
205+
for these functions is available as part of the official `CUDA documentation <http://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH__SINGLE.html#group__CUDA__MATH__SINGLE>`_.
206+
207+
208+
More examples
209+
-------------
210+
You can find more examples in our `unit tests <https://github.com/facebookresearch/TensorComprehensions/blob/master/python/tests/test_tc.py>`_.
211+
We also provide more elaborate examples on how to `compute argmin <https://github.com/facebookresearch/TensorComprehensions/blob/master/python/examples/min_distance.py#L151>`_ as well as a simple TC + PyTorch `python overhead benchmark <https://github.com/facebookresearch/TensorComprehensions/blob/master/python/benchmarks/python_overhead.py>`_.

docs/source/index.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,3 @@ Machine Learning.
6060
:caption: Support
6161

6262
contacts
63-
64-
.. toctree::
65-
:maxdepth: 1
66-
:caption: Tutorials Reference
67-
68-
tutorials/index

docs/source/installation.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _installation_guide:
2+
13
Installation Guide
24
==================
35

docs/source/tutorials/index.rst

Lines changed: 0 additions & 34 deletions
This file was deleted.

docs/source/tutorials/tutorial_tensordot_with_tc.rst

Lines changed: 0 additions & 157 deletions
This file was deleted.

0 commit comments

Comments
 (0)