[jiterator] stricter static_assert (#72576)

Summary:
* static_assert on `jiterator_stringify` usage in ROCm.
* static_assert for `complex<half>`

Pull Request resolved: https://github.com/pytorch/pytorch/pull/72576

Reviewed By: ngimel

Differential Revision: D34387640

Pulled By: mruberry

fbshipit-source-id: d58dbb062c9c301465b9b7e4a56ee3d64baaadf9
(cherry picked from commit 82d2a75519)
This commit is contained in:
kshitij12345 2022-02-22 19:09:34 -08:00 committed by PyTorch MergeBot
parent 9ea6db4aca
commit 299b40de50
2 changed files with 2 additions and 7 deletions

View File

@ -8,7 +8,6 @@
#define AT_USE_JITERATOR() true
#define jiterator_stringify(...) std::string(#__VA_ARGS__);
#else
// TODO: update this to become a static assertion
#define AT_USE_JITERATOR() false
#define jiterator_stringify(...) std::string("Jiterator is disabled");
#define jiterator_stringify(...) static_assert(false, "Jiterator is not supported on ROCm");
#endif // USE_ROCM

View File

@ -53,7 +53,7 @@ struct delayed_false : std::false_type {
template <typename T>
inline std::string typeName() {
// we can't use static_assert(false) directly as the
// program will be not compile even if the template is not
// program will be not compiled even if the template is not
// instantiated, so we use `delayed_false`
// to make sure compiler doesn't eagerly raise
// fail this assertion.
@ -77,10 +77,6 @@ template <> inline std::string typeName<c10::complex<float>>(){
template <> inline std::string typeName<c10::complex<double>>(){
return "std::complex<double>";
}
template <> inline std::string typeName<c10::complex<c10::Half>>(){
TORCH_INTERNAL_ASSERT(false, "torch.complex32 is not supported");
return "std::complex<at::Half>";
}
template <> inline std::string typeName<at::Half>(){
return "at::Half";
}