1
0

external_benchmark_load_stable_diffusion.py 565 B

12345678910111213
  1. from tinygrad.helpers import fetch, Timing
  2. from tinygrad.device import Device
  3. from tinygrad.nn.state import torch_load, load_state_dict
  4. from examples.stable_diffusion import StableDiffusion
  5. # run "sudo purge" before testing on OS X to avoid the memory cache
  6. if __name__ == "__main__":
  7. fn = fetch('https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt', 'sd-v1-4.ckpt')
  8. model = StableDiffusion()
  9. with Timing():
  10. load_state_dict(model, torch_load(fn)['state_dict'], strict=False)
  11. Device[Device.DEFAULT].synchronize()