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

[Docs] Add and update documentation #48

Merged
merged 3 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ code {
font-family: monospace;
}
code {
color: #3e3ead;
color: #434552;
}

.heading-style, h1, h2, h3, h4, h5, h6 {
Expand Down
3 changes: 3 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
todo_include_todos = True

autodoc_typehints = 'description'
autodoc_default_options = {
'member-order': 'bysource',
}

bibtex_default_style = 'unsrt'
bibtex_bibfiles = ['references.bib']
Expand Down
60 changes: 60 additions & 0 deletions docs/source/getting-started/build-from-source.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Build from source
-------------------
.. _Build-from-source:

If you want to contribute to Hidet, or you encountered any problem installing hidet via pip, it is better to install
hidet from source.

Clone the code
~~~~~~~~~~~~~~

First clone the repository to local:

.. code-block:: console

$ git clone https://github.com/hidet-org/hidet

Build shared libraries
~~~~~~~~~~~~~~~~~~~~~~

The runtime library is written in C++ and compiled into a shared library. To build the shared library, you need to have
a C++ compiler installed (as well as build tools like ``cmake``, and ``make``). The following command will build the
shared library:

.. code-block:: console

$ cd hidet
$ mkdir build
$ cd build
$ cp ../config.cmake . # copy the cmake config to build directory
$ cmake ..
$ make -j4

After building, you could find two libraries ``libhidet.so`` and ``libhidet_runtime.so`` under ``build/lib`` directory.

Update environment variables
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To allow Python interpreter to find hidet package under ``python`` directory of the repository, we should append the
directory to ``PYTHONPATH`` variable. To allow the system find the shared libraries we built in the previous step,
we should append ``build/lib`` directory to ``LD_LIBRARY_PATH`` variable.

.. code-block:: console

$ export HIDET_HOME=<The Path to Hidet Repo>
$ export PYTHONPATH=$PYTHONPATH:$HIDET_HOME/python
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HIDET_HOME/build/lib

To avoid repeating above commands, it is recommended to put above commands to your shell's initialization script
(e.g., ``~/.bashrc`` for Bash and ``~/.zshrc`` for Zsh).

Validation
~~~~~~~~~~

To make sure we have successfully installed hidet, run the following command in a new shell:

.. code-block:: console

$ python -c "import hidet"

If no error reports, then hidet has been successfully installed on your computer.
80 changes: 6 additions & 74 deletions docs/source/getting-started/install.rst
Original file line number Diff line number Diff line change
@@ -1,89 +1,21 @@
Installation
============

Install via pip
----------------

.. todo::
:class: margin

Coming soon.

Run the following command to install ``hidet`` package directly using python pip:
Run the following command to install ``hidet`` package via python pip:

.. code-block:: console

$ pip install hidet


Install from source
-------------------

.. note::
:class: margin

Currently, hidet is not open-sourced yet. Please ask Yaoyao get access to the GitHub repository.

In the future, we will publish hidet to The `Python Package Index (PyPI) <https://pypi.org/>`_.

If you are a developer of Hidet, it is better to install hidet from source.

Clone the code
~~~~~~~~~~~~~~

First clone the repository to local:

.. code-block:: console

$ git clone https://github.com/hidet-org/hidet

Build shared libraries
~~~~~~~~~~~~~~~~~~~~~~

Create the directory to build the shared libraries:

.. code-block:: console

$ cd hidet
$ mkdir build
$ cd build
$ cp ../config.cmake . # copy the cmake config to build directory

You could customize the build by update the ``config.cmake`` file, according the instructions in the default config file. Usually,
just leave it as default.

Build hidet shared libraries (under ``build`` directory):

.. code-block:: console

$ cmake ..
$ make -j4

After building, you could find two libraries ``libhidet.so`` and ``libhidet_runtime.so`` under ``build/lib`` directory.

Update environment variables
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To allow Python interpreter to find hidet package under ``python`` directory of the repository, we should append the directory to ``PYTHONPATH`` variable.
To allow the system find the shared libraries we built in the previous step, we should append ``build/lib`` directory to ``LD_LIBRARY_PATH`` variable.

.. code-block:: console

$ export HIDET_HOME=<The Path to Hidet Repo>
$ export PYTHONPATH=$PYTHONPATH:$HIDET_HOME/python
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HIDET_HOME/build/lib

To avoid repeating above commands, it is recommended to put above commands to your shell's initialization script (e.g., ``~/.bashrc`` for Bash and ``~/.zshrc`` for Zsh).

Validation
~~~~~~~~~~

To make sure we have successfully installed hidet, run the following command in a new shell:
To verify the installation, run the following command:

.. code-block:: console

$ python -c "import hidet"

If no error reports, then hidet has been successfully installed on your computer.
If you want, you can also :doc:`build from source </getting-started/build-from-source>`.

.. toctree::
:hidden:

build-from-source
9 changes: 3 additions & 6 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
Welcome to Hidet's Documentation
================================

.. note::

Hidet has not been open-sourced yet. Please do not distribute this website.

Hidet is an open-source DNN inference framework, it features

- **Ease of Use**: Support end to end inference given a model in ONNX format.
- **Ease of Use**: Support end to end inference for PyTorch and ONNX models.
- **High Performance**: Graph-level optimizations and operator-level kernel tuning.
- **Extensibility**: Easy to add new operators and new hardware backends.
- **Extensibility**: Easy to add new operators, and fusion patterns.
- **Python Oriented**: All core components are written in Python.


.. toctree::
Expand Down
8 changes: 8 additions & 0 deletions docs/source/python_api/graph/frontend/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
hidet.graph.frontend
====================

.. toctree::
:caption: Submodules

onnx
torch
9 changes: 4 additions & 5 deletions docs/source/python_api/graph/frontend/onnx.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
hidet.graph.frontend
--------------------
hidet.graph.frontend.onnx
-------------------------

.. autofunction:: hidet.graph.frontend.from_onnx

.. automodule:: hidet.graph.frontend.onnx
:members:
:autosummary:
7 changes: 7 additions & 0 deletions docs/source/python_api/graph/frontend/torch.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
hidet.graph.frontend.torch
--------------------------

.. autofunction:: hidet.graph.frontend.from_torch

.. autoclass:: hidet.graph.frontend.torch.DynamoConfig
:members:
4 changes: 2 additions & 2 deletions docs/source/python_api/graph/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ hidet.graph
.. toctree::
:caption: Submodules

frontend/onnx
ops/index
frontend/index
transforms/index


.. automodule:: hidet.graph
:members:
:imported-members:
:special-members: __call__
:exclude-members: Tensor
:autosummary:
7 changes: 7 additions & 0 deletions docs/source/python_api/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Python API
==========

.. note::

We are actively working on adding more api documentation.


.. toctree::
:maxdepth: 1
:caption: Python API
Expand All @@ -9,6 +14,8 @@ Python API
option
driver
cuda
tensor
ops/index
ir/index
graph/index
runtime/index
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
hidet.graph.ops
===============
hidet.ops
=========

.. todo::

We are still working on the documentation of operators.

.. automodule:: hidet.graph.ops
.. automodule:: hidet.ops
:members:
:undoc-members:
:imported-members:
Expand Down
38 changes: 38 additions & 0 deletions docs/source/python_api/tensor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
hidet.Tensor
============


.. autoclass:: hidet.Tensor

.. autoattribute:: shape
.. autoattribute:: dtype
.. autoattribute:: device
.. autoattribute:: size
.. autoattribute:: nbytes
.. autoattribute:: storage
.. autoattribute:: trace
.. autoattribute:: op
.. autoattribute:: layout
.. automethod:: tolist
.. automethod:: to_device
.. automethod:: astype
.. automethod:: cpu
.. automethod:: cuda
.. automethod:: copy
.. automethod:: cpu_async
.. automethod:: cuda_async
.. automethod:: copy_async
.. automethod:: detach
.. automethod:: numpy
.. automethod:: torch
.. automethod:: to
.. automethod:: item
.. automethod:: signature
.. automethod:: is_symbolic
.. automethod:: contiguous
.. automethod:: reshape
.. automethod:: squeeze
.. automethod:: unsqueeze
.. automethod:: rearrange
.. automethod:: sum
.. automethod:: mean