Make `_get_perspective_coeffs` device agnostic
Context
This PR is an attempt to solve the issue mentioned in #9076 and explicitly accept tensor on any device as input for the function _get_perspective_coeffs.
proposed solution
This PR proposes to cast startpoints and endpoints as Tensor if a List[List[int]] is passed as input. We then modify how the a_matrix is build to avoid the for loop and make sure the construction of the matrix is compatible with torchscript. The b_matrix is then directly constructed from startpoints (reshaping and modifying the precision).
Testing
We add one test (test_perspective_tensor_input) to make sure the function is compatible with tensor inputs.
pytest test/test_functional_tensor.py -vvv -k test_perspective
...
337 passed, 336 skipped, 21843 deselected in 5.75s (on CPU machine)
:link: Helpful Links
:test_tube: See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9082
- :page_facing_up: Preview Python docs built from this PR
Note: Links to docs will display an error until the docs builds have been completed.
This comment was automatically generated by Dr. CI and updates every 15 minutes.