File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 3434from ldm .invoke .devices import choose_torch_device , choose_precision
3535from ldm .invoke .conditioning import get_uc_and_c
3636
37+ def fix_func (orig ):
38+ if hasattr (torch .backends , 'mps' ) and torch .backends .mps .is_available ():
39+ def new_func (* args , ** kw ):
40+ device = kw .get ("device" , "mps" )
41+ kw ["device" ]= "cpu"
42+ return orig (* args , ** kw ).to (device )
43+ return new_func
44+ return orig
45+
46+ torch .rand = fix_func (torch .rand )
47+ torch .rand_like = fix_func (torch .rand_like )
48+ torch .randn = fix_func (torch .randn )
49+ torch .randn_like = fix_func (torch .randn_like )
50+ torch .randint = fix_func (torch .randint )
51+ torch .randint_like = fix_func (torch .randint_like )
52+ torch .bernoulli = fix_func (torch .bernoulli )
53+ torch .multinomial = fix_func (torch .multinomial )
54+
3755"""Simplified text to image API for stable diffusion/latent diffusion
3856
3957Example Usage:
You can’t perform that action at this time.
0 commit comments