Coverage for src/flag_gems/runtime/backend/_sunrise/ops/cos.py: 0%

19 statements  

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

1import logging 

2 

3import triton 

4import triton.language as tl 

5 

6from flag_gems.utils import pointwise_dynamic 

7from flag_gems.utils.pointwise_dynamic import CodeGenConfig 

8 

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

10 

11MAX_GRID_SIZES = (65535, 65535, 65535) 

12config = CodeGenConfig( 

13 max_tile_size=512, 

14 max_grid_size=MAX_GRID_SIZES, 

15 max_num_warps_per_cta=32, 

16 prefer_block_pointer=True, 

17 prefer_1d_tile=True, 

18) 

19 

20 

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

22@triton.jit 

23def cos_func(x): 

24 return tl.cos(x.to(tl.float32)) 

25 

26 

27def cos(A): 

28 logger.debug("GEMS COS") 

29 return cos_func(A) 

30 

31 

32def cos_(A): 

33 logger.debug("GEMS COS_") 

34 cos_func(A, out0=A) 

35 return A