-
public class EValueJava 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 booleanisNone()booleanisTensor()booleanisBool()booleanisInt()booleanisDouble()booleanisString()static EValueoptionalNone()Creates a new {@code EValue}of type{@code Optional}that contains no value.static EValuefrom(Tensor tensor)Creates a new {@code EValue}of type{@code Tensor}.static EValuefrom(boolean value)Creates a new {@code EValue}of type{@code bool}.static EValuefrom(long value)Creates a new {@code EValue}of type{@code int}.static EValuefrom(double value)Creates a new {@code EValue}of type{@code double}.static EValuefrom(String value)Creates a new {@code EValue}of type{@code str}.TensortoTensor()booleantoBool()longtoInt()doubletoDouble()StringtoStr()Array<byte>toByteArray()Serializes an {@code EValue}into a byte array.static EValuefromByteArray(Array<byte> bytes)Deserializes an {@code EValue}from a byte[].-
-
Method Detail
-
isNone
boolean isNone()
-
isTensor
boolean isTensor()
-
isBool
boolean isBool()
-
isInt
boolean isInt()
-
isDouble
boolean isDouble()
-
isString
boolean isString()
-
optionalNone
static EValue optionalNone()
Creates a new
{@code EValue}of type{@code Optional}that contains no value.
-
toBool
boolean toBool()
-
toInt
long toInt()
-
toDouble
double toDouble()
-
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.
-
-
-
-