ID: PyTorch PR-1
I have force-pushed an updated, compile-safe implementation to address the logical and architectural edge cases across both the CPU and CUDA backends.
Core Changes & Fixes:
-
Compile-Time Branching (CPU & CUDA): Added C++17
if constexpr (std::is_integral_v<scalar_t>)branching to decouple the type dispatch loops. This completely isolates the NaN-preservation logic to floating-point types (float,double,Half,BFloat16). As a result, integral type paths completely elide theisnanguards at compile time, eliminating template instantiation errors and preserving the highly optimized native fast paths. -
CUDA Host-to-Device Fix: Inside
sign_kernel_cuda, the host-sideat::_isnanutility inside theGPU_LAMBDAhas been replaced with the device-safe qualifiedc10::isnanintrinsic. This resolves the NVCC__host__to__device__namespace violation completely. -
Validation: The updated files have been verified locally. Both
spin lintandlintrunner -apass with zero code style or formatting errors, and local target compilation succeeds perfectly.
The PR is now fully production-ready and structurally sound.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.