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

18 statements  

« prev     ^ index     » next       coverage.py v7.6.9, created at 2026-03-28 12:23 +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 isCloseVectorization=True, 

19 unroll_num=8, 

20) 

21 

22 

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

24@triton.jit 

25def sqrt_func(x): 

26 return tl.sqrt(x.to(tl.float32)) 

27 

28 

29def sqrt(A): 

30 logger.debug("GEMS SQRT") 

31 return sqrt_func(A) 

32 

33 

34def sqrt_(A): 

35 logger.debug("GEMS SQRT_") 

36 sqrt_func(A, out0=A) 

37 return A