Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
54af3ca7
Unverified
Commit
54af3ca7
authored
May 21, 2025
by
Sayak Paul
Committed by
GitHub
May 21, 2025
Browse files
[chore] allow string device to be passed to randn_tensor. (#11559)
allow string device to be passed to randn_tensor.
parent
ba8dc7dc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
src/diffusers/utils/torch_utils.py
src/diffusers/utils/torch_utils.py
+3
-1
No files found.
src/diffusers/utils/torch_utils.py
View file @
54af3ca7
...
@@ -38,7 +38,7 @@ except (ImportError, ModuleNotFoundError):
...
@@ -38,7 +38,7 @@ except (ImportError, ModuleNotFoundError):
def
randn_tensor
(
def
randn_tensor
(
shape
:
Union
[
Tuple
,
List
],
shape
:
Union
[
Tuple
,
List
],
generator
:
Optional
[
Union
[
List
[
"torch.Generator"
],
"torch.Generator"
]]
=
None
,
generator
:
Optional
[
Union
[
List
[
"torch.Generator"
],
"torch.Generator"
]]
=
None
,
device
:
Optional
[
"torch.device"
]
=
None
,
device
:
Optional
[
Union
[
str
,
"torch.device"
]
]
=
None
,
dtype
:
Optional
[
"torch.dtype"
]
=
None
,
dtype
:
Optional
[
"torch.dtype"
]
=
None
,
layout
:
Optional
[
"torch.layout"
]
=
None
,
layout
:
Optional
[
"torch.layout"
]
=
None
,
):
):
...
@@ -47,6 +47,8 @@ def randn_tensor(
...
@@ -47,6 +47,8 @@ def randn_tensor(
is always created on the CPU.
is always created on the CPU.
"""
"""
# device on which tensor is created defaults to device
# device on which tensor is created defaults to device
if
isinstance
(
device
,
str
):
device
=
torch
.
device
(
device
)
rand_device
=
device
rand_device
=
device
batch_size
=
shape
[
0
]
batch_size
=
shape
[
0
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment