This PR adds refs for the following ops:
- `torch.triu`
- `torch.tril`
- `torch.triu_indices`
- `torch.tril_indices`
- `torch.nn.functional.pairwise_distance`
- `torch.nn.functional.pdist`
It adds OpInfos for
- `torch.triu_indices`
- `torch.tril_indices`
Note that these were already tested in `test/test_tensor_creation_ops.py`
but for the ref tests we need the OpInfos.
Finally, it improves documentation for PairwiseDistance and adds
a missing import to `torch/testing/_internal/opinfo/core.py`.
This started with an attempt to just add the `nn.functional` refs above,
but it turned out that `pdist` was easiest to implement using `triu_indices`
so I added that one and the related functions as well.
~~In the end, I changed the `pdist` implementation to not use `triu_indices`
but kept the other refs.~~
Pull Request resolved: https://github.com/pytorch/pytorch/pull/82819
Approved by: https://github.com/ngimel
Ref #82518
The moves `python_ref_db` entries for `torch.fft` into
`opinfo/definitions/fft.py`.
I ran into a problem with `_find_referenced_opinfo` since it's called
at init time for the module, yet relies on the completed op_db list.
This PR fixes the circular dependency by explicitly passing in an
op_db argument which can point to only the locally defined `op_db`.
An alternative solution would be to have a different folder for the
`op_db` and the `python_ref_db` definitions. However that would mean
losing the convenience of having closely related opinfos be in the
same file.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/83277
Approved by: https://github.com/albanD
Similar to #82984, this PR fixes the error inputs for linalg.lstsq.
It also also asserts that SampleInput's args must be a
tuple and kwargs (after handling None) must be a dict, and fixes one
other sample input.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/83004
Approved by: https://github.com/Chillee
The `ref` property was moved down from `{Unary,Binary}UfuncInfo` into
`OpInfo` quite some time ago, but `OpInfo` uses `None` to signal no
reference is available while the others use `_NOTHING`. This makes
everything consistently use `None`.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/82348
Approved by: https://github.com/ngimel
The `ref` property was moved down from `{Unary,Binary}UfuncInfo` into
`OpInfo` quite some time ago, but `OpInfo` uses `None` to signal no
reference is available while the others use `_NOTHING`. This makes
everything consistently use `None`.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/82348
Approved by: https://github.com/ngimel
Ref #82518
Starting small to minimize merge conflicts, this moves the top-level
class definitions and some helper functions into the `opinfos` folder.
It also brings `common_methods_invocations.py` to just below 1MB.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/82540
Approved by: https://github.com/albanD