Skip to content

Commit d675c0c

Browse files
authored
[FBcode->GH] Move loading Decoder.so to a separate file to avoid building it internally (#5183)
1 parent ffd0d23 commit d675c0c

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

torchvision/io/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
import torch
44

55
from ..utils import _log_api_usage_once
6+
7+
try:
8+
from ._load_gpu_decoder import _HAS_VIDEO_DECODER
9+
except ModuleNotFoundError:
10+
_HAS_VIDEO_DECODER = False
611
from ._video_opt import (
712
Timebase,
813
VideoMetaData,
9-
_HAS_VIDEO_DECODER,
1014
_HAS_VIDEO_OPT,
1115
_probe_video_from_file,
1216
_probe_video_from_memory,

torchvision/io/_load_gpu_decoder.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from ..extension import _load_library
2+
3+
4+
try:
5+
_load_library("Decoder")
6+
_HAS_VIDEO_DECODER = True
7+
except (ImportError, OSError):
8+
_HAS_VIDEO_DECODER = False

torchvision/io/_video_opt.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@
1414
except (ImportError, OSError):
1515
_HAS_VIDEO_OPT = False
1616

17-
try:
18-
_load_library("Decoder")
19-
_HAS_VIDEO_DECODER = True
20-
except (ImportError, OSError):
21-
_HAS_VIDEO_DECODER = False
22-
2317
default_timebase = Fraction(0, 1)
2418

2519

0 commit comments

Comments
 (0)