Coverage for src/flag_gems/ops/bitwise_and.py: 93%

27 statements  

« prev     ^ index     » next       coverage.py v7.6.9, created at 2026-03-18 02:36 +0800

1import logging 

2 

3import triton 

4 

5from flag_gems.utils import pointwise_dynamic 

6 

7logger = logging.getLogger(__name__) 

8 

9 

10@pointwise_dynamic(promotion_methods=[(0, 1, "DEFAULT")]) 

11@triton.jit 

12def bitwise_and_func(x, y): 

13 return x & y 

14 

15 

16def bitwise_and_tensor(A, B): 

17 logger.debug("GEMS BITWISE AND") 

18 return bitwise_and_func(A, B) 

19 

20 

21def bitwise_and_tensor_(A, B): 

22 logger.debug("GEMS BITWISE AND_") 

23 return bitwise_and_func(A, B, out0=A) 

24 

25 

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

27@triton.jit 

28def bitwise_and_func_scalar(x, y): 

29 return x & y 

30 

31 

32def bitwise_and_scalar(A, B): 

33 logger.debug("GEMS BITWISE AND SCALAR") 

34 return bitwise_and_func_scalar(A, B) 

35 

36 

37def bitwise_and_scalar_(A, B): 

38 logger.debug("GEMS BITWISE AND_ SCALAR") 

39 return bitwise_and_func_scalar(A, B, out0=A) 

40 

41 

42def bitwise_and_scalar_tensor(A, B): 

43 logger.debug("GEMS BITWISE AND SCALAR TENSOR") 

44 return bitwise_and_func_scalar(B, A)