DiffusionEngine

suspend fun DiffusionEngine(modelPath: String, backendConfig: BackendConfig = BackendConfig.DEFAULT, options: DiffusionEngineOptions = DiffusionEngineOptions()): DiffusionEngine(source)

Loads a full Stable Diffusion checkpoint (.gguf, .safetensors or .ckpt) with stable-diffusion.cpp and returns a ready DiffusionEngine. Same as the DiffusionModelFiles overload with DiffusionModelFiles(modelPath).


suspend fun DiffusionEngine(model: DiffusionModelFiles, backendConfig: BackendConfig = BackendConfig.DEFAULT, options: DiffusionEngineOptions = DiffusionEngineOptions()): DiffusionEngine(source)

Loads model with stable-diffusion.cpp and returns a ready DiffusionEngine.

The weights are loaded on the new engine's own dedicated thread. backendConfig is enforced at load time:

BackendConfig.cpuThreads sets the CPU threads (BackendConfig.AUTO_THREADS = performance cores), BackendConfig.useFlashAttention flash attention in every module (off when null), and BackendConfig.useMmap whether the weight files are memory-mapped.

Throws

if a file is missing or not a loadable diffusion model.

if the backend is unavailable and fallback is off.

if the weights cannot be allocated.

if the native libraries cannot be loaded.