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
c6c3294d
Unverified
Commit
c6c3294d
authored
Mar 30, 2020
by
theonekeyg
Committed by
GitHub
Mar 30, 2020
Browse files
Replace 2 transpose ops with 1 permute (#2018)
parent
ac4b9f87
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
2 deletions
+1
-2
torchvision/transforms/functional.py
torchvision/transforms/functional.py
+1
-2
No files found.
torchvision/transforms/functional.py
View file @
c6c3294d
...
@@ -84,8 +84,7 @@ def to_tensor(pic):
...
@@ -84,8 +84,7 @@ def to_tensor(pic):
img
=
img
.
view
(
pic
.
size
[
1
],
pic
.
size
[
0
],
len
(
pic
.
getbands
()))
img
=
img
.
view
(
pic
.
size
[
1
],
pic
.
size
[
0
],
len
(
pic
.
getbands
()))
# put it from HWC to CHW format
# put it from HWC to CHW format
# yikes, this transpose takes 80% of the loading time/CPU
img
=
img
.
permute
((
2
,
0
,
1
)).
contiguous
()
img
=
img
.
transpose
(
0
,
1
).
transpose
(
0
,
2
).
contiguous
()
if
isinstance
(
img
,
torch
.
ByteTensor
):
if
isinstance
(
img
,
torch
.
ByteTensor
):
return
img
.
float
().
div
(
255
)
return
img
.
float
().
div
(
255
)
else
:
else
:
...
...
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