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

Function add

python/singa/tensor.py:1232–1252  ·  view source on GitHub ↗

Elementi-wise addition. 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

1230
1231
1232def add(lhs, rhs, ret=None):
1233 '''Elementi-wise addition.
1234
1235 Args:
1236 lhs (Tensor): lhs tensor
1237 rhs (Tensor): rhs tensor
1238 ret (Tensor, optional): if not None, the result is stored in it;
1239 otherwise, a new Tensor would be created for the result.
1240
1241 Returns:
1242 the result Tensor
1243 '''
1244 if ret is None:
1245 # call Tensor.__add__()
1246 return lhs + rhs
1247 else:
1248 if isinstance(rhs, Tensor):
1249 singa.Add(lhs.data, rhs.data, ret.data)
1250 else:
1251 singa.AddFloatWithRet(lhs.data, rhs, ret.data)
1252 return ret
1253
1254
1255def sub(lhs, rhs, ret=None):

Callers 3

Cuda>Method · 0.50
valSparsAllReduceMethod · 0.50
topKSparsAllReduceMethod · 0.50

Calls 1

AddMethod · 0.80

Tested by

no test coverage detected