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

15 statements  

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

1import logging 

2 

3import torch 

4import triton 

5 

6from ..utils.pointwise_dynamic import pointwise_dynamic 

7 

8logger = logging.getLogger(__name__) 

9 

10 

11@pointwise_dynamic( 

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

13) 

14@triton.jit 

15def addcdiv_kernel(x, t1, t2, value): 

16 return x + value * t1 / t2 

17 

18 

19def addcdiv(inp, tensor1, tensor2, value=1.0, out=None): 

20 logger.debug("GEMS_CAMBRICON ADDCDIV FORWARD") 

21 

22 if out is None: 

23 out = torch.empty_like(inp) 

24 

25 addcdiv_kernel(inp, tensor1, tensor2, value, out0=out) 

26 

27 return out