MCPcopy
hub / github.com/Robbyant/lingbot-world / _apply

Method _apply

wan/modules/animate/animate_utils.py:126–143  ·  view source on GitHub ↗
(self, other, op)

Source from the content-addressed store, hash-verified

124 return 'TensorList: \n' + repr(self.tensors)
125
126 def _apply(self, other, op):
127 if isinstance(other, (list, tuple, TensorList)) or (
128 isinstance(other, torch.Tensor) and (
129 other.numel() > 1 or other.ndim > 1
130 )
131 ):
132 assert len(other) == len(self.tensors)
133 return TensorList([op(u, v) for u, v in zip(self.tensors, other)])
134 elif isinstance(other, numbers.Number) or (
135 isinstance(other, torch.Tensor) and (
136 other.numel() == 1 and other.ndim <= 1
137 )
138 ):
139 return TensorList([op(u, other) for u in self.tensors])
140 else:
141 raise TypeError(
142 f'unsupported operand for *: "TensorList" and "{type(other)}"'
143 )

Callers 12

__add__Method · 0.95
__radd__Method · 0.95
__sub__Method · 0.95
__rsub__Method · 0.95
__mul__Method · 0.95
__rmul__Method · 0.95
__floordiv__Method · 0.95
__truediv__Method · 0.95
__rfloordiv__Method · 0.95
__rtruediv__Method · 0.95
__pow__Method · 0.95
__rpow__Method · 0.95

Calls 1

TensorListClass · 0.85

Tested by

no test coverage detected