Package ai.djl.modality
Class Input
java.lang.Object
ai.djl.modality.Input
- Direct Known Subclasses:
Output
A class stores the generic input data for inference.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(byte[] data) Appends an item at the end of the input.voidadd(int index, String key, BytesSupplier data) Inserts the specified element at the specified position in the input.voidadd(BytesSupplier data) Appends an item at the end of the input.voidAppends an item at the end of the input.voidAdds a key/value pair to the input content.voidadd(String key, BytesSupplier data) Adds a key/value pair to the input content.voidAdds a key/value pair to the input content.voidaddProperty(String key, String value) Adds a property to the input.static Inputdecode(InputStream is) Decodes the input fromencode().protected static voiddecodeInputBase(DataInputStream dis, Input input) booleandeepEquals(Object o) Checks for deep equality with another input.byte[]encode()Encodes all data in the input to a binary form.protected voidget(int index) Returns the element at the specified position in theInput.Returns the element for the first key found in theInput.byte[]getAsBytes(int index) Returns the value asbyte[]at the specified position in theInput.byte[]getAsBytes(String key) Returns the value asbyte[]for the first key found in theInput.getAsNDArray(NDManager manager, int index) Returns the value asNDArrayat the specified position in theInput.getAsNDArray(NDManager manager, String key) Returns the value asNDArrayfor the first key found in theInput.getAsNDList(NDManager manager, int index) Returns the value asNDListat the specified position in theInput.getAsNDList(NDManager manager, String key) Returns the value asNDListfor the first key found in theInput.getAsString(int index) Returns the value asbyte[]at the specified position in theInput.getAsString(String key) Returns the value asbyte[]for the first key found in theInput.ai.djl.util.PairList<String,BytesSupplier> Returns the content of the input.ai.djl.util.PairList<String,ByteBuffer> Returns the content of the input asByteBuffers.getData()Returns the default data item.getDataAsNDList(NDManager manager) Returns the default data asNDList.Returns the properties of the input.getProperty(String key, String defaultValue) Returns the value to which the specified key is mapped.booleanReturnstrueif the input is cancelled.voidsetCancelled(boolean cancelled) Sets the cancelled status.voidsetContent(ai.djl.util.PairList<String, BytesSupplier> content) Sets the content of the input.voidsetProperties(Map<String, String> properties) Sets the properties of the input.toString()*
-
Field Details
-
properties
-
-
-
Constructor Details
-
Input
public Input()Constructs a newInputinstance.
-
-
Method Details
-
isCancelled
public boolean isCancelled()Returnstrueif the input is cancelled.- Returns:
trueif the input is cancelled.
-
setCancelled
public void setCancelled(boolean cancelled) Sets the cancelled status.- Parameters:
cancelled- the cancelled status
-
getProperties
Returns the properties of the input.- Returns:
- the properties of the input
-
setProperties
Sets the properties of the input.- Parameters:
properties- the properties of the input
-
addProperty
Adds a property to the input.- Parameters:
key- key with which the specified value is to be addedvalue- value to be added with the specified key
-
getProperty
Returns the value to which the specified key is mapped.- Parameters:
key- the key whose associated value is to be returneddefaultValue- the default mapping of the key- Returns:
- the value to which the specified key is mapped
-
getContent
Returns the content of the input.A
Inputmay contains multiple data.- Returns:
- the content of the input
-
getContentAsBuffers
Returns the content of the input asByteBuffers.A
Inputmay contains multiple data.- Returns:
- the content of the input as
ByteBuffers.
-
setContent
Sets the content of the input.- Parameters:
content- the content of the input
-
add
public void add(byte[] data) Appends an item at the end of the input.- Parameters:
data- data to be added
-
add
Appends an item at the end of the input.- Parameters:
data- data to be added
-
add
Appends an item at the end of the input.- Parameters:
data- data to be added
-
add
Adds a key/value pair to the input content.- Parameters:
key- key with which the specified data is to be addeddata- data to be added with the specified key
-
add
Adds a key/value pair to the input content.- Parameters:
key- key with which the specified data is to be addeddata- data to be added with the specified key
-
add
Adds a key/value pair to the input content.- Parameters:
key- key with which the specified data is to be addeddata- data to be added with the specified key
-
add
Inserts the specified element at the specified position in the input.- Parameters:
index- the index at which the specified element is to be insertedkey- key with which the specified data is to be addeddata- data to be added with the specified key
-
getData
Returns the default data item.- Returns:
- the default data item
-
getDataAsNDList
Returns the default data asNDList.- Parameters:
manager-NDManagerused to create thisNDArray- Returns:
- the default data as
NDList
-
get
Returns the element for the first key found in theInput.- Parameters:
key- the key of the element to get- Returns:
- the element for the first key found in the
Input
-
get
Returns the element at the specified position in theInput.- Parameters:
index- the index of the element to return- Returns:
- the element at the specified position in the
Input
-
getAsBytes
Returns the value asbyte[]for the first key found in theInput.- Parameters:
key- the key of the element to get- Returns:
- the value as
byte[]for the first key found in theInput
-
getAsBytes
public byte[] getAsBytes(int index) Returns the value asbyte[]at the specified position in theInput.- Parameters:
index- the index of the element to return- Returns:
- the value as
byte[]at the specified position in theInput
-
getAsString
Returns the value asbyte[]for the first key found in theInput.- Parameters:
key- the key of the element to get- Returns:
- the value as
byte[]for the first key found in theInput
-
getAsString
Returns the value asbyte[]at the specified position in theInput.- Parameters:
index- the index of the element to return- Returns:
- the value as
byte[]at the specified position in theInput
-
getAsNDArray
Returns the value asNDArrayfor the first key found in theInput.- Parameters:
manager-NDManagerused to create thisNDArraykey- the key of the element to get- Returns:
- the value as
NDArrayfor the first key found in theInput
-
getAsNDArray
Returns the value asNDArrayat the specified position in theInput.- Parameters:
manager-NDManagerused to create thisNDArrayindex- the index of the element to return- Returns:
- the value as
NDArrayat the specified position in theInput
-
getAsNDList
Returns the value asNDListfor the first key found in theInput.- Parameters:
manager-NDManagerused to create thisNDArraykey- the key of the element to get- Returns:
- the value as
NDListfor the first key found in theInput
-
getAsNDList
Returns the value asNDListat the specified position in theInput.- Parameters:
manager-NDManagerused to create thisNDArrayindex- the index of the element to return- Returns:
- the value as
NDListat the specified position in theInput
-
encode
Encodes all data in the input to a binary form.- Returns:
- the binary encoding
- Throws:
IOException- if it fails to encode part of the data
-
encodeInputBase
- Throws:
IOException
-
decode
Decodes the input fromencode().- Parameters:
is- the data to decode from- Returns:
- the decoded input
- Throws:
IOException- if it fails to decode part of the input
-
decodeInputBase
- Throws:
IOException
-
deepEquals
Checks for deep equality with another input.- Parameters:
o- the other input.- Returns:
- whether they and all properties, content, and data are equal
-
toString
*
-