Repository: pytorch
Issue: `C10_HOST_DEVICE` for `std::isnan(c10::complex<T>)`?
Labels: module: cuda,triaged

### 🐛 Describe the bug

I'm developing a C++ & CUDA extension (as part of the [phytorch](https://github.com/kosiokarchev/phytorch) package), and I had written a function `std::isnan(c10::complex<T>)`. However, since v2.0.0, torch includes a similar function in c10/util/complex_utils.h ([link](https://github.com/pytorch/pytorch/blame/75cfc0be21383636d300d702e5eeb66245f93048/c10/util/complex_utils.h#L41)).

My problem is that, unlike most other functions that relate to `c10:complex<T>`, `isnan` is not declared with `__host__ __device__`, and I cannot use it in CUDA code, but I also cannot overwrite it in my code (or can I?), so the compiler now throws an error. Therefore, I'm left with either having to rename my function (or move it to a different namespace), or (instruct my users to) patch the torch headers, which is very undesirable.

Will it be possible to add `C10_HOST_DEVICE` to `isnan` in `complex_utils.h`? Or would you recommend some other way of "using" it in GPU code? Thanks!

### Versions

Collecting environment information...
PyTorch version: 2.0.0
Is debug build: False
CUDA used to build PyTorch: 11.8
ROCM used to build PyTorch: N/A

OS: Rocky Linux release 8.8 (Green Obsidian) (x86_64)
GCC version: (conda-forge gcc 11.3.0-19) 11.3.0
Clang version: Could not collect
CMake version: version 3.20.2
Libc version: glibc-2.28

Python version: 3.10.10 | packaged by conda-forge | (main, Mar 24 2023, 20:08:06) [GCC 11.3.0] (64-bit runtime)
Python platform: Linux-4.18.0-425.19.2.el8_7.x86_64-x86_64-with-glibc2.28
Is CUDA available: True
CUDA runtime version: 11.8.89
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA A100-PCIE-40GB
Nvidia driver version: 525.89.02
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              112
On-line CPU(s) list: 0-111
Thread(s) per core:  2
Core(s) per socket:  28
Socket(s):           2
NUMA node(s):        2
Vendor ID:           GenuineIntel
CPU family:          6
Model:               85
Model name:          Intel(R) Xeon(R) Gold 6238R CPU @ 2.20GHz
Stepping:            7
CPU MHz:             2200.000
BogoMIPS:            4400.00
Virtualization:      VT-x
L1d cache:           32K
L1i cache:           32K
L2 cache:            1024K
L3 cache:            39424K
NUMA node0 CPU(s):   0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110
NUMA node1 CPU(s):   1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101,103,105,107,109,111
Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear flush_l1d arch_capabilities

Versions of relevant libraries:
[pip3] numpy==1.24.2
[pip3] phytorch==0.0.post1.dev91+gd60c96f.d20230407
[pip3] phytorchx==0.1.post1.dev0+ge54312c.d20230816
[pip3] pytorch-lightning==2.0.1
[pip3] torch==2.0.0
[pip3] torch-scatter==2.1.1+pt20cu118
[pip3] torchdiffeq==0.2.2
[pip3] torchmetrics==0.11.4
[pip3] torchviz==0.0.2
[pip3] triton==2.0.0
[conda] blas                      2.116                       mkl    conda-forge
[conda] blas-devel                3.9.0            16_linux64_mkl    conda-forge
[conda] cudatoolkit               11.7.0              hd8887f6_10    nvidia
[conda] libblas                   3.9.0            16_linux64_mkl    conda-forge
[conda] libcblas                  3.9.0            16_linux64_mkl    conda-forge
[conda] liblapack                 3.9.0            16_linux64_mkl    conda-forge
[conda] liblapacke                3.9.0            16_linux64_mkl    conda-forge
[conda] mkl                       2022.1.0           h84fe81f_915    conda-forge
[conda] mkl-devel                 2022.1.0           ha770c72_916    conda-forge
[conda] mkl-include               2022.1.0           h84fe81f_915    conda-forge
[conda] numpy                     1.24.2          py310h8deb116_0    conda-forge
[conda] phytorch                  0.0.post1.dev91+gd60c96f.d20230407          pypi_0    pypi
[conda] phytorchx                 0.1.post1.dev0+ge54312c.d20230816          pypi_0    pypi
[conda] pytorch                   2.0.0           py3.10_cuda11.8_cudnn8.7.0_0    pytorch
[conda] pytorch-cuda              11.8                 h7e8668a_3    pytorch
[conda] pytorch-lightning         2.0.1              pyhd8ed1ab_0    conda-forge
[conda] pytorch-mutex             1.0                        cuda    pytorch
[conda] torch-scatter             2.1.1+pt20cu118          pypi_0    pypi
[conda] torchdiffeq               0.2.2              pyhd8ed1ab_0    conda-forge
[conda] torchmetrics              0.11.4             pyhd8ed1ab_0    conda-forge
[conda] torchtriton               2.0.0                     py310    pytorch
[conda] torchviz                  0.0.2                    pypi_0    pypi


cc @ptrblck