Skip to content

Commit

Permalink
[docs] Remove empty code blocks (#13689)
Browse files Browse the repository at this point in the history
This removes the linter that checks that each sphinx gallery tutorial begins with the proper boilerplate by extracting it out to sphinx gallery reset functions. This runs automatically so no code in the tutorials nor associated linters are necessary.
  • Loading branch information
driazati authored Jan 12, 2023
1 parent e0c2181 commit 665dd41
Show file tree
Hide file tree
Showing 74 changed files with 24 additions and 533 deletions.
6 changes: 6 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ def rewrite_generic_admonition(match):
return text


def install_request_hook(gallery_conf, fname):
testing.utils.install_request_hook(depth=3)


INSTALL_TVM_DEV = f"""\
%%shell
# Installs the latest dev build of TVM from PyPI. If you wish to build
Expand Down Expand Up @@ -431,6 +435,7 @@ def jupyter_notebook(script_blocks, gallery_conf, target_dir, real_func):
"topic/vta/tutorials",
]


subsection_order = ExplicitOrder(
str(p)
for p in [
Expand Down Expand Up @@ -563,6 +568,7 @@ def force_gc(gallery_conf, fname):
"expected_failing_examples": [],
"reset_modules": ("matplotlib", "seaborn", force_gc),
"promote_jupyter_magic": True,
"reset_modules": (install_request_hook),
}

autodoc_default_options = {
Expand Down
5 changes: 0 additions & 5 deletions gallery/how_to/compile_models/from_coreml.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@
https://github.com/apple/coremltools
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore
import tvm
from tvm import te
import tvm.relay as relay
Expand Down
6 changes: 0 additions & 6 deletions gallery/how_to/compile_models/from_darknet.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

# numpy and matplotlib
import numpy as np
import matplotlib.pyplot as plt
Expand Down
3 changes: 0 additions & 3 deletions gallery/how_to/compile_models/from_keras.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@

# sphinx_gallery_start_ignore
# sphinx_gallery_requires_cuda = True
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore
import tvm
from tvm import te
Expand Down
5 changes: 1 addition & 4 deletions gallery/how_to/compile_models/from_mxnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@
https://mxnet.apache.org/versions/master/install/index.html
"""

# some standard imports
# sphinx_gallery_start_ignore
# sphinx_gallery_requires_cuda = True
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore
# some standard imports
import mxnet as mx
import tvm
import tvm.relay as relay
Expand Down
3 changes: 0 additions & 3 deletions gallery/how_to/compile_models/from_oneflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@

# sphinx_gallery_start_ignore
# sphinx_gallery_requires_cuda = True
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore
import os, math
from matplotlib import pyplot as plt
Expand Down
5 changes: 0 additions & 5 deletions gallery/how_to/compile_models/from_onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
https://github.com/onnx/onnx
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore
import onnx
import numpy as np
import tvm
Expand Down
5 changes: 0 additions & 5 deletions gallery/how_to/compile_models/from_paddle.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@
https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore
import tarfile
import paddle
import numpy as np
Expand Down
6 changes: 0 additions & 6 deletions gallery/how_to/compile_models/from_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@
be unstable.
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

import tvm
from tvm import relay

Expand Down
6 changes: 0 additions & 6 deletions gallery/how_to/compile_models/from_tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@
Please refer to https://www.tensorflow.org/install
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

# tvm, relay
import tvm
from tvm import te
Expand Down
6 changes: 0 additions & 6 deletions gallery/how_to/compile_models/from_tflite.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@
# Utils for downloading and extracting zip files
# ----------------------------------------------

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

import os


Expand Down
6 changes: 0 additions & 6 deletions gallery/how_to/deploy_models/deploy_model_on_adreno.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,6 @@
# -----------------
# As an example we would use classical cat image from ImageNet

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

from PIL import Image
from tvm.contrib.download import download_testdata
from matplotlib import pyplot as plt
Expand Down
5 changes: 0 additions & 5 deletions gallery/how_to/deploy_models/deploy_model_on_android.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
This is an example of using Relay to compile a keras model and deploy it on Android device.
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

import os
import numpy as np
Expand Down
4 changes: 0 additions & 4 deletions gallery/how_to/deploy_models/deploy_model_on_nano.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@

# sphinx_gallery_start_ignore
# sphinx_gallery_requires_cuda = True
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

import tvm
from tvm import te
import tvm.relay as relay
Expand Down
6 changes: 0 additions & 6 deletions gallery/how_to/deploy_models/deploy_model_on_rasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@
it on Raspberry Pi.
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

import tvm
from tvm import te
import tvm.relay as relay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@
be unstable.
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

import tvm
from tvm import relay
from tvm import relay
Expand Down
5 changes: 0 additions & 5 deletions gallery/how_to/deploy_models/deploy_prequantized.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
Once loaded, we can run compiled, quantized models on any hardware TVM supports.
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

#################################################################################
# First, necessary imports
Expand Down
5 changes: 0 additions & 5 deletions gallery/how_to/deploy_models/deploy_prequantized_tflite.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

###############################################################################
# Necessary imports
Expand Down
5 changes: 0 additions & 5 deletions gallery/how_to/deploy_models/deploy_quantized.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
Relay, quantize the Relay model and then perform the inference.
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

import tvm
from tvm import te
Expand Down
5 changes: 0 additions & 5 deletions gallery/how_to/deploy_models/deploy_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@
sparse speed using fake weights to see the benefit of structured sparsity.
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

###############################################################################
# Load Required Modules
Expand Down
5 changes: 0 additions & 5 deletions gallery/how_to/deploy_models/deploy_ssd_gluoncv.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
We will use GluonCV pre-trained SSD model and convert it to Relay IR
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore
import tvm
from tvm import te

Expand Down
5 changes: 0 additions & 5 deletions gallery/how_to/extend_tvm/bring_your_own_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@
ctypes.CDLL('my-datatype-lib.so', ctypes.RTLD_GLOBAL)
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

######################
# A Simple TVM Program
Expand Down
5 changes: 0 additions & 5 deletions gallery/how_to/extend_tvm/low_level_custom_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore
import tvm
from tvm import te
import numpy as np
Expand Down
5 changes: 0 additions & 5 deletions gallery/how_to/extend_tvm/use_pass_infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@
The same approach can be used for tir as well.
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

import numpy as np
import tvm
Expand Down
5 changes: 0 additions & 5 deletions gallery/how_to/extend_tvm/use_pass_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@
passes. Please also refer to the :ref:`pass-infra`.
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore
import tvm
import tvm.relay as relay
from tvm.relay.testing import resnet
Expand Down
10 changes: 3 additions & 7 deletions gallery/how_to/optimize_operators/opt_conv_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@
"""

# sphinx_gallery_start_ignore
# sphinx_gallery_requires_cuda = True
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

################################################################
# Preparation and Algorithm
# -------------------------
Expand All @@ -47,6 +40,9 @@
# convolution. The following code defines the convolution algorithm in TVM.
#

# sphinx_gallery_start_ignore
# sphinx_gallery_requires_cuda = True
# sphinx_gallery_end_ignore
import numpy as np
import tvm
from tvm import te
Expand Down
4 changes: 0 additions & 4 deletions gallery/how_to/optimize_operators/opt_conv_tensorcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@

# sphinx_gallery_start_ignore
# sphinx_gallery_requires_cuda = True
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

import tvm
from tvm import te
import numpy as np
Expand Down
5 changes: 0 additions & 5 deletions gallery/how_to/optimize_operators/opt_gemm.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@
Intel i7-4770HQ CPU. The cache line size should be 64 bytes for all the x86 CPUs.
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

################################################################################################
# Preparation and Baseline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@

# sphinx_gallery_start_ignore
# sphinx_gallery_requires_cuda = True
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

import os

import numpy as np
Expand Down
5 changes: 0 additions & 5 deletions gallery/how_to/tune_with_autoscheduler/tune_network_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@
__name__ == "__main__":` block.
"""

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

import numpy as np
import os
Expand Down
Loading

0 comments on commit 665dd41

Please sign in to comment.