Package ai.djl.translate
Class PaddingStackBatchifier.Builder
java.lang.Object
ai.djl.translate.PaddingStackBatchifier.Builder
- Enclosing class:
- PaddingStackBatchifier
Builder to build a
PaddingStackBatchifier
.-
Method Summary
Modifier and TypeMethodDescriptionaddPad
(int array, int dim, NDArraySupplier supplier) Adds a new dimension to be padded in the inputNDList
.addPad
(int array, int dim, NDArraySupplier supplier, int paddingSize) Adds a new dimension to be padded in the inputNDList
.build()
Builds thePaddingStackBatchifier
.optIncludeValidLengths
(boolean includeValidLengths) Sets whether to include the valid lengths (length of non-padded data) for each array.
-
Method Details
-
optIncludeValidLengths
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
Adds a new dimension to be padded in the inputNDList
.- Parameters:
array
- which array in theNDList
to paddim
- which dimension in the array to padsupplier
- 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 inputNDList
.- Parameters:
array
- which array in theNDList
to paddim
- which dimension in the array to padsupplier
- 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 CpaddingSize
- the minimum padding size to use. All sequences to pad must be less than this size- Returns:
- this builder
-
build
Builds thePaddingStackBatchifier
.- Returns:
- the constructed
PaddingStackBatchifier
-