Commit Graph

2 Commits

Author SHA1 Message Date
Lu Fang
dc6939ebff Add isBackwardCompatibleWith for Argument and FunctionSchema (#23409)
Summary:
we intend to be conservative, and will relax the checks in future if necessary.
So far, we consider the following three conditions as backward compatible:
   1) two schemas are equal
   2) two schemas have same number of arguments, and this schema's
      arguments are backward compatible with the corresponding ones in
      argument list of old_schema.
   3) this schema has m argument, old_argument has n argument, m > n.
      the first n arguments of this schema are backward compatible with
      the corresponding arguments of old_schema. the remaning arguments
      must be either OptionalType or provide default values.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/23409
ghstack-source-id: 90111021

Test Plan: buck test //caffe2/test:function_schema

Reviewed By: hl475

Differential Revision: D16505203

fbshipit-source-id: e4099537776a60e8945e5c3cd57fa861f3598a9b
2019-09-13 20:37:14 -07:00
Lu Fang
75cac0fe69 expose parse_schema and __eq__ function to python and add round trip tests (#23208)
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
2019-09-06 15:50:56 -07:00