Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@wrapout
def maximum(self, other):
return self.backend.maximum(self.tensor, other)
@wrapout
def _stack(self, tensors, axis=0):
# stacks only "tensors", but not "self"
tensors = [t.tensor if isinstance(t, self.__class__) else t for t in tensors]
return self.backend.stack(tensors, dim=axis)
@wrapout
def any(self, axis=None, keepdims=False):
assert self.dtype == self.backend.bool
if axis is None:
assert not keepdims
return self.tensor.any()
if not isinstance(axis, Iterable):
axis = (axis,)
axis = reversed(sorted(axis))
x = self.tensor
for i in axis:
x = x.any(i, keepdim=keepdims)
return x
@wrapout
def _concatenate(self, tensors, axis=0):
# concatenates only "tensors", but not "self"
tensors = [t.tensor if isinstance(t, self.__class__) else t for t in tensors]
return self.backend.cat(tensors, dim=axis)
@wrapout
def logical_not(self):
assert self.dtype == self.backend.bool
return ~self.tensor
@wrapout
def logical_not(self):
assert self.dtype == self.backend.bool
return self.backend.logical_not(self.tensor)
@wrapout
def argsort(self, axis=-1):
return self.tensor.argsort(dim=axis)
@wrapout
def argmin(self, axis=None):
return self.tensor.argmin(axis=axis)
@wrapout
def _stack(self, tensors, axis=0):
# stacks only "tensors", but not "self"
tensors = [t.tensor if isinstance(t, self.__class__) else t for t in tensors]
return self.backend.stack(tensors, axis=axis)
@wrapout
def tile(self, multiples):
assert len(multiples) == self.ndim
return self.backend.tile(self.tensor, multiples)