mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
It is better to have the new tracer as global config that can be manipulated easily. Also I believe dynamo-like config infra is useful instead of relying on custom way of patching stuff. Differential Revision: [D82478649](https://our.internmc.facebook.com/intern/diff/D82478649) Pull Request resolved: https://github.com/pytorch/pytorch/pull/162558 Approved by: https://github.com/zhxchen17 ghstack dependencies: #162557
54 lines
1.3 KiB
Python
54 lines
1.3 KiB
Python
# Owner(s): ["oncall: export"]
|
|
|
|
try:
|
|
from . import test_export, testing
|
|
except ImportError:
|
|
import test_export # @manual=fbcode//caffe2/test:test_export-library
|
|
import testing # @manual=fbcode//caffe2/test:test_export-library
|
|
|
|
from torch._export import config
|
|
from torch.export import export
|
|
|
|
|
|
test_classes = {}
|
|
|
|
|
|
def mocked_strict_export_v2(*args, **kwargs):
|
|
# If user already specified strict, don't make it strict
|
|
with config.patch(use_new_tracer_experimental=True):
|
|
if "strict" in kwargs:
|
|
return export(*args, **kwargs)
|
|
return export(*args, **kwargs, strict=True)
|
|
|
|
|
|
def make_dynamic_cls(cls):
|
|
cls_prefix = "StrictExportV2"
|
|
|
|
test_class = testing.make_test_cls_with_mocked_export(
|
|
cls,
|
|
cls_prefix,
|
|
test_export.STRICT_EXPORT_V2_SUFFIX,
|
|
mocked_strict_export_v2,
|
|
xfail_prop="_expected_failure_strict_v2",
|
|
)
|
|
|
|
test_classes[test_class.__name__] = test_class
|
|
# REMOVING THIS LINE WILL STOP TESTS FROM RUNNING
|
|
globals()[test_class.__name__] = test_class
|
|
test_class.__module__ = __name__
|
|
return test_class
|
|
|
|
|
|
tests = [
|
|
test_export.TestDynamismExpression,
|
|
test_export.TestExport,
|
|
]
|
|
for test in tests:
|
|
make_dynamic_cls(test)
|
|
del test
|
|
|
|
if __name__ == "__main__":
|
|
from torch._dynamo.test_case import run_tests
|
|
|
|
run_tests()
|