Commit Graph

20 Commits

Author SHA1 Message Date
d8c8ba2440 Fix unused Python variables in test/[e-z]* (#136964)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/136964
Approved by: https://github.com/justinchuby, https://github.com/albanD
2024-12-18 23:02:30 +00:00
ba3cd6e463 Enable UFMT on test/test_fake_tensor.py, test/test_flop_counter.py and some files (#125747)
Part of: #123062

Ran lintrunner on:

- test/test_fake_tensor.py
- test/test_flop_counter.py
- test/test_function_schema.py
- test/test_functional_autograd_benchmark.py
- test/test_functional_optim.py
- test/test_functionalization_of_rng_ops.py

Detail:

```bash
$ lintrunner -a --take UFMT --all-files
ok No lint issues.
Successfully applied all patches.
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/125747
Approved by: https://github.com/malfet
2024-05-15 14:50:14 +00:00
6676193b5e [frontend] Expose real_type getter for torch.Argument (#91938)
Exposing an API to get real_type from an Argument. This is useful for Argument types such as SymInt.

Differential Revision: [D42425661](https://our.internmc.facebook.com/intern/diff/D42425661/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/91938
Approved by: https://github.com/ezyang
2023-01-12 01:26:50 +00:00
17bc40c19d add __hash__ to FunctionSchema (#90730)
This PR adds __hash__ to FunctionSchema pybind binding, so that
it could be used for things like dict indexing
Pull Request resolved: https://github.com/pytorch/pytorch/pull/90730
Approved by: https://github.com/ezyang
2023-01-04 18:59:22 +00:00
b1f5644fad [frontend] Print real type for Argument (#85103)
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
2022-09-15 22:16:32 +00:00
a8a36c45a6 [frontend] Fix tensor list alias annotation (#84005)
For issue https://github.com/pytorch/pytorch/issues/77920 and a retry of https://github.com/pytorch/pytorch/pull/83921

The current logic checks alias info before `[]` and after. If no alias info exists after `[]`, we overwrite the alias info before. This logic failed on argument like `Tensor(a!)[]`, dropping the alias info before `[]` on the floor. This PR adds a new alias info if it's missing after `[]`. This way we can keep the alias info before `[]`.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/84005
Approved by: https://github.com/cccclai, https://github.com/bdhirsh
2022-08-24 19:50:19 +00:00
c7e9eea915 Expose is_out to python
Pull Request resolved: https://github.com/pytorch/pytorch/pull/78591

Approved by: https://github.com/zhxchen17
2022-06-01 07:39:24 +00:00
8bdbe94344 Add forward compatability tests in CI (#64139)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/64139

Test Plan: Imported from OSS

Reviewed By: mruberry

Differential Revision: D30626912

Pulled By: tugsbayasgalan

fbshipit-source-id: 781a88386701b42e2e86daaca0a779d1fc1c4df3
2022-01-05 23:40:06 -08:00
6259601c8a Set test owners for tests with unknown owners (#67552)
Summary:
Action following https://github.com/pytorch/pytorch/issues/66232

Pull Request resolved: https://github.com/pytorch/pytorch/pull/67552

Reviewed By: jbschlosser

Differential Revision: D32028248

Pulled By: janeyx99

fbshipit-source-id: a006f7026288b7126dba58b31cac28e10ce0fed6
2021-10-29 12:42:01 -07:00
19c1b45f25 Detect out argument in the schema (#62755)
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
2021-08-27 11:20:33 -07:00
1022443168 Revert D30279364: [codemod][lint][fbcode/c*] Enable BLACK by default
Test Plan: revert-hammer

Differential Revision:
D30279364 (b004307252)

Original commit changeset: c1ed77dfe43a

fbshipit-source-id: eab50857675c51e0088391af06ec0ecb14e2347e
2021-08-12 11:45:01 -07:00
b004307252 [codemod][lint][fbcode/c*] Enable BLACK by default
Test Plan: manual inspection & sandcastle

Reviewed By: zertosh

Differential Revision: D30279364

fbshipit-source-id: c1ed77dfe43a3bde358f92737cd5535ae5d13c9a
2021-08-12 10:58:35 -07:00
a2422cc243 Add stricter check for function schemas with varargs (#56509)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/56509

Test Plan: Imported from OSS

Reviewed By: gmagogsfm

Differential Revision: D27889626

Pulled By: tugsbayasgalan

fbshipit-source-id: 5ff81a313ff53a9519d7dc9f3d6f7234d58af8e2
2021-04-20 20:04:38 -07:00
ef262575dd [pytorch] Fix printing of optional string arguments in schemas (#55196)
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
2021-04-05 15:28:18 -07:00
8a1e100466 Stricter backward compatibility check (#45773)
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
2020-10-06 01:28:48 -07:00
20ac736200 Remove py2 compatible future imports (#44735)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/44735

Reviewed By: mruberry

Differential Revision: D23731306

Pulled By: ezyang

fbshipit-source-id: 0ba009a99e475ddbe22981be8ac636f8a1c8b02f
2020-09-16 12:55:57 -07:00
f050b16dd9 Move pytorch distributed tests to separate folder for contbuild. (#30445)
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
2020-01-22 21:16:59 -08:00
a03581b927 add tests that schemas are valid (#30749)
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
2019-12-09 15:12:13 -08:00
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
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