Class PaddingStackBatchifier.Builder

java.lang.Object
ai.djl.translate.PaddingStackBatchifier.Builder
Enclosing class:
PaddingStackBatchifier

public static final class PaddingStackBatchifier.Builder extends Object
Builder to build a PaddingStackBatchifier.
  • Method Details

    • optIncludeValidLengths

      public PaddingStackBatchifier.Builder optIncludeValidLengths(boolean includeValidLengths)
      Sets whether to include the valid lengths (length of non-padded data) for each array.
      Parameters:
      includeValidLengths - true to include valid lengths
      Returns:
      this builder
    • addPad

      public PaddingStackBatchifier.Builder addPad(int array, int dim, NDArraySupplier supplier)
      Adds a new dimension to be padded in the input NDList.
      Parameters:
      array - which array in the NDList to pad
      dim - which dimension in the array to pad
      supplier - a supplier that produces the padding array. The padding array shape should include both the batch and a 1 for the padded dimension. For batch array shape NTC, the padding shape should be N x 1 x C
      Returns:
      this builder
    • addPad

      public PaddingStackBatchifier.Builder addPad(int array, int dim, NDArraySupplier supplier, int paddingSize)
      Adds a new dimension to be padded in the input NDList.
      Parameters:
      array - which array in the NDList to pad
      dim - which dimension in the array to pad
      supplier - a supplier that produces the padding array. The padding array shape should include both the batch and a 1 for the padded dimension. For batch array shape NTC, the padding shape should be N x 1 x C
      paddingSize - the minimum padding size to use. All sequences to pad must be less than this size
      Returns:
      this builder
    • build

      public PaddingStackBatchifier build()
      Returns:
      the constructed PaddingStackBatchifier