Coming from Torch7 I am missing logical operations such as the any() and all() functions to check whether a Boolean Tensor contains either only zeros or ones (e.g. after another logical operation):

  
      github.com
  
  
    torch/torch7/blob/master/doc/maths.md#torchanya 25
<a name="torch.maths.dok"></a>
# Math Functions #

Torch provides MATLAB-like functions for manipulating [`Tensor`](tensor.md) objects.  Functions fall into several types of categories:

  * [Constructors](#torch.construction.dok) like [`zeros`](#torch.zeros), [`ones`](#torch.ones);
  * Extractors like [`diag`](#torch.diag)  and [`triu`](#torch.triu);
  * [Element-wise](#torch.elementwise.dok) mathematical operations like [`abs`](#torch.abs) and [`pow`](#torch.pow);
  * [BLAS](#torch.basicoperations.dok) operations;
  * [Column or row-wise operations](#torch.columnwise.dok) like [`sum`](#torch.sum) and [`max`](#torch.max);
  * [Matrix-wide operations](#torch.matrixwide.dok) like [`trace`](#torch.trace) and [`norm`](#torch.norm);
  * [Convolution and cross-correlation](#torch.conv.dok) operations like [`conv2`](#torch.conv2);
  * [Basic linear algebra operations](#torch.linalg.dok) like [`eig`](#torch.eig);
  * [Logical operations](#torch.logical.dok) on `Tensor`s.

By default, all operations allocate a new `Tensor` to return the result.
However, all functions also support passing the target `Tensor`(s) as the first argument(s), in which case the target `Tensor`(s) will be resized accordingly and filled with result.
This property is especially useful when one wants have tight control over when memory is allocated.

The *Torch* package adopts the same concept, so that calling a function directly on the `Tensor` itself using an object-oriented syntax is equivalent to passing the `Tensor` as the optional resulting `Tensor`.


  This file has been truncated. show original

  
  
    
    
  
  


I understand I could probably do something like

a = torch.rand(3,3)
torch.sum(torch.lt 38(a,1)) / torch.numel(a)

and check whether this is 1 or 0 (result is a byte tensor so this should be integer division), but it feels rather inconvenient.
Is there some equivalent in PyTorch and if not, would it be possible to add these functions?