Try fix XLAPreAutograd with *_like functions. (#33848)
Summary:
In *_like functions we call
`globalLegacyTypeDispatch().initForDispatchKeySet(c10::detail::multi_dispatch_key_set(self, options));` -> `dispatchKeyToBackend` and thus this change.
`self` has both `XLAPreAutograd` and `XLATensorId` in key set.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33848
Differential Revision: D20135898
Pulled By: ailzhang
fbshipit-source-id: a8585f39f3fa77b53718f20d3144f4f2f3cb8e53
diff --git a/c10/core/Backend.h b/c10/core/Backend.h
index 1310203..5f3d8c7 100644
--- a/c10/core/Backend.h
+++ b/c10/core/Backend.h
@@ -80,7 +80,7 @@
return Backend::HIP;
} else if (t == DispatchKey::MSNPUTensorId) {
return Backend::MSNPU;
- } else if (t == DispatchKey::XLATensorId) {
+ } else if (t == DispatchKey::XLATensorId || t == DispatchKey::XLAPreAutograd) {
return Backend::XLA;
} else if (t == DispatchKey::SparseCPUTensorId) {
return Backend::SparseCPU;