Upload folder using huggingface_hub
Browse files- main/fresco_v2v.py +3 -2
- main/matryoshka.py +3 -2
main/fresco_v2v.py
CHANGED
|
@@ -404,10 +404,11 @@ def my_forward(
|
|
| 404 |
# TODO: this requires sync between CPU and GPU. So try to pass timesteps as tensors if you can
|
| 405 |
# This would be a good case for the `match` statement (Python 3.10+)
|
| 406 |
is_mps = sample.device.type == "mps"
|
|
|
|
| 407 |
if isinstance(timestep, float):
|
| 408 |
-
dtype = torch.float32 if is_mps else torch.float64
|
| 409 |
else:
|
| 410 |
-
dtype = torch.int32 if is_mps else torch.int64
|
| 411 |
timesteps = torch.tensor([timesteps], dtype=dtype, device=sample.device)
|
| 412 |
elif len(timesteps.shape) == 0:
|
| 413 |
timesteps = timesteps[None].to(sample.device)
|
|
|
|
| 404 |
# TODO: this requires sync between CPU and GPU. So try to pass timesteps as tensors if you can
|
| 405 |
# This would be a good case for the `match` statement (Python 3.10+)
|
| 406 |
is_mps = sample.device.type == "mps"
|
| 407 |
+
is_npu = sample.device.type == "npu"
|
| 408 |
if isinstance(timestep, float):
|
| 409 |
+
dtype = torch.float32 if (is_mps or is_npu) else torch.float64
|
| 410 |
else:
|
| 411 |
+
dtype = torch.int32 if (is_mps or is_npu) else torch.int64
|
| 412 |
timesteps = torch.tensor([timesteps], dtype=dtype, device=sample.device)
|
| 413 |
elif len(timesteps.shape) == 0:
|
| 414 |
timesteps = timesteps[None].to(sample.device)
|
main/matryoshka.py
CHANGED
|
@@ -2806,10 +2806,11 @@ class MatryoshkaUNet2DConditionModel(
|
|
| 2806 |
# TODO: this requires sync between CPU and GPU. So try to pass timesteps as tensors if you can
|
| 2807 |
# This would be a good case for the `match` statement (Python 3.10+)
|
| 2808 |
is_mps = sample.device.type == "mps"
|
|
|
|
| 2809 |
if isinstance(timestep, float):
|
| 2810 |
-
dtype = torch.float32 if is_mps else torch.float64
|
| 2811 |
else:
|
| 2812 |
-
dtype = torch.int32 if is_mps else torch.int64
|
| 2813 |
timesteps = torch.tensor([timesteps], dtype=dtype, device=sample.device)
|
| 2814 |
elif len(timesteps.shape) == 0:
|
| 2815 |
timesteps = timesteps[None].to(sample.device)
|
|
|
|
| 2806 |
# TODO: this requires sync between CPU and GPU. So try to pass timesteps as tensors if you can
|
| 2807 |
# This would be a good case for the `match` statement (Python 3.10+)
|
| 2808 |
is_mps = sample.device.type == "mps"
|
| 2809 |
+
is_npu = sample.device.type == "npu"
|
| 2810 |
if isinstance(timestep, float):
|
| 2811 |
+
dtype = torch.float32 if (is_mps or is_npu) else torch.float64
|
| 2812 |
else:
|
| 2813 |
+
dtype = torch.int32 if (is_mps or is_npu) else torch.int64
|
| 2814 |
timesteps = torch.tensor([timesteps], dtype=dtype, device=sample.device)
|
| 2815 |
elif len(timesteps.shape) == 0:
|
| 2816 |
timesteps = timesteps[None].to(sample.device)
|