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
vision
Commits
73de9abe
"src/git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "acb4eb7ecdf126949821b6b2607db5b77fb42acb"
Unverified
Commit
73de9abe
authored
Oct 14, 2020
by
vfdev
Committed by
GitHub
Oct 14, 2020
Browse files
Fixed device when used in _gen_affine_grid and _perspective_grid (#2813)
parent
69dc971e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
torchvision/transforms/functional_tensor.py
torchvision/transforms/functional_tensor.py
+8
-4
No files found.
torchvision/transforms/functional_tensor.py
View file @
73de9abe
...
@@ -929,8 +929,10 @@ def _gen_affine_grid(
...
@@ -929,8 +929,10 @@ def _gen_affine_grid(
d
=
0.5
d
=
0.5
base_grid
=
torch
.
empty
(
1
,
oh
,
ow
,
3
,
dtype
=
theta
.
dtype
,
device
=
theta
.
device
)
base_grid
=
torch
.
empty
(
1
,
oh
,
ow
,
3
,
dtype
=
theta
.
dtype
,
device
=
theta
.
device
)
base_grid
[...,
0
].
copy_
(
torch
.
linspace
(
-
ow
*
0.5
+
d
,
ow
*
0.5
+
d
-
1
,
steps
=
ow
))
x_grid
=
torch
.
linspace
(
-
ow
*
0.5
+
d
,
ow
*
0.5
+
d
-
1
,
steps
=
ow
,
device
=
theta
.
device
)
base_grid
[...,
1
].
copy_
(
torch
.
linspace
(
-
oh
*
0.5
+
d
,
oh
*
0.5
+
d
-
1
,
steps
=
oh
).
unsqueeze_
(
-
1
))
base_grid
[...,
0
].
copy_
(
x_grid
)
y_grid
=
torch
.
linspace
(
-
oh
*
0.5
+
d
,
oh
*
0.5
+
d
-
1
,
steps
=
oh
,
device
=
theta
.
device
).
unsqueeze_
(
-
1
)
base_grid
[...,
1
].
copy_
(
y_grid
)
base_grid
[...,
2
].
fill_
(
1
)
base_grid
[...,
2
].
fill_
(
1
)
rescaled_theta
=
theta
.
transpose
(
1
,
2
)
/
torch
.
tensor
([
0.5
*
w
,
0.5
*
h
],
dtype
=
theta
.
dtype
,
device
=
theta
.
device
)
rescaled_theta
=
theta
.
transpose
(
1
,
2
)
/
torch
.
tensor
([
0.5
*
w
,
0.5
*
h
],
dtype
=
theta
.
dtype
,
device
=
theta
.
device
)
...
@@ -1065,8 +1067,10 @@ def _perspective_grid(coeffs: List[float], ow: int, oh: int, dtype: torch.dtype,
...
@@ -1065,8 +1067,10 @@ def _perspective_grid(coeffs: List[float], ow: int, oh: int, dtype: torch.dtype,
d
=
0.5
d
=
0.5
base_grid
=
torch
.
empty
(
1
,
oh
,
ow
,
3
,
dtype
=
dtype
,
device
=
device
)
base_grid
=
torch
.
empty
(
1
,
oh
,
ow
,
3
,
dtype
=
dtype
,
device
=
device
)
base_grid
[...,
0
].
copy_
(
torch
.
linspace
(
d
,
ow
*
1.0
+
d
-
1.0
,
steps
=
ow
))
x_grid
=
torch
.
linspace
(
d
,
ow
*
1.0
+
d
-
1.0
,
steps
=
ow
,
device
=
device
)
base_grid
[...,
1
].
copy_
(
torch
.
linspace
(
d
,
oh
*
1.0
+
d
-
1.0
,
steps
=
oh
).
unsqueeze_
(
-
1
))
base_grid
[...,
0
].
copy_
(
x_grid
)
y_grid
=
torch
.
linspace
(
d
,
oh
*
1.0
+
d
-
1.0
,
steps
=
oh
,
device
=
device
).
unsqueeze_
(
-
1
)
base_grid
[...,
1
].
copy_
(
y_grid
)
base_grid
[...,
2
].
fill_
(
1
)
base_grid
[...,
2
].
fill_
(
1
)
rescaled_theta1
=
theta1
.
transpose
(
1
,
2
)
/
torch
.
tensor
([
0.5
*
ow
,
0.5
*
oh
],
dtype
=
dtype
,
device
=
device
)
rescaled_theta1
=
theta1
.
transpose
(
1
,
2
)
/
torch
.
tensor
([
0.5
*
ow
,
0.5
*
oh
],
dtype
=
dtype
,
device
=
device
)
...
...
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