public final class OrtUtil
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static long |
elementCount(long[] shape)
Counts the number of elements stored in a Tensor of this shape.
|
static java.lang.String[] |
flattenString(java.lang.Object o)
Flatten a multidimensional String array into a single dimensional String array, reading it in a
multidimensional row-major order.
|
static java.lang.Object |
newBooleanArray(long[] shape)
Creates a new primitive boolean array of up to 8 dimensions, using the supplied shape.
|
static java.lang.Object |
newByteArray(long[] shape)
Creates a new primitive byte array of up to 8 dimensions, using the supplied shape.
|
static java.lang.Object |
newDoubleArray(long[] shape)
Creates a new primitive double array of up to 8 dimensions, using the supplied shape.
|
static java.lang.Object |
newFloatArray(long[] shape)
Creates a new primitive float array of up to 8 dimensions, using the supplied shape.
|
static java.lang.Object |
newIntArray(long[] shape)
Creates a new primitive int array of up to 8 dimensions, using the supplied shape.
|
static java.lang.Object |
newLongArray(long[] shape)
Creates a new primitive long array of up to 8 dimensions, using the supplied shape.
|
static java.lang.Object |
newShortArray(long[] shape)
Creates a new primitive short array of up to 8 dimensions, using the supplied shape.
|
static java.lang.Object |
reshape(boolean[] input,
long[] shape)
Reshapes a boolean array into the desired n-dimensional array assuming the boolean array is
stored in n-dimensional row-major order.
|
static java.lang.Object |
reshape(byte[] input,
long[] shape)
Reshapes a byte array into the desired n-dimensional array assuming the byte array is stored in
n-dimensional row-major order.
|
static java.lang.Object |
reshape(double[] input,
long[] shape)
Reshapes a double array into the desired n-dimensional array assuming the double array is
stored in n-dimensional row-major order.
|
static java.lang.Object |
reshape(float[] input,
long[] shape)
Reshapes a float array into the desired n-dimensional array assuming the float array is stored
in n-dimensional row-major order.
|
static java.lang.Object |
reshape(int[] input,
long[] shape)
Reshapes an int array into the desired n-dimensional array, assuming the int array is stored in
n-dimensional row-major order.
|
static java.lang.Object |
reshape(long[] input,
long[] shape)
Reshapes a long array into the desired n-dimensional array, assuming the long array is stored
in n-dimensional row-major order.
|
static java.lang.Object |
reshape(short[] input,
long[] shape)
Reshapes a short array into the desired n-dimensional array assuming the short array is stored
in n-dimensional row-major order.
|
static long[] |
transformShape(int[] shape)
Converts an int shape into a long shape.
|
static int[] |
transformShape(long[] shape)
Converts an long shape into a int shape.
|
static boolean |
validateShape(long[] shape)
Checks that the shape is a valid shape for a Java array (i.e.
|
public static int[] transformShape(long[] shape)
Validates that the shape has more than 1 elements, less than 9 elements, each element is
less than Integer.MAX_VALUE
and that each entry is non-negative.
shape
- The long shape.public static long[] transformShape(int[] shape)
Validates that the shape has more than 1 element, less than 9 elements and that each entry is non-negative.
shape
- The int shape.public static java.lang.Object newBooleanArray(long[] shape)
shape
- The shape of array to create.public static java.lang.Object newByteArray(long[] shape)
shape
- The shape of array to create.public static java.lang.Object newShortArray(long[] shape)
shape
- The shape of array to create.public static java.lang.Object newIntArray(long[] shape)
shape
- The shape of array to create.public static java.lang.Object newLongArray(long[] shape)
shape
- The shape of array to create.public static java.lang.Object newFloatArray(long[] shape)
shape
- The shape of array to create.public static java.lang.Object newDoubleArray(long[] shape)
shape
- The shape of array to create.public static java.lang.Object reshape(boolean[] input, long[] shape)
IllegalArgumentException
if the number
of elements doesn't match between the shape and the input or the shape is invalid.input
- The boolean array.shape
- The desired shape.public static java.lang.Object reshape(byte[] input, long[] shape)
IllegalArgumentException
if the number of
elements doesn't match between the shape and the input or the shape is invalid.input
- The byte array.shape
- The desired shape.public static java.lang.Object reshape(short[] input, long[] shape)
IllegalArgumentException
if the number of
elements doesn't match between the shape and the input or the shape is invalid.input
- The short array.shape
- The desired shape.public static java.lang.Object reshape(int[] input, long[] shape)
IllegalArgumentException
if the number of
elements doesn't match between the shape and the input or the shape is invalid.input
- The int array.shape
- The desired shape.public static java.lang.Object reshape(long[] input, long[] shape)
IllegalArgumentException
if the number of
elements doesn't match between the shape and the input or the shape is invalid.input
- The long array.shape
- The desired shape.public static java.lang.Object reshape(float[] input, long[] shape)
IllegalArgumentException
if the number of
elements doesn't match between the shape and the input or the shape is invalid.input
- The float array.shape
- The desired shape.public static java.lang.Object reshape(double[] input, long[] shape)
IllegalArgumentException
if the number
of elements doesn't match between the shape and the input or the shape is invalid.input
- The double array.shape
- The desired shape.public static long elementCount(long[] shape)
Multiplies all the elements together if they are positive, throws an IllegalArgumentException
otherwise.
shape
- The shape to use.public static boolean validateShape(long[] shape)
shape
- The shape to check.public static java.lang.String[] flattenString(java.lang.Object o)
o
- A multidimensional String array.