MCPcopy Create free account
hub / github.com/apache/singa / sub

Function sub

python/singa/tensor.py:1255–1275  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1253
1254
1255def 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
1278def eltwise_mult(lhs, rhs, ret=None):

Callers 2

valSparsAllReduceMethod · 0.50
topKSparsAllReduceMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected