(self, other: Union[torch.Tensor, 'VarLenTensor'], op: callable)
| 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) |
no test coverage detected