Elementi-wise division. Args: lhs (Tensor): lhs tensor rhs (Tensor): rhs tensor ret (Tensor, optional): if not None, the result is stored in it; otherwise, a new Tensor would be created for the result. Returns: the result Tensor
(lhs, rhs, ret=None)
| 1603 | |
| 1604 | |
| 1605 | def div(lhs, rhs, ret=None): |
| 1606 | '''Elementi-wise division. |
| 1607 | |
| 1608 | Args: |
| 1609 | lhs (Tensor): lhs tensor |
| 1610 | rhs (Tensor): rhs tensor |
| 1611 | ret (Tensor, optional): if not None, the result is stored in it; |
| 1612 | otherwise, a new Tensor would be created for the result. |
| 1613 | |
| 1614 | Returns: |
| 1615 | the result Tensor |
| 1616 | ''' |
| 1617 | if ret is None: |
| 1618 | # call Tensor.__div__() |
| 1619 | return lhs / rhs |
| 1620 | else: |
| 1621 | if isinstance(rhs, Tensor): |
| 1622 | singa.Div(lhs.data, rhs.data, ret.data) |
| 1623 | else: |
| 1624 | singa.DivFloatWithRet(lhs.data, rhs, ret.data) |
| 1625 | return ret |
| 1626 | |
| 1627 | |
| 1628 | def axpy(alpha, x, y): |