Package ai.djl.translate
Class PaddingStackBatchifier
- java.lang.Object
-
- ai.djl.translate.PaddingStackBatchifier
-
- All Implemented Interfaces:
Batchifier
public final class PaddingStackBatchifier extends java.lang.Object implements Batchifier
The padding stack batchifier is aStackBatchifierthat also pads elements to reach the same length.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPaddingStackBatchifier.BuilderBuilder to build aPaddingStackBatchifier.
-
Field Summary
-
Fields inherited from interface ai.djl.translate.Batchifier
STACK
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description NDListbatchify(NDList[] inputs)Converts an array ofNDListinto an NDList.static PaddingStackBatchifier.Builderbuilder()Returns aPaddingStackBatchifier.Builder.NDList[]split(NDList list, int numOfSlices, boolean evenSplit)Splits the givenNDListinto the given number of slices.NDList[]unbatchify(NDList inputs)Reverses thebatchifyoperation.
-
-
-
Method Detail
-
batchify
public NDList batchify(NDList[] inputs)
Converts an array ofNDListinto an NDList.The size of the input array is the batch size. The data in each of the
NDListare assumed to be the same, and are batched together to form one batchedNDList.- Specified by:
batchifyin interfaceBatchifier- Parameters:
inputs- the input array ofNDListwhere each element is a- Returns:
- the batchified
NDList
-
unbatchify
public NDList[] unbatchify(NDList inputs)
Reverses thebatchifyoperation.- Specified by:
unbatchifyin interfaceBatchifier- Parameters:
inputs- theNDListthat needs to be 'unbatchified'- Returns:
- an array of NDLists, of size equal to batch size, where each NDList is one element from the batch of inputs
-
split
public NDList[] split(NDList list, int numOfSlices, boolean evenSplit)
Splits the givenNDListinto the given number of slices.This function unbatchifies the input
NDList, redistributes them into the given number of slices, and then batchify each of the slices to form an array ofNDList.- Specified by:
splitin interfaceBatchifier- Parameters:
list- theNDListthat needs to be splitnumOfSlices- the number of slices the list must be sliced intoevenSplit- whether each slice must have the same shape- Returns:
- an array of
NDListthat contains all the slices
-
builder
public static PaddingStackBatchifier.Builder builder()
Returns aPaddingStackBatchifier.Builder.- Returns:
- a
PaddingStackBatchifier.Builder
-
-