1#!/bin/bash 2__doc__=" 3This script simply runs the torch doctests via the xdoctest runner. 4 5This must be run from the root of the torch repo, as it needs the path to the 6torch source code. 7 8This script is provided as a developer convenience. On the CI the doctests are 9invoked in 'run_test.py' 10" 11# To simply list tests 12# xdoctest -m torch --style=google list 13 14# Reference: https://stackoverflow.com/questions/59895/bash-script-dir 15SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 16TORCH_MODPATH=$SCRIPT_DIR/../torch 17echo "TORCH_MODPATH = $TORCH_MODPATH" 18 19if [[ ! -d "$TORCH_MODPATH" ]] ; then 20 echo "Could not find the path to the torch module" 21else 22 export XDOCTEST_GLOBAL_EXEC="from torch import nn\nimport torch.nn.functional as F\nimport torch" 23 export XDOCTEST_OPTIONS="+IGNORE_WHITESPACE" 24 # Note: google wont catch numpy style docstrings (a few exist) but it also wont fail 25 # on things not intended to be doctests. 26 export XDOCTEST_STYLE="google" 27 xdoctest torch "$TORCH_MODPATH" --style="$XDOCTEST_STYLE" --global-exec "$XDOCTEST_GLOBAL_EXEC" --options="$XDOCTEST_OPTIONS" 28fi 29