torch.addcdiv¶
-
torch.
addcdiv
(input, tensor1, tensor2, *, value=1, out=None) → Tensor¶ Performs the element-wise division of
tensor1
bytensor2
, multiply the result by the scalarvalue
and add it toinput
.Warning
Integer division with addcdiv is no longer supported, and in a future release addcdiv will perform a true division of
tensor1
andtensor2
. The historic addcdiv behavior can be implemented usingfloor_divide()
for integral inputs (input
+value
*tensor1
//tensor2
) anddiv()
for float inputs (input
+value
*tensor1
/tensor2
). The future addcdiv behavior can be implemented withtrue_divide()
(input
+value
* torch.true_divide(tensor1
,tensor2
).The shapes of
input
,tensor1
, andtensor2
must be broadcastable.For inputs of type FloatTensor or DoubleTensor,
value
must be a real number, otherwise an integer.- Parameters
Example:
>>> t = torch.randn(1, 3) >>> t1 = torch.randn(3, 1) >>> t2 = torch.randn(1, 3) >>> torch.addcdiv(t, t1, t2, value=0.1) tensor([[-0.2312, -3.6496, 0.1312], [-1.0428, 3.4292, -0.1030], [-0.5369, -0.9829, 0.0430]])