Skip to content
This repository was archived by the owner on Nov 27, 2024. It is now read-only.

Commit 20cc4ff

Browse files
committed
Load/Unload Decoder, Support all model value types
1 parent d3cd25f commit 20cc4ff

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

OnnxStack.StableDiffusion/Diffusers/StableCascade/StableCascadeDiffuser.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ protected override async Task<DenseTensor<float>> DecodeLatentsAsync(PromptOptio
216216
await _vaeDecoder.UnloadAsync();
217217

218218
return imageResult
219-
.GetTensorMutableDataAsSpan<float>()
219+
.ToArray()
220+
.AsSpan()
220221
.NormalizeOneToOne()
221222
.ToDenseTensor(outputDim);
222223
}

OnnxStack.StableDiffusion/Pipelines/StableCascadePipeline.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,30 @@ public StableCascadePipeline(PipelineOptions pipelineOptions, TokenizerModel tok
6363
public override DiffuserPipelineType PipelineType => DiffuserPipelineType.StableCascade;
6464

6565

66+
public override Task LoadAsync()
67+
{
68+
if (_pipelineOptions.MemoryMode == MemoryModeType.Minimum)
69+
return base.LoadAsync();
70+
71+
// Preload all models into VRAM
72+
return Task.WhenAll
73+
(
74+
_decoderUnet.LoadAsync(),
75+
base.LoadAsync()
76+
);
77+
}
78+
79+
80+
/// <summary>
81+
/// Unloads the pipeline.
82+
/// </summary>
83+
/// <returns></returns>
84+
public override Task UnloadAsync()
85+
{
86+
_decoderUnet?.Dispose();
87+
return base.UnloadAsync();
88+
}
89+
6690
/// <summary>
6791
/// Creates the diffuser.
6892
/// </summary>

0 commit comments

Comments
 (0)