mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/21438 ghimport-source-id: 33f145f5b3508163365442c22a223c4a44e677d8 Differential Revision: D15738856 fbshipit-source-id: 656e8d0e3d0d22f116e3ab66bf0282608d6f1a76
21 lines
766 B
Python
21 lines
766 B
Python
import torch
|
|
from common_utils import TestCase, run_tests
|
|
|
|
|
|
class LoggingTest(TestCase):
|
|
def testApiUsage(self):
|
|
"""
|
|
This test verifies that api usage logging is not triggered via static
|
|
initialization. Since it's triggered at first invocation only - we just
|
|
subprocess
|
|
"""
|
|
s = TestCase.runWithPytorchAPIUsageStderr("import torch")
|
|
self.assertRegexpMatches(s, "PYTORCH_API_USAGE.*import")
|
|
# import the shared library directly - it triggers static init but doesn't call anything
|
|
s = TestCase.runWithPytorchAPIUsageStderr("from ctypes import CDLL; CDLL('{}')".format(torch._C.__file__))
|
|
self.assertNotRegexpMatches(s, "PYTORCH_API_USAGE")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
run_tests()
|