Skip to content

Commit

Permalink
fix(api): set VAE attn processor during conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Sep 24, 2023
1 parent 6e2896f commit 0ecae65
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions api/onnx_web/convert/diffusion/diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ def convert_diffusion_diffusers(
else:
pipeline.vae = AutoencoderKL.from_pretrained(vae_path)

if is_torch_2_0:
pipeline.unet.set_attn_processor(AttnProcessor())
pipeline.vae.set_attn_processor(AttnProcessor())

optimize_pipeline(conversion, pipeline)

output_path = Path(dest_path)
Expand Down Expand Up @@ -430,9 +434,6 @@ def convert_diffusion_diffusers(
unet_inputs = ["sample", "timestep", "encoder_hidden_states", "return_dict"]
unet_scale = torch.tensor(False).to(device=device, dtype=torch.bool)

if is_torch_2_0:
pipeline.unet.set_attn_processor(AttnProcessor())

unet_in_channels = pipeline.unet.config.in_channels
unet_sample_size = pipeline.unet.config.sample_size
unet_path = output_path / "unet" / ONNX_MODEL
Expand Down

0 comments on commit 0ecae65

Please sign in to comment.