Coverage for src/flag_gems/runtime/backend/_kunlunxin/ops/exp2.py: 0%

18 statements  

« prev     ^ index     » next       coverage.py v7.6.9, created at 2026-03-22 16:54 +0800

1import logging 

2 

3import triton 

4import triton.language as tl 

5from _kunlunxin.utils.codegen_config_utils import CodeGenConfig 

6 

7from ..utils.pointwise_dynamic import pointwise_dynamic 

8 

9logger = logging.getLogger("flag_gems").getChild(__name__.lstrip(".")) 

10 

11config_ = CodeGenConfig( 

12 512, 

13 (65536, 65536, 65536), 

14 32, 

15 True, 

16 prefer_1d_tile=True, 

17 buffer_size_limit=4096, 

18 unroll_num=4, 

19) 

20 

21 

22@pointwise_dynamic(promotion_methods=[(0, "INT_TO_FLOAT")], config=config_) 

23@triton.jit 

24def exp2_func(x): 

25 LN2 = 0.69314718056 

26 return tl.exp(x.to(tl.float32) * LN2) 

27 

28 

29def exp2(A): 

30 logger.debug("GEMS EXP") 

31 return exp2_func(A) 

32 

33 

34def exp2_(A): 

35 logger.debug("GEMS EXP_") 

36 return exp2_func(A, out0=A)