AlanB commited on
Commit
5db5932
·
1 Parent(s): a52dc91

Added vae_slicing option

Browse files
Files changed (1) hide show
  1. pipeline.py +15 -0
pipeline.py CHANGED
@@ -135,6 +135,21 @@ class ImagicStableDiffusionPipeline(DiffusionPipeline):
135
  # set slice_size = `None` to disable `attention slicing`
136
  self.enable_attention_slicing(None)
137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  def train(
139
  self,
140
  prompt: Union[str, List[str]],
 
135
  # set slice_size = `None` to disable `attention slicing`
136
  self.enable_attention_slicing(None)
137
 
138
+ def enable_vae_slicing(self):
139
+ r"""
140
+ Enable sliced VAE decoding.
141
+ When this option is enabled, the VAE will split the input tensor in slices to compute decoding in several
142
+ steps. This is useful to save some memory and allow larger batch sizes.
143
+ """
144
+ self.vae.enable_slicing()
145
+
146
+ def disable_vae_slicing(self):
147
+ r"""
148
+ Disable sliced VAE decoding. If `enable_vae_slicing` was previously invoked, this method will go back to
149
+ computing decoding in one step.
150
+ """
151
+ self.vae.disable_slicing()
152
+
153
  def train(
154
  self,
155
  prompt: Union[str, List[str]],