mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
Summary: expose necessary functions to python, and add round-way tests for function schema str() and parsing functions. We iterate over all the registered function schemas and get the string, then parse the string. We compare the schema generated from parsing with the original one, and make sure they are equal. Pull Request resolved: https://github.com/pytorch/pytorch/pull/23208 ghstack-source-id: 89638026 Test Plan: buck test //caffe2/test:function_schema Reviewed By: zrphercule Differential Revision: D16435471 fbshipit-source-id: 6961ab096335eb88a96b132575996c24090fd4c0
19 lines
570 B
Python
19 lines
570 B
Python
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
|
|
import torch
|
|
from common_utils import TestCase, run_tests
|
|
|
|
|
|
class TestFunctionSchema(TestCase):
|
|
def test_serialize_and_deserialize(self):
|
|
schemas = torch._C._jit_get_all_schemas()
|
|
# so far we have around 1700 registered schemas
|
|
self.assertGreater(len(schemas), 1000)
|
|
for schema in schemas:
|
|
parsed_schema = torch._C.parse_schema(str(schema))
|
|
self.assertEqual(parsed_schema, schema)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
run_tests()
|