stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

[Performance 2/6] Replace einops.rearrange with torch native ops

Open huchenlei opened this issue 1 year ago • 0 comments
trafficstars

Description

According to https://github.com/lllyasviel/stable-diffusion-webui-forge/discussions/716#discussioncomment-9336461, einops.rearrange calls in crossattn is causing extra overhead. Replacing it with torch native ops can save ~55ms/it.

Screenshots/videos:

image

TODO

There are other places where einops.rearrange can be replaced by torch native ops, but this one in CrossAttn is the most critical one. Instrument the usage of einops.rearrange elsewhere might also yield some improvements.

Checklist:

huchenlei avatar May 15 '24 19:05 huchenlei