Class TensorInternals


  • public final class TensorInternals
    extends java.lang.Object
    Utility methods for tensors which are not exposed to the public API
    • Method Detail

      • entrySetOf

        public static <T> java.util.Set<java.util.Map.Entry<Position,​T>> entrySetOf​(Tensor<T> tensor)
      • sameValues

        public static <S> Tensor<S> sameValues​(Shape shape,
                                               S value)
      • createFrom

        public static <S> Tensor<S> createFrom​(Shape shape,
                                               java.util.function.Supplier<S> supplier)
      • createFrom

        public static <S> Tensor<S> createFrom​(Shape shape,
                                               java.util.function.Function<Position,​S> function)
      • mapFrom

        public static <V> java.util.Map<Position,​V> mapFrom​(Tensor<V> tensor)
        Returns a map representing the content of the given tensor. The concrete instance of the map might differ depending on the implementation of the passed in tensor: Tensor implementations can offer a more efficient way to retrieve a map from them, by implementing the Mappable interface. If this interface is present, then its Mappable.asMap() method will be called. Otherwise, as a fallback, a new immutable map will be created from information from the shape of the passed in tensor and its values.
        Parameters:
        tensor - the tensor from which a map should be returned
        Returns:
        a map representing the content of the tensor
        Throws:
        java.lang.NullPointerException - in case the passed in tensor is null