Add support to to(device) op. (#56857) (#57599)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/57599
Currently, if we call tensor.to() method and pass a device as the parameter. It will fail, because in symbolic function of to() we didn't handle such case.
So add a check in the beginning of this symbolic function, if this is a device cast, we return self directly. A test has also been added.
Test Plan: Imported from OSS
Reviewed By: malfet
Differential Revision: D28393523
Pulled By: SplitInfinity
fbshipit-source-id: c41e3c0293932fc90dedb544daadd9c5d4b48792
Co-authored-by: Jay Zhang <jiz@microsoft.com>