Retry of [#84985](https://github.com/pytorch/pytorch/pull/84985). For some reason `ghstack land` doesn't work on that PR
In JIT world, if we parse an argument in schema and print its type, we always get `fake_type`. For example, `MemoryFormat? memory_format` becomes `int? memory_format`. This doesn't align with the original schema string and creates discrepency between `torchgen.FunctionSchema` and `torch._C.FunctionSchema`. Here I'm letting `torch._C.Argument` print its `real_type` and hence be aligned with the original schema string.
Rely on newly added unit test.
Differential Revision: [D39550665](https://our.internmc.facebook.com/intern/diff/D39550665)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/85103
Approved by: https://github.com/cccclai
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/62755
After this change, out argument can be checked by calling is_out()
Test Plan: Imported from OSS
Reviewed By: mruberry
Differential Revision: D30415256
Pulled By: tugsbayasgalan
fbshipit-source-id: b2e1fa46bab7c813aaede1f44149081ef2df566d
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/55196
This commit fixes printing of default values for optional string type arguments in schemas. At the moment, these default values are not printed as quoted strings. If a schema with an optional string type parameter with a default value that is not `None` is printed and then parsed, the lack of quotes causes a parsing error.
ghstack-source-id: 125655241
Test Plan: This commit adds a unit test to `test_function_schema.py` to test this case.
Differential Revision: D27525450
fbshipit-source-id: 23a93169e7599e7b385e59b7cfafb17fd76318b7
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/45773
Changes the function schema's backward compatibility check to be stricter to comply with C++ API backwards compatibility capabilities.
ghstack-source-id: 113537304
Test Plan:
Updated and added tests to test_function_schema.py
Browsed through several commits to native_functions.yaml and derivatives.yaml and I don't see instances where new arguments where not already being appended.
Reviewed By: dzhulgakov
Differential Revision: D24089751
fbshipit-source-id: a21f407cdc750906d3326e3ea27928b8aa732804
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30445
Create distributed and rpc directories under caffe/test for better management
of unit tests.
Differential Revision: D18702786
fbshipit-source-id: e9daeed0cfb846ef68806f6decfcb57c0e0e3606
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30749
Add check to schemas that the schema is sane.
I removed the defaults from symbolic_script because they were in some cases wrong and don't actually do anything. At the point they're invoked the forward should already have matched all arguments.
Test Plan: Imported from OSS
Differential Revision: D18864775
Pulled By: eellison
fbshipit-source-id: 273d7e96d65b8a3d3de72e2d7bfcdf2417046c6b
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
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