Package 

Class EValue


  • 
    public class EValue
    
                        

    Java representation of an ExecuTorch value, which is implemented as tagged union that can be one of the supported types: https://pytorch.org/docs/stable/jit.html#types .

    Calling {@code toX} methods for inappropriate types will throw IllegalStateException.

    {@code EValue} objects are constructed with {@code EValue.from(value)}, {@code * EValue.tupleFrom(value1, value2, ...)}, {@code EValue.listFrom(value1, value2, ...)}, or one of the {@code dict} methods, depending on the key type.

    Data is retrieved from {@code EValue} objects with the {@code toX()} methods. Note that {@code * str}-type EValues must be extracted with toStr, rather than toString.

    {@code EValue} objects may retain references to objects passed into their constructors, and may return references to their internal state from {@code toX()}.

    Warning: These APIs are experimental and subject to change without notice

    • Method Summary

      Modifier and Type Method Description
      boolean isNone()
      boolean isTensor()
      boolean isBool()
      boolean isInt()
      boolean isDouble()
      boolean isString()
      static EValue optionalNone() Creates a new {@code EValue} of type {@code Optional} that contains no value.
      static EValue from(Tensor tensor) Creates a new {@code EValue} of type {@code Tensor}.
      static EValue from(boolean value) Creates a new {@code EValue} of type {@code bool}.
      static EValue from(long value) Creates a new {@code EValue} of type {@code int}.
      static EValue from(double value) Creates a new {@code EValue} of type {@code double}.
      static EValue from(String value) Creates a new {@code EValue} of type {@code str}.
      Tensor toTensor()
      boolean toBool()
      long toInt()
      double toDouble()
      String toStr()
      Array<byte> toByteArray() Serializes an {@code EValue} into a byte array.
      static EValue fromByteArray(Array<byte> bytes) Deserializes an {@code EValue} from a byte[].
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • optionalNone

         static EValue optionalNone()

        Creates a new {@code EValue} of type {@code Optional} that contains no value.

      • from

         static EValue from(Tensor tensor)

        Creates a new {@code EValue} of type {@code Tensor}.

      • from

         static EValue from(boolean value)

        Creates a new {@code EValue} of type {@code bool}.

      • from

         static EValue from(long value)

        Creates a new {@code EValue} of type {@code int}.

      • from

         static EValue from(double value)

        Creates a new {@code EValue} of type {@code double}.

      • from

         static EValue from(String value)

        Creates a new {@code EValue} of type {@code str}.

      • toByteArray

         Array<byte> toByteArray()

        Serializes an {@code EValue} into a byte array. Note: This method is experimental and subjectto change without notice.

      • fromByteArray

         static EValue fromByteArray(Array<byte> bytes)

        Deserializes an {@code EValue} from a byte[]. Note: This method is experimental and subject tochange without notice.

        Parameters:
        bytes - The byte array to deserialize from.