SIGN IN SIGN UP

[BugFix][CUDA] Provide htan overloads for fp16/bf16 tangent (#2894)

T.tan and T.__tan on float16/bfloat16 lower to htan() calls, but CUDA
has no half-precision tangent intrinsic, so the generated kernels failed
to compile with 'identifier htan is undefined'.

Add TL_PATCH device overloads for htan(half_t) and htan(bfloat16_t) in
src/tl_templates/cuda/common.h. Both evaluate via float32 tanf and
convert the result back, matching the existing pattern used for hexp and
other missing 16-bit intrinsics in the same file.

Add test_tan_16bit_compiles_and_runs covering T.tan and T.__tan for
both float16 and bfloat16, asserting the generated source contains
htan() and that numerical results match torch.tan within fp16 tolerance.
R
Ruihan11 committed
c8e402fc9316c8f2db4c378905c04e5f79915673
Parent: cd57a84
Committed by GitHub <noreply@github.com> on 8/11/2026, 7:22:06 AM