Coverage for src/flag_gems/ops/cosh.py: 89%

19 statements  

« prev     ^ index     » next       coverage.py v7.6.9, created at 2026-06-10 07:09 +0800

1import logging 

2 

3import triton 

4import triton.language as tl 

5 

6from flag_gems.utils import pointwise_dynamic 

7 

8logger = logging.getLogger(__name__) 

9 

10 

11@pointwise_dynamic(promotion_methods=[(0, "INT_TO_FLOAT")]) 

12@triton.jit 

13def cosh_func(x): 

14 x = x.to(tl.float32) 

15 return 0.5 * (tl.exp(x) + tl.exp(-x)) 

16 

17 

18def cosh(A): 

19 logger.debug("GEMS COSH") 

20 return cosh_func(A) 

21 

22 

23def cosh_(A): 

24 logger.debug("GEMS COSH_") 

25 return cosh_func(A, out0=A) 

26 

27 

28def cosh_out(A, out): 

29 logger.debug("GEMS COSH_OUT") 

30 return cosh_func(A, out0=out)