Skip to content

TestNNAPI fails when not build with QNNPACK #82810

@Flamefire

Description

@Flamefire

🐛 Describe the bug

Since 3802edd there is a TestNNAPI test case which in its setUp unconditionally loads QNNPACK:

torch.backends.quantized.engine = 'qnnpack'

So when PyTorch is built without it this will hard error:

======================================================================
ERROR: test_unsqueeze (jit.test_backend_nnapi.TestNnapiBackend)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/dev/shm/s3248973-EasyBuild/PyTorch/1.10.0/foss-2021a/pytorch/test/jit/test_backend_nnapi.py", line 37, in setUp
    super().setUp()
  File "/dev/shm/s3248973-EasyBuild/PyTorch/1.10.0/foss-2021a/pytorch/test/test_nnapi.py", line 25, in setUp
    torch.backends.quantized.engine = 'qnnpack'
  File "/tmp/easybuild-tmp/eb-5FO9wX/tmpIMOoeD/lib/python3.9/site-packages/torch/backends/quantized/__init__.py", line 29, in __set__
    torch._C._set_qengine(_get_qengine_id(val))
RuntimeError: quantized engine QNNPACK is not supported

I'm not sure what the correct way to solve this here is:

  • Skip the test if no QNNPACK is there
  • Don't set it there if it isn't available

Versions

Affected is 1.9.0 and higher.

cc @albanD @mruberry @jbschlosser @walterddr @kshitij12345 @saketh-are

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: nnRelated to torch.nnmodule: testsIssues related to tests (not the torch.testing module)triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions