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
OpenDAS
dgl
Commits
3db6604e
Unverified
Commit
3db6604e
authored
Dec 15, 2022
by
Xin Yao
Committed by
GitHub
Dec 15, 2022
Browse files
[Fix core lib warning] Fix using `torch.tensor` for tensor conversion (#5028)
parent
9731e023
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
3 deletions
+3
-3
python/dgl/backend/pytorch/tensor.py
python/dgl/backend/pytorch/tensor.py
+1
-1
python/dgl/nn/pytorch/glob.py
python/dgl/nn/pytorch/glob.py
+2
-2
No files found.
python/dgl/backend/pytorch/tensor.py
View file @
3db6604e
...
...
@@ -341,7 +341,7 @@ def pack_padded_tensor(input, lengths):
def
boolean_mask
(
input
,
mask
):
if
"bool"
not
in
str
(
mask
.
dtype
):
mask
=
th
.
tensor
(
mask
,
dtype
=
th
.
bool
)
mask
=
th
.
as_
tensor
(
mask
,
dtype
=
th
.
bool
)
return
input
[
mask
]
...
...
python/dgl/nn/pytorch/glob.py
View file @
3db6604e
...
...
@@ -729,8 +729,8 @@ class MultiHeadAttention(nn.Module):
max_len_x
=
max
(
lengths_x
)
max_len_mem
=
max
(
lengths_mem
)
device
=
x
.
device
lengths_x
=
th
.
tensor
(
lengths_x
,
dtype
=
th
.
int64
,
device
=
device
)
lengths_mem
=
th
.
tensor
(
lengths_mem
,
dtype
=
th
.
int64
,
device
=
device
)
lengths_x
=
th
.
as_
tensor
(
lengths_x
,
dtype
=
th
.
int64
,
device
=
device
)
lengths_mem
=
th
.
as_
tensor
(
lengths_mem
,
dtype
=
th
.
int64
,
device
=
device
)
queries
=
self
.
proj_q
(
x
).
view
(
-
1
,
self
.
num_heads
,
self
.
d_head
)
keys
=
self
.
proj_k
(
mem
).
view
(
-
1
,
self
.
num_heads
,
self
.
d_head
)
...
...
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