Class ParameterInit

java.lang.Object
smile.deep.layer.ParameterInit

public final class ParameterInit extends Object
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.
  • Method Details

    • skipGemmWeights

      public static boolean skipGemmWeights()
      Returns true inside a placeholderGemms() scope.
      Returns:
      true if LinearLayer.gemm(int, int, boolean) should skip allocating the weight.
    • placeholderGemms

      public static ParameterInit.GemmScope placeholderGemms()
      Opens a scope in which LinearLayer.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 true when the current thread is inside an uninitialized() / uninitialized(Device) scope.
      Returns:
      true if parameter init should be skipped.
    • device

      public static Device 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

      public static ParameterInit.Scope 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

      public static ParameterInit.Scope uninitialized(Device device)
      Opens a scope where new Linear/Embedding layers skip parameter init and allocate empty storage on device (e.g. the rank's CUDA device).
      Parameters:
      device - target device for empty parameter tensors.
      Returns:
      scope handle (close to leave the uninitialized region).