-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathaddcdiv.py
More file actions
38 lines (33 loc) · 865 Bytes
/
addcdiv.py
File metadata and controls
38 lines (33 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import infinicore
from infinicore.lib import _infinicore
from infinicore.tensor import Tensor
def addcdiv(
input: Tensor,
tensor1: Tensor,
tensor2: Tensor,
*,
value=1.0,
out=None,
) -> Tensor:
r"""Apply the addcdiv function."""
if infinicore.use_ntops and input.device.type in ("cuda", "musa"):
return infinicore.ntops.torch.addcdiv(
input, tensor1, tensor2, value=value, out=out
)
if out is None:
return Tensor(
_infinicore.addcdiv(
input._underlying,
tensor1._underlying,
tensor2._underlying,
float(value),
)
)
_infinicore.addcdiv_(
input._underlying,
tensor1._underlying,
tensor2._underlying,
out._underlying,
float(value),
)
return out