LogicGoInfotechSpaces commited on
Commit
14cc518
·
1 Parent(s): 6c0e8ac

Fix hardcoded CUDA call in StyleCLIP fused_act for curly hair editing

Browse files
editings/styleclip/models/stylegan2/op/fused_act.py CHANGED
@@ -22,11 +22,13 @@ class FusedLeakyReLU(nn.Module):
22
 
23
  def fused_leaky_relu(input, bias, negative_slope=0.2, scale=2**0.5):
24
  rest_dim = [1] * (input.ndim - bias.ndim - 1)
25
- input = input.cuda()
 
 
26
  if input.ndim == 3:
27
  return (
28
  F.leaky_relu(
29
- input + bias.view(1, *rest_dim, bias.shape[0]),
30
  negative_slope=negative_slope,
31
  )
32
  * scale
@@ -34,7 +36,7 @@ def fused_leaky_relu(input, bias, negative_slope=0.2, scale=2**0.5):
34
  else:
35
  return (
36
  F.leaky_relu(
37
- input + bias.view(1, bias.shape[0], *rest_dim),
38
  negative_slope=negative_slope,
39
  )
40
  * scale
 
22
 
23
  def fused_leaky_relu(input, bias, negative_slope=0.2, scale=2**0.5):
24
  rest_dim = [1] * (input.ndim - bias.ndim - 1)
25
+ # Use the same device as input instead of hardcoded CUDA
26
+ device = input.device
27
+ input = input.to(device)
28
  if input.ndim == 3:
29
  return (
30
  F.leaky_relu(
31
+ input + bias.view(1, *rest_dim, bias.shape[0]).to(device),
32
  negative_slope=negative_slope,
33
  )
34
  * scale
 
36
  else:
37
  return (
38
  F.leaky_relu(
39
+ input + bias.view(1, bias.shape[0], *rest_dim).to(device),
40
  negative_slope=negative_slope,
41
  )
42
  * scale