Skip to content

Commit

Permalink
Add documentations (pytorch#1144)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#1144

Add fbgemm_gpu docs similar to https://pytorch.org/torchrec/

Reviewed By: malfet

Differential Revision: D36271013

fbshipit-source-id: e2061f04cf9999b18001cc6c204acb4de49f481e
  • Loading branch information
Rostyslav Geyyer authored and facebook-github-bot committed Jun 17, 2022
1 parent 572c28b commit 0f7b91f
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 1 deletion.
79 changes: 79 additions & 0 deletions .github/workflows/fbgemm_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# This workflow builds the fbgemm_gpu docs and deploys them to gh-pages.
name: Generate documentation
on:
push:
branches:
- main
jobs:
build_docs_job:
runs-on: linux.2xlarge
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
# Update references
# TODO: update the git submodule sync after we fixed the auto-sync part
- name: Git Sumbodule Update
run: |
git submodule init
git submodule update --remote --recursive
git log
- name: Update pip
run: |
sudo yum update -y
sudo yum -y install git python3-pip
sudo pip3 install --upgrade pip
- name: Setup conda
run: |
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
- name: setup Path
run: |
echo "/home/ec2-user/miniconda/bin" >> $GITHUB_PATH
echo "CONDA=/home/ec2-user/miniconda" >> $GITHUB_PATH
- name: create conda env
run: |
conda create --name build_binary python=3.9
conda info
- name: check python version
run: |
conda run -n build_binary python --version
- name: Install gcc
shell: bash
run: |
sudo yum group install -y "Development Tools"
- name: Setup Path
run: |
echo /usr/local/bin >> $GITHUB_PATH
- name: Install PyTorch
shell: bash
run: |
conda run -n build_binary python -m pip install --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
- name: Test PyTorch Installation
run: |
conda run -n build_binary python -c "import torch.distributed"
echo "torch.distributed succeeded"
- name: Install fbgemm_gpu nightly
run: |
conda run -n build_binary python -m pip install fbgemm-gpu-nightly-cpu
- name: Test fbgemm_gpu installation
shell: bash
run: |
conda run -n build_binary \
python -c "import fbgemm_gpu"
- name: Build the docset
run: |
conda run -n build_binary python -m pip install -r fbgemm_gpu/docs/requirements.txt
cd ./fbgemm_gpu/docs
conda run -n build_binary make html
cd ..
- name: Get output time
run: echo "The time was ${{ steps.build.outputs.time }}"
- name: Deploy
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: docs/build/html # The folder the action should deploy.
20 changes: 20 additions & 0 deletions fbgemm_gpu/docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
5 changes: 5 additions & 0 deletions fbgemm_gpu/docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sphinx
torch
numpy
# PyTorch Theme
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
65 changes: 65 additions & 0 deletions fbgemm_gpu/docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
import os
import sys

import pytorch_sphinx_theme

sys.path.insert(0, os.path.abspath("../.."))

# -- Project information -----------------------------------------------------

project = "fbgemm"
copyright = "2022, FBGEMM team"
author = "FBGEMM team"

# The full version, including alpha/beta/rc tags
release = "0.1.2"


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ["sphinx.ext.napoleon", "sphinx.ext.autodoc"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "pytorch_sphinx_theme"
html_theme_path = [pytorch_sphinx_theme.get_html_theme_path()]
html_theme_options = {
"pytorch_project": "fbgemm",
"collapse_navigation": True,
"analytics_id": "UA-117752657-2",
}

# 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"]
11 changes: 11 additions & 0 deletions fbgemm_gpu/docs/source/fbgemm_gpu.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fbgemm_gpu
==========

.. automodule:: fbgemm_gpu

fbgemm_gpu.batched_unary_embeddings_ops
---------------------------------------

.. automodule:: fbgemm_gpu.batched_unary_embeddings_ops
:members:
:show-inheritance:
22 changes: 22 additions & 0 deletions fbgemm_gpu/docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.. FBGEMM documentation master file, copied from fbgemm/docs
on Wed Jun 8 17:19:01 2022.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to FBGEMM's documentation!
=======================================

.. toctree::
:maxdepth: 2
:caption: Contents:

:ref:`genindex`

API Documentation
=================

.. toctree::
:maxdepth: 2
:caption: Contents

fbgemm_gpu.rst
5 changes: 4 additions & 1 deletion fbgemm_gpu/fbgemm_gpu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

import torch

torch.ops.load_library(os.path.join(os.path.dirname(__file__), "fbgemm_gpu_py.so"))
try:
torch.ops.load_library(os.path.join(os.path.dirname(__file__), "fbgemm_gpu_py.so"))
except Exception:
print("File fbgemm_gpu_py.so not found")

# __init__.py is only used in OSS
# Use existence to check if fbgemm_gpu_py.so has already been loaded
Expand Down

0 comments on commit 0f7b91f

Please sign in to comment.