public abstract class AbstractBlock extends java.lang.Object implements Block
AbstractBlock
is an abstract implementation of Block
. It is recommended that all
Block
classes that have children extend the AbstractBlock
.Modifier and Type | Field and Description |
---|---|
protected java.util.List<java.lang.String> |
inputNames |
protected Shape[] |
inputShapes |
Constructor and Description |
---|
AbstractBlock() |
Modifier and Type | Method and Description |
---|---|
protected void |
beforeInitialize(Shape[] inputShapes)
Performs any action necessary before initialization.
|
void |
cast(DataType dataType)
Guaranteed to throw an exception.
|
void |
clear()
Closes all the parameters of the block.
|
ai.djl.util.PairList<java.lang.String,Shape> |
describeInput()
Returns a
PairList of input names, and shapes. |
ParameterList |
getParameters()
Returns a list of all the parameters of the block, including the parameters of its children
fetched recursively.
|
boolean |
isInitialized()
Returns a boolean whether the block is initialized.
|
protected void |
readInputShapes(java.io.DataInputStream is) |
protected void |
saveInputShapes(java.io.DataOutputStream os) |
void |
setInitializer(Initializer initializer)
Sets an
Initializer to the block. |
void |
setInitializer(Initializer initializer,
java.lang.String paramName)
Sets an
Initializer to the specified direct parameter of the block, overriding the
initializer of the parameter, if already set. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forward, forward, getChildren, getDirectParameters, getOutputShapes, getParameterShape, initialize, loadParameters, saveParameters, validateLayout
protected Shape[] inputShapes
protected java.util.List<java.lang.String> inputNames
public ai.djl.util.PairList<java.lang.String,Shape> describeInput()
PairList
of input names, and shapes.describeInput
in interface Block
PairList
of input names, and shapespublic void setInitializer(Initializer initializer)
Initializer
to the block.setInitializer
in interface Block
initializer
- the initializer to setpublic void setInitializer(Initializer initializer, java.lang.String paramName)
Initializer
to the specified direct parameter of the block, overriding the
initializer of the parameter, if already set.setInitializer
in interface Block
initializer
- the initializer to be setparamName
- the name of the parameterpublic ParameterList getParameters()
getParameters
in interface Block
protected void beforeInitialize(Shape[] inputShapes)
inputShapes
- the expected shapes of the inputpublic boolean isInitialized()
isInitialized
in interface Block
public void clear()
public void cast(DataType dataType)
protected void saveInputShapes(java.io.DataOutputStream os) throws java.io.IOException
java.io.IOException
protected void readInputShapes(java.io.DataInputStream is) throws java.io.IOException
java.io.IOException