MCPcopy
hub / github.com/TencentARC/Pixal3D / __elemwise__

Method __elemwise__

pixal3d/modules/sparse/basic.py:201–212  ·  view source on GitHub ↗
(self, other: Union[torch.Tensor, 'VarLenTensor'], op: callable)

Source from the content-addressed store, hash-verified

199 return self.replace(-self.feats)
200
201 def __elemwise__(self, other: Union[torch.Tensor, 'VarLenTensor'], op: callable) -> 'VarLenTensor':
202 if isinstance(other, torch.Tensor):
203 try:
204 other = torch.broadcast_to(other, self.shape)
205 other = other[self.batch_boardcast_map]
206 except:
207 pass
208 if isinstance(other, VarLenTensor):
209 other = other.feats
210 new_feats = op(self.feats, other)
211 new_tensor = self.replace(new_feats)
212 return new_tensor
213
214 def __add__(self, other: Union[torch.Tensor, 'VarLenTensor', float]) -> 'VarLenTensor':
215 return self.__elemwise__(other, torch.add)

Callers 8

__add__Method · 0.95
__radd__Method · 0.95
__sub__Method · 0.95
__rsub__Method · 0.95
__mul__Method · 0.95
__rmul__Method · 0.95
__truediv__Method · 0.95
__rtruediv__Method · 0.95

Calls 1

replaceMethod · 0.95

Tested by

no test coverage detected