Elementi-wise subtraction. 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)
| 1253 | |
| 1254 | |
| 1255 | def sub(lhs, rhs, ret=None): |
| 1256 | '''Elementi-wise subtraction. |
| 1257 | |
| 1258 | Args: |
| 1259 | lhs (Tensor): lhs tensor |
| 1260 | rhs (Tensor): rhs tensor |
| 1261 | ret (Tensor, optional): if not None, the result is stored in it; |
| 1262 | otherwise, a new Tensor would be created for the result. |
| 1263 | |
| 1264 | Returns: |
| 1265 | the result Tensor |
| 1266 | ''' |
| 1267 | if ret is None: |
| 1268 | # call Tensor.__sub__() |
| 1269 | return lhs - rhs |
| 1270 | else: |
| 1271 | if isinstance(rhs, Tensor): |
| 1272 | singa.Sub(lhs.data, rhs.data, ret.data) |
| 1273 | else: |
| 1274 | singa.SubFloatWithRet(lhs.data, rhs, ret.data) |
| 1275 | return ret |
| 1276 | |
| 1277 | |
| 1278 | def eltwise_mult(lhs, rhs, ret=None): |
no outgoing calls
no test coverage detected