Class ParameterInit
java.lang.Object
smile.deep.layer.ParameterInit
Controls whether
LinearLayer / EmbeddingLayer skip default
parameter initialization (Kaiming / normal) and where empty parameter
storage is allocated. Inference weight load wraps model construction in
uninitialized(Device) so shells land on the target GPU without a
full host-side empty model footprint.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumScope handle ofplaceholderGemms().static enumDecrements the skip depth when closed. -
Method Summary
Modifier and TypeMethodDescriptionstatic Devicedevice()Target device for empty Linear/Embedding shells in the current scope.static ParameterInit.GemmScopeOpens a scope in whichLinearLayer.gemm(int, int, boolean)creates a 1x1 placeholder instead of the full weight.static booleanskip()static booleanReturnstrueinside aplaceholderGemms()scope.static ParameterInit.ScopeOpens a scope where new Linear/Embedding layers skip parameter init and allocate empty storage on CPU.static ParameterInit.Scopeuninitialized(Device device) Opens a scope where new Linear/Embedding layers skip parameter init and allocate empty storage ondevice(e.g.
-
Method Details
-
skipGemmWeights
public static boolean skipGemmWeights()Returnstrueinside aplaceholderGemms()scope.- Returns:
trueifLinearLayer.gemm(int, int, boolean)should skip allocating the weight.
-
placeholderGemms
Opens a scope in whichLinearLayer.gemm(int, int, boolean)creates a 1x1 placeholder instead of the full weight. Used when quantized replacements (FP8, Marlin) will be installed for those projections, so the dense bf16 shells (twice the size of the FP8 weights) never exist on the device.- Returns:
- scope handle (close to leave the region).
-
skip
public static boolean skip()- Returns:
trueif parameter init should be skipped.
-
device
Target device for empty Linear/Embedding shells in the current scope. Defaults to CPU when not inside a device-aware uninitialized scope.- Returns:
- target device for empty parameter storage.
-
uninitialized
Opens a scope where new Linear/Embedding layers skip parameter init and allocate empty storage on CPU.- Returns:
- scope handle (close to leave the uninitialized region).
-
uninitialized
Opens a scope where new Linear/Embedding layers skip parameter init and allocate empty storage ondevice(e.g. the rank's CUDA device).- Parameters:
device- target device for empty parameter tensors.- Returns:
- scope handle (close to leave the uninitialized region).
-