|
2 | 2 |
|
3 | 3 | import torch
|
4 | 4 |
|
5 |
| -from . import _binary_ufuncs, _dtypes, _funcs, _funcs_impl, _helpers, _unary_ufuncs |
| 5 | +from . import _dtypes, _funcs, _funcs_impl, _helpers, _ufuncs |
6 | 6 | from ._detail import _dtypes_impl, _util
|
7 | 7 |
|
8 | 8 | newaxis = None
|
@@ -176,24 +176,24 @@ def __str__(self):
|
176 | 176 | ### comparisons ###
|
177 | 177 | def __eq__(self, other):
|
178 | 178 | try:
|
179 |
| - return _binary_ufuncs.equal(self, other) |
| 179 | + return _ufuncs.equal(self, other) |
180 | 180 | except (RuntimeError, TypeError):
|
181 | 181 | # Failed to convert other to array: definitely not equal.
|
182 | 182 | falsy = torch.full(self.shape, fill_value=False, dtype=bool)
|
183 | 183 | return asarray(falsy)
|
184 | 184 |
|
185 | 185 | def __ne__(self, other):
|
186 | 186 | try:
|
187 |
| - return _binary_ufuncs.not_equal(self, other) |
| 187 | + return _ufuncs.not_equal(self, other) |
188 | 188 | except (RuntimeError, TypeError):
|
189 | 189 | # Failed to convert other to array: definitely not equal.
|
190 | 190 | falsy = torch.full(self.shape, fill_value=True, dtype=bool)
|
191 | 191 | return asarray(falsy)
|
192 | 192 |
|
193 |
| - __gt__ = _binary_ufuncs.greater |
194 |
| - __lt__ = _binary_ufuncs.less |
195 |
| - __ge__ = _binary_ufuncs.greater_equal |
196 |
| - __le__ = _binary_ufuncs.less_equal |
| 193 | + __gt__ = _ufuncs.greater |
| 194 | + __lt__ = _ufuncs.less |
| 195 | + __ge__ = _ufuncs.greater_equal |
| 196 | + __le__ = _ufuncs.less_equal |
197 | 197 |
|
198 | 198 | def __bool__(self):
|
199 | 199 | try:
|
@@ -239,107 +239,107 @@ def __len__(self):
|
239 | 239 | ### arithmetic ###
|
240 | 240 |
|
241 | 241 | # add, self + other
|
242 |
| - __add__ = __radd__ = _binary_ufuncs.add |
| 242 | + __add__ = __radd__ = _ufuncs.add |
243 | 243 |
|
244 | 244 | def __iadd__(self, other):
|
245 |
| - return _binary_ufuncs.add(self, other, out=self) |
| 245 | + return _ufuncs.add(self, other, out=self) |
246 | 246 |
|
247 | 247 | # sub, self - other
|
248 |
| - __sub__ = _binary_ufuncs.subtract |
| 248 | + __sub__ = _ufuncs.subtract |
249 | 249 |
|
250 | 250 | # XXX: generate a function just for this? AND other non-commutative ops.
|
251 | 251 | def __rsub__(self, other):
|
252 |
| - return _binary_ufuncs.subtract(other, self) |
| 252 | + return _ufuncs.subtract(other, self) |
253 | 253 |
|
254 | 254 | def __isub__(self, other):
|
255 |
| - return _binary_ufuncs.subtract(self, other, out=self) |
| 255 | + return _ufuncs.subtract(self, other, out=self) |
256 | 256 |
|
257 | 257 | # mul, self * other
|
258 |
| - __mul__ = __rmul__ = _binary_ufuncs.multiply |
| 258 | + __mul__ = __rmul__ = _ufuncs.multiply |
259 | 259 |
|
260 | 260 | def __imul__(self, other):
|
261 |
| - return _binary_ufuncs.multiply(self, other, out=self) |
| 261 | + return _ufuncs.multiply(self, other, out=self) |
262 | 262 |
|
263 | 263 | # div, self / other
|
264 |
| - __truediv__ = _binary_ufuncs.divide |
| 264 | + __truediv__ = _ufuncs.divide |
265 | 265 |
|
266 | 266 | def __rtruediv__(self, other):
|
267 |
| - return _binary_ufuncs.divide(other, self) |
| 267 | + return _ufuncs.divide(other, self) |
268 | 268 |
|
269 | 269 | def __itruediv__(self, other):
|
270 |
| - return _binary_ufuncs.divide(self, other, out=self) |
| 270 | + return _ufuncs.divide(self, other, out=self) |
271 | 271 |
|
272 | 272 | # floordiv, self // other
|
273 |
| - __floordiv__ = _binary_ufuncs.floor_divide |
| 273 | + __floordiv__ = _ufuncs.floor_divide |
274 | 274 |
|
275 | 275 | def __rfloordiv__(self, other):
|
276 |
| - return _binary_ufuncs.floor_divide(other, self) |
| 276 | + return _ufuncs.floor_divide(other, self) |
277 | 277 |
|
278 | 278 | def __ifloordiv__(self, other):
|
279 |
| - return _binary_ufuncs.floor_divide(self, other, out=self) |
| 279 | + return _ufuncs.floor_divide(self, other, out=self) |
280 | 280 |
|
281 |
| - __divmod__ = _binary_ufuncs.divmod |
| 281 | + __divmod__ = _ufuncs.divmod |
282 | 282 |
|
283 | 283 | # power, self**exponent
|
284 |
| - __pow__ = __rpow__ = _binary_ufuncs.float_power |
| 284 | + __pow__ = __rpow__ = _ufuncs.float_power |
285 | 285 |
|
286 | 286 | def __rpow__(self, exponent):
|
287 |
| - return _binary_ufuncs.float_power(exponent, self) |
| 287 | + return _ufuncs.float_power(exponent, self) |
288 | 288 |
|
289 | 289 | def __ipow__(self, exponent):
|
290 |
| - return _binary_ufuncs.float_power(self, exponent, out=self) |
| 290 | + return _ufuncs.float_power(self, exponent, out=self) |
291 | 291 |
|
292 | 292 | # remainder, self % other
|
293 |
| - __mod__ = __rmod__ = _binary_ufuncs.remainder |
| 293 | + __mod__ = __rmod__ = _ufuncs.remainder |
294 | 294 |
|
295 | 295 | def __imod__(self, other):
|
296 |
| - return _binary_ufuncs.remainder(self, other, out=self) |
| 296 | + return _ufuncs.remainder(self, other, out=self) |
297 | 297 |
|
298 | 298 | # bitwise ops
|
299 | 299 | # and, self & other
|
300 |
| - __and__ = __rand__ = _binary_ufuncs.bitwise_and |
| 300 | + __and__ = __rand__ = _ufuncs.bitwise_and |
301 | 301 |
|
302 | 302 | def __iand__(self, other):
|
303 |
| - return _binary_ufuncs.bitwise_and(self, other, out=self) |
| 303 | + return _ufuncs.bitwise_and(self, other, out=self) |
304 | 304 |
|
305 | 305 | # or, self | other
|
306 |
| - __or__ = __ror__ = _binary_ufuncs.bitwise_or |
| 306 | + __or__ = __ror__ = _ufuncs.bitwise_or |
307 | 307 |
|
308 | 308 | def __ior__(self, other):
|
309 |
| - return _binary_ufuncs.bitwise_or(self, other, out=self) |
| 309 | + return _ufuncs.bitwise_or(self, other, out=self) |
310 | 310 |
|
311 | 311 | # xor, self ^ other
|
312 |
| - __xor__ = __rxor__ = _binary_ufuncs.bitwise_xor |
| 312 | + __xor__ = __rxor__ = _ufuncs.bitwise_xor |
313 | 313 |
|
314 | 314 | def __ixor__(self, other):
|
315 |
| - return _binary_ufuncs.bitwise_xor(self, other, out=self) |
| 315 | + return _ufuncs.bitwise_xor(self, other, out=self) |
316 | 316 |
|
317 | 317 | # bit shifts
|
318 |
| - __lshift__ = __rlshift__ = _binary_ufuncs.left_shift |
| 318 | + __lshift__ = __rlshift__ = _ufuncs.left_shift |
319 | 319 |
|
320 | 320 | def __ilshift__(self, other):
|
321 |
| - return _binary_ufuncs.left_shift(self, other, out=self) |
| 321 | + return _ufuncs.left_shift(self, other, out=self) |
322 | 322 |
|
323 |
| - __rshift__ = __rrshift__ = _binary_ufuncs.right_shift |
| 323 | + __rshift__ = __rrshift__ = _ufuncs.right_shift |
324 | 324 |
|
325 | 325 | def __irshift__(self, other):
|
326 |
| - return _binary_ufuncs.right_shift(self, other, out=self) |
| 326 | + return _ufuncs.right_shift(self, other, out=self) |
327 | 327 |
|
328 |
| - __matmul__ = _binary_ufuncs.matmul |
| 328 | + __matmul__ = _ufuncs.matmul |
329 | 329 |
|
330 | 330 | def __rmatmul__(self, other):
|
331 |
| - return _binary_ufuncs.matmul(other, self) |
| 331 | + return _ufuncs.matmul(other, self) |
332 | 332 |
|
333 | 333 | def __imatmul__(self, other):
|
334 |
| - return _binary_ufuncs.matmul(self, other, out=self) |
| 334 | + return _ufuncs.matmul(self, other, out=self) |
335 | 335 |
|
336 | 336 | # unary ops
|
337 |
| - __invert__ = _unary_ufuncs.invert |
338 |
| - __abs__ = _unary_ufuncs.absolute |
339 |
| - __pos__ = _unary_ufuncs.positive |
340 |
| - __neg__ = _unary_ufuncs.negative |
| 337 | + __invert__ = _ufuncs.invert |
| 338 | + __abs__ = _ufuncs.absolute |
| 339 | + __pos__ = _ufuncs.positive |
| 340 | + __neg__ = _ufuncs.negative |
341 | 341 |
|
342 |
| - conjugate = _unary_ufuncs.conjugate |
| 342 | + conjugate = _ufuncs.conjugate |
343 | 343 | conj = conjugate
|
344 | 344 |
|
345 | 345 | ### methods to match namespace functions
|
|
0 commit comments