[ao][docs] tests for quantization docs (#79923)

Summary: per https://github.com/pytorch/pytorch/issues/79135 the code
snippets in the docs don't run. This is a recurring problem since
previously there was no unit test to check that these code snippets
actually ran. This PR adds support for such a test, importing the
snippet as a string and evaluating it to make sure that it actually runs
if the code snippet has user defined code, you can pass in dummy
versions using global_inputs. Sometimes the imports of the code snippets
behave oddly but you can pass them in as in test_quantization_doc_custom
where nnq is passed in.

Test Plan: python test/test_quantization.py TestQuantizationDocs
also see https://github.com/pytorch/pytorch/pull/79994 to see what shows up in CI when the docs get broken

Reviewers:

Subscribers:

Tasks:

Tags:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/79923
Approved by: https://github.com/z-a-f, https://github.com/vspenubarthi
This commit is contained in:
HDCharles
2022-06-23 10:37:53 -07:00
committed by PyTorch MergeBot
parent da33c93169
commit ffdc5eebc7
3 changed files with 274 additions and 124 deletions

View File

@ -37,7 +37,7 @@ from quantization.core.test_workflow_module import TestHistogramObserver # noqa
from quantization.core.test_workflow_module import TestDistributed # noqa: F401
from quantization.core.test_workflow_module import TestFusedObsFakeQuantModule # noqa: F401
from quantization.core.test_utils import TestUtils # noqa: F401
from quantization.core.test_docs import TestQuantizationDocs # noqa: F401
# Eager Mode Workflow. Tests for the functionality of APIs and different features implemented
# using eager mode.