Class Input

  • Direct Known Subclasses:
    Output

    public class Input
    extends java.lang.Object
    A class stores the generic input data for inference.
    • Constructor Summary

      Constructors 
      Constructor Description
      Input()
      Constructs a new Input instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(byte[] data)
      Appends an item at the end of the input.
      void add​(int index, java.lang.String key, BytesSupplier data)
      Inserts the specified element at the specified position in the input.
      void add​(BytesSupplier data)
      Appends an item at the end of the input.
      void add​(java.lang.String data)
      Appends an item at the end of the input.
      void add​(java.lang.String key, byte[] data)
      Adds a key/value pair to the input content.
      void add​(java.lang.String key, BytesSupplier data)
      Adds a key/value pair to the input content.
      void add​(java.lang.String key, java.lang.String data)
      Adds a key/value pair to the input content.
      void addProperty​(java.lang.String key, java.lang.String value)
      Adds a property to the input.
      BytesSupplier get​(int index)
      Returns the element at the specified position in the Input.
      BytesSupplier get​(java.lang.String key)
      Returns the element for the first key found in the Input.
      byte[] getAsBytes​(int index)
      Returns the value as byte[] at the specified position in the Input.
      byte[] getAsBytes​(java.lang.String key)
      Returns the value as byte[] for the first key found in the Input.
      NDArray getAsNDArray​(NDManager manager, int index)
      Returns the value as NDArray at the specified position in the Input.
      NDArray getAsNDArray​(NDManager manager, java.lang.String key)
      Returns the value as NDArray for the first key found in the Input.
      NDList getAsNDList​(NDManager manager, int index)
      Returns the value as NDList at the specified position in the Input.
      NDList getAsNDList​(NDManager manager, java.lang.String key)
      Returns the value as NDList for the first key found in the Input.
      java.lang.String getAsString​(int index)
      Returns the value as byte[] at the specified position in the Input.
      java.lang.String getAsString​(java.lang.String key)
      Returns the value as byte[] for the first key found in the Input.
      ai.djl.util.PairList<java.lang.String,​BytesSupplier> getContent()
      Returns the content of the input.
      BytesSupplier getData()
      Returns the default data item.
      NDList getDataAsNDList​(NDManager manager)
      Returns the default data as NDList.
      java.util.Map<java.lang.String,​java.lang.String> getProperties()
      Returns the properties of the input.
      java.lang.String getProperty​(java.lang.String key, java.lang.String defaultValue)
      Returns the value to which the specified key is mapped.
      void setContent​(ai.djl.util.PairList<java.lang.String,​BytesSupplier> content)
      Sets the content of the input.
      void setProperties​(java.util.Map<java.lang.String,​java.lang.String> properties)
      Sets the properties of the input.
      java.lang.String toString()
      *
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Input

        public Input()
        Constructs a new Input instance.
    • Method Detail

      • getProperties

        public java.util.Map<java.lang.String,​java.lang.String> getProperties()
        Returns the properties of the input.
        Returns:
        the properties of the input
      • setProperties

        public void setProperties​(java.util.Map<java.lang.String,​java.lang.String> properties)
        Sets the properties of the input.
        Parameters:
        properties - the properties of the input
      • addProperty

        public void addProperty​(java.lang.String key,
                                java.lang.String value)
        Adds a property to the input.
        Parameters:
        key - key with which the specified value is to be added
        value - value to be added with the specified key
      • getProperty

        public java.lang.String getProperty​(java.lang.String key,
                                            java.lang.String defaultValue)
        Returns the value to which the specified key is mapped.
        Parameters:
        key - the key whose associated value is to be returned
        defaultValue - the default mapping of the key
        Returns:
        the value to which the specified key is mapped
      • getContent

        public ai.djl.util.PairList<java.lang.String,​BytesSupplier> getContent()
        Returns the content of the input.

        A Input may contains multiple data.

        Returns:
        the content of the input
      • setContent

        public void setContent​(ai.djl.util.PairList<java.lang.String,​BytesSupplier> content)
        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

        public void add​(java.lang.String data)
        Appends an item at the end of the input.
        Parameters:
        data - data to be added
      • add

        public void add​(BytesSupplier data)
        Appends an item at the end of the input.
        Parameters:
        data - data to be added
      • add

        public void add​(java.lang.String key,
                        byte[] data)
        Adds a key/value pair to the input content.
        Parameters:
        key - key with which the specified data is to be added
        data - data to be added with the specified key
      • add

        public void add​(java.lang.String key,
                        java.lang.String data)
        Adds a key/value pair to the input content.
        Parameters:
        key - key with which the specified data is to be added
        data - data to be added with the specified key
      • add

        public void add​(java.lang.String key,
                        BytesSupplier data)
        Adds a key/value pair to the input content.
        Parameters:
        key - key with which the specified data is to be added
        data - data to be added with the specified key
      • add

        public void add​(int index,
                        java.lang.String key,
                        BytesSupplier data)
        Inserts the specified element at the specified position in the input.
        Parameters:
        index - the index at which the specified element is to be inserted
        key - key with which the specified data is to be added
        data - data to be added with the specified key
      • getData

        public BytesSupplier getData()
        Returns the default data item.
        Returns:
        the default data item
      • getDataAsNDList

        public NDList getDataAsNDList​(NDManager manager)
        Returns the default data as NDList.
        Parameters:
        manager - NDManager used to create this NDArray
        Returns:
        the default data as NDList
      • get

        public BytesSupplier get​(java.lang.String key)
        Returns the element for the first key found in the Input.
        Parameters:
        key - the key of the element to get
        Returns:
        the element for the first key found in the Input
      • get

        public BytesSupplier get​(int index)
        Returns the element at the specified position in the Input.
        Parameters:
        index - the index of the element to return
        Returns:
        the element at the specified position in the Input
      • getAsBytes

        public byte[] getAsBytes​(java.lang.String key)
        Returns the value as byte[] for the first key found in the Input.
        Parameters:
        key - the key of the element to get
        Returns:
        the value as byte[] for the first key found in the Input
      • getAsBytes

        public byte[] getAsBytes​(int index)
        Returns the value as byte[] at the specified position in the Input.
        Parameters:
        index - the index of the element to return
        Returns:
        the value as byte[] at the specified position in the Input
      • getAsString

        public java.lang.String getAsString​(java.lang.String key)
        Returns the value as byte[] for the first key found in the Input.
        Parameters:
        key - the key of the element to get
        Returns:
        the value as byte[] for the first key found in the Input
      • getAsString

        public java.lang.String getAsString​(int index)
        Returns the value as byte[] at the specified position in the Input.
        Parameters:
        index - the index of the element to return
        Returns:
        the value as byte[] at the specified position in the Input
      • getAsNDArray

        public NDArray getAsNDArray​(NDManager manager,
                                    java.lang.String key)
        Returns the value as NDArray for the first key found in the Input.
        Parameters:
        manager - NDManager used to create this NDArray
        key - the key of the element to get
        Returns:
        the value as NDArray for the first key found in the Input
      • getAsNDArray

        public NDArray getAsNDArray​(NDManager manager,
                                    int index)
        Returns the value as NDArray at the specified position in the Input.
        Parameters:
        manager - NDManager used to create this NDArray
        index - the index of the element to return
        Returns:
        the value as NDArray at the specified position in the Input
      • getAsNDList

        public NDList getAsNDList​(NDManager manager,
                                  java.lang.String key)
        Returns the value as NDList for the first key found in the Input.
        Parameters:
        manager - NDManager used to create this NDArray
        key - the key of the element to get
        Returns:
        the value as NDList for the first key found in the Input
      • getAsNDList

        public NDList getAsNDList​(NDManager manager,
                                  int index)
        Returns the value as NDList at the specified position in the Input.
        Parameters:
        manager - NDManager used to create this NDArray
        index - the index of the element to return
        Returns:
        the value as NDList at the specified position in the Input
      • toString

        public java.lang.String toString()
        *
        Overrides:
        toString in class java.lang.Object