Elementi-wise multiplication. 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)
| 1241 | |
| 1242 | |
| 1243 | def eltwise_mult(lhs, rhs, ret=None): |
| 1244 | '''Elementi-wise multiplication. |
| 1245 | |
| 1246 | Args: |
| 1247 | lhs (Tensor): lhs tensor |
| 1248 | rhs (Tensor): rhs tensor |
| 1249 | ret (Tensor, optional): if not None, the result is stored in it; |
| 1250 | otherwise, a new Tensor would be created for the result. |
| 1251 | |
| 1252 | Returns: |
| 1253 | the result Tensor |
| 1254 | ''' |
| 1255 | |
| 1256 | if ret is None: |
| 1257 | # call Tensor.__mul__() |
| 1258 | return lhs * rhs |
| 1259 | else: |
| 1260 | if isinstance(rhs, Tensor): |
| 1261 | singa.EltwiseMult(lhs.data, rhs.data, ret.data) |
| 1262 | else: |
| 1263 | singa.EltwiseMultFloatWithRet(lhs.data, rhs, ret.data) |
| 1264 | return ret |
| 1265 | |
| 1266 | |
| 1267 | def mult(A, B, C=None, alpha=1.0, beta=0.0): |