Coverage for src/flag_gems/runtime/backend/_cambricon/ops/bitwise_and.py: 0%

27 statements  

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

1import logging 

2 

3import triton 

4 

5from ..utils.pointwise_dynamic import pointwise_dynamic 

6 

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

8 

9 

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

11@triton.jit 

12def bitwise_and_func(x, y, inplace): 

13 return x & y 

14 

15 

16def bitwise_and_tensor(A, B): 

17 logger.debug("GEMS_CAMBRICON BITWISE AND") 

18 return bitwise_and_func(A, B, False) 

19 

20 

21def bitwise_and_tensor_(A, B): 

22 logger.debug("GEMS_CAMBRICON AND_") 

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

24 

25 

26@pointwise_dynamic( 

27 is_tensor=[True, False, False], promotion_methods=[(0, 1, "DEFAULT")] 

28) 

29@triton.jit 

30def bitwise_and_func_scalar(x, y, inplace): 

31 return x & y 

32 

33 

34def bitwise_and_scalar(A, B): 

35 logger.debug("GEMS_CAMBRICON BITWISE AND SCALAR") 

36 return bitwise_and_func_scalar(A, B, False) 

37 

38 

39def bitwise_and_scalar_(A, B): 

40 logger.debug("GEMS_CAMBRICON BITWISE AND_ SCALAR") 

41 return bitwise_and_func_scalar(A, B, True, out0=A) 

42 

43 

44def bitwise_and_scalar_tensor(A, B): 

45 logger.debug("GEMS_CAMBRICON BITWISE AND SCALAR TENSOR") 

46 return bitwise_and_func_scalar(B, A, False)