Skip to content

Commit

Permalink
Add binary tests for XNNPACK library (pytorch#964)
Browse files Browse the repository at this point in the history
  • Loading branch information
digantdesai authored Feb 24, 2022
1 parent 4c35239 commit f75b01a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
22 changes: 19 additions & 3 deletions check_binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ set -eux -o pipefail
# this is currently not true)
# 4. Standard Python imports work
# 5. MKL is available everywhere except for MacOS wheels
# 6. CUDA is setup correctly and does not hang
# 7. Magma is available for CUDA builds
# 8. CuDNN is available for CUDA builds
# 6. XNNPACK is available everywhere except for MacOS wheels
# 7. CUDA is setup correctly and does not hang
# 8. Magma is available for CUDA builds
# 9. CuDNN is available for CUDA builds
#
# This script needs the env variables DESIRED_PYTHON, DESIRED_CUDA,
# DESIRED_DEVTOOLSET and PACKAGE_TYPE
Expand Down Expand Up @@ -326,6 +327,21 @@ else
fi
fi

###############################################################################
# Check for XNNPACK
###############################################################################

if [[ "$PACKAGE_TYPE" == 'libtorch' ]]; then
echo "Checking that XNNPACK is available"
build_and_run_example_cpp check-torch-xnnpack
else
if [[ "$(uname)" != 'Darwin' || "$PACKAGE_TYPE" != *wheel ]]; then
echo "Checking that XNNPACK is available"
pushd /tmp
python -c 'import torch.backends.xnnpack; exit(0 if torch.backends.xnnpack.enabled else 1)'
popd
fi
fi

###############################################################################
# Check CUDA configured correctly
Expand Down
7 changes: 7 additions & 0 deletions test_example_code/check-torch-xnnpack.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <ATen/ATen.h>
#include <torch/torch.h>

int main(int argc, const char* argv[]) {
TORCH_CHECK(at::globalContext().isXNNPACKAvailable(), "XNNPACK is not available");
return 0;
}

0 comments on commit f75b01a

Please sign in to comment.