Make sure the ends of linspace are correct regardless of the precision (#91625)
This operation is usually called with small sizes, so the fact that this
adds a couple of operations should be alright. Even more, given the
structure of the data, the branching in the `where` is pretty much free.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/91625
Approved by: https://github.com/peterbell10, https://github.com/ngimel