Commit 0cbe521b authored by Lingfan Yu's avatar Lingfan Yu Committed by Minjie Wang
Browse files

[Doc] Fix document building for multiple tensor backends (#301)

* remove loading backend in sse

* build mxnet in a second run

* a third run to fix everything

* fix docstring in sampler

* fix docstring in transformer

* README for doc build

* some reordering and printing

* use filename_pattern instead of ignore_pattern to reduce warning at the cost of redundant work...

* add env var to use mxnet in Jenkinsfile

* remove step 3, it's already fixed by previous commit
parent af23c457
...@@ -55,7 +55,7 @@ def pytorch_tutorials() { ...@@ -55,7 +55,7 @@ def pytorch_tutorials() {
} }
def mxnet_tutorials() { def mxnet_tutorials() {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build", "PYTHONPATH=${env.WORKSPACE}/python"]) { withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build", "PYTHONPATH=${env.WORKSPACE}/python", "DGLBACKEND=mxnet"]) {
dir("tests/scripts") { dir("tests/scripts") {
sh "bash task_mxnet_tutorial_test.sh" sh "bash task_mxnet_tutorial_test.sh"
} }
......
...@@ -13,12 +13,32 @@ help: ...@@ -13,12 +13,32 @@ help:
.PHONY: help Makefile .PHONY: help Makefile
mxnet:
@echo "##################################################################"
@echo "# #"
@echo "# Step 1: Building MXNet tutorials #"
@echo "# #"
@echo "##################################################################"
@DGLBACKEND=mxnet $(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \
-D sphinx_gallery_conf.filename_pattern="/*(?<=mx)\.py"
pytorch:
@echo "##################################################################"
@echo "# #"
@echo "# Step 2: Building PyTorch tutorials #"
@echo "# #"
@echo "##################################################################"
@DGLBACKEND=pytorch $(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \
-D sphinx_gallery_conf.filename_pattern="/*(?<!mx)\.py"
html-noexec: html-noexec:
$(SPHINXBUILD) -D plot_gallery=0 -b html "$(SOURCEDIR)" "$(BUILDDIR)/html" $(SPHINXBUILD) -D plot_gallery=0 -b html "$(SOURCEDIR)" "$(BUILDDIR)/html"
@echo @echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html." @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
html: Makefile mxnet pytorch
# Catch-all target: route all unknown targets to Sphinx using the new # Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile %: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
DGL document and tutorial folder DGL document and tutorial folder
================================ ================================
To build, Build documents
---------------
First, clean up existing files:
```
./clean.sh
```
Then build:
``` ```
make html make html
``` ```
and then render the page `build/html/index.html`. Note: due to the backend loading issue, it actually takes 2 rounds to build:
1. build tutorials that uses MXNet as backend
2. build tutorials that uses PyTorch as backend
Render locally
--------------
```
cd build/html
python3 -m http.server 8000
```
...@@ -99,8 +99,10 @@ def NeighborSampler(g, batch_size, expand_factor, num_hops=1, ...@@ -99,8 +99,10 @@ def NeighborSampler(g, batch_size, expand_factor, num_hops=1,
The subgraph loader returns a list of subgraphs and a dictionary of additional The subgraph loader returns a list of subgraphs and a dictionary of additional
information about the subgraphs. The size of the subgraph list is the number of workers. information about the subgraphs. The size of the subgraph list is the number of workers.
The dictionary contains: The dictionary contains:
'seeds': a list of 1D tensors of seed Ids, if return_seed_id is True.
- seeds: a list of 1D tensors of seed Ids, if return_seed_id is True.
Parameters Parameters
---------- ----------
......
...@@ -92,9 +92,6 @@ Stochastic Steady-state Embedding (SSE) ...@@ -92,9 +92,6 @@ Stochastic Steady-state Embedding (SSE)
import mxnet as mx import mxnet as mx
import os import os
import dgl import dgl
# DGL backend defaults to PyTorch, so we need to switch backend.
# One can also set the environment variable outside Python.
dgl.load_backend('mxnet')
def T(g): def T(g):
def message_func(edges): def message_func(edges):
......
...@@ -219,12 +219,12 @@ Transformer Tutorial ...@@ -219,12 +219,12 @@ Transformer Tutorial
# function, including: # function, including:
# #
# - ``fn.src_mul_egdes(src_field, edges_field, out_field)`` multiplies # - ``fn.src_mul_egdes(src_field, edges_field, out_field)`` multiplies
# source’s attribute and edges attribute, and send the result to the # source’s attribute and edges attribute, and send the result to the
# destination node’s mailbox keyed by ``out_field``. # destination node’s mailbox keyed by ``out_field``.
# - ``fn.copy_edge(edges_field, out_field)`` copies edge’s attribute to # - ``fn.copy_edge(edges_field, out_field)`` copies edge’s attribute to
# destination node’s mailbox. # destination node’s mailbox.
# - ``fn.sum(edges_field, out_field)`` sums up # - ``fn.sum(edges_field, out_field)`` sums up
# edge’s attribute and sends aggregation to destination node’s mailbox. # edge’s attribute and sends aggregation to destination node’s mailbox.
# #
# Here we assemble those built-in function into ``propagate_attention``, # Here we assemble those built-in function into ``propagate_attention``,
# which is also the main graph operation function in our final # which is also the main graph operation function in our final
...@@ -540,6 +540,7 @@ Transformer Tutorial ...@@ -540,6 +540,7 @@ Transformer Tutorial
# print(graph.tgt[0]) # Output word index list # print(graph.tgt[0]) # Output word index list
# print(graph.tgt[1]) # Ouptut positions # print(graph.tgt[1]) # Ouptut positions
# break # break
#
# Output: # Output:
# #
# .. code:: # .. code::
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment