Skip to content

Commit a88f721

Browse files
committed
IsPipelineCacheEnabled
1 parent db49e04 commit a88f721

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

TensorStack.StableDiffusion/Common/GenerateOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public record GenerateOptions : IPipelineOptions, ISchedulerOptions
4545
public bool IsLowMemoryEncoderEnabled { get; set; }
4646
public bool IsLowMemoryDecoderEnabled { get; set; }
4747
public bool IsLowMemoryTextEncoderEnabled { get; set; }
48-
48+
public bool IsPipelineCacheEnabled { get; set; } = true;
4949

5050
public bool HasControlNet => ControlNet is not null;
5151
public bool HasInputImage => InputImage is not null;

TensorStack.StableDiffusion/Pipelines/IPipelineOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public interface IPipelineOptions : IRunOptions
3636
bool IsLowMemoryEncoderEnabled { get; set; }
3737
bool IsLowMemoryDecoderEnabled { get; set; }
3838
bool IsLowMemoryTextEncoderEnabled { get; set; }
39-
39+
bool IsPipelineCacheEnabled { get; set; }
4040

4141
bool HasControlNet => ControlNet is not null;
4242
bool HasInputImage => InputImage is not null;

TensorStack.StableDiffusion/Pipelines/PipelineBase.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ protected Tensor<float> ApplyGuidance(Tensor<float> conditional, Tensor<float> u
157157
/// <param name="options">The options.</param>
158158
protected PromptResult GetPromptCache(IPipelineOptions options)
159159
{
160+
if (!options.IsPipelineCacheEnabled)
161+
return default;
162+
160163
if (_promptCache is null || !_promptCache.IsValid(options))
161164
return default;
162165

@@ -187,10 +190,10 @@ protected PromptResult SetPromptCache(IPipelineOptions options, PromptResult pro
187190
/// <param name="options">The options.</param>
188191
protected Tensor<float> GetEncoderCache(IPipelineOptions options)
189192
{
190-
if (_encoderCache is null)
193+
if (!options.IsPipelineCacheEnabled)
191194
return default;
192195

193-
if (!_encoderCache.IsValid(options.InputImage))
196+
if (_encoderCache is null || !_encoderCache.IsValid(options.InputImage))
194197
return default;
195198

196199
return _encoderCache.CacheResult;

0 commit comments

Comments
 (0)