Coverage for src/flag_gems/ops/exp.py: 94%

18 statements  

« prev     ^ index     » next       coverage.py v7.6.9, created at 2026-03-17 02:35 +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 exp_func(x): 

14 return tl.exp(x.to(tl.float32)) 

15 

16 

17def exp(A): 

18 logger.debug("GEMS EXP") 

19 return exp_func(A) 

20 

21 

22def exp_(A): 

23 logger.debug("GEMS EXP_") 

24 return exp_func(A, out0=A) 

25 

26 

27# exp.out(Tensor self, *, Tensor(a!) out) -> Tensor(a!) 

28def exp_out(A, out): 

29 logger.debug("GEMS EXP_OUT") 

30 return exp_func(A, out0=out)