Coverage for src/flag_gems/ops/maximum.py: 78%

18 statements  

« prev     ^ index     » next       coverage.py v7.6.9, created at 2026-03-29 04:01 +0800

1import logging 

2 

3import triton 

4import triton.language as tl 

5 

6from flag_gems.runtime import device 

7from flag_gems.utils import pointwise_dynamic 

8 

9logger = logging.getLogger(__name__) 

10device = device.name 

11 

12 

13@pointwise_dynamic(is_tensor=[True, True], promotion_methods=[(0, 1, "DEFAULT")]) 

14@triton.jit 

15def maximum_kernel(X, Y): 

16 if X.dtype == tl.bfloat16: 

17 X = X.to(tl.float32) 

18 Y = Y.to(tl.float32) 

19 

20 return tl.maximum(X, Y) 

21 

22 

23def maximum(X, Y): 

24 logger.debug("GEMS MAXIMUM") 

25 assert X.device.type == device and Y.device.type == device 

26 return maximum_kernel(X, Y)