Skip to content

Commit c8719d8

Browse files
committed
chore(//py/torch_tensorrt): __init__.py mypy conforming
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
1 parent 491b933 commit c8719d8

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

py/torch_tensorrt/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,23 @@
1212
__tensorrt_version__,
1313
)
1414

15+
from typing import Dict, List
16+
1517
if sys.version_info < (3,):
1618
raise Exception(
1719
"Python 2 has reached end-of-life and is not supported by Torch-TensorRT"
1820
)
1921

2022

21-
def _parse_semver(version):
23+
def _parse_semver(version: str) -> Dict[str, str]:
2224
split = version.split(".")
2325
if len(split) < 3:
2426
split.append("")
2527

2628
return {"major": split[0], "minor": split[1], "patch": split[2]}
2729

2830

29-
def _find_lib(name, paths):
31+
def _find_lib(name: str, paths: List[str]) -> str:
3032
for path in paths:
3133
libpath = os.path.join(path, name)
3234
if os.path.isfile(libpath):
@@ -99,7 +101,7 @@ def _find_lib(name, paths):
99101
from torch_tensorrt.dynamo import backend
100102

101103

102-
def _register_with_torch():
104+
def _register_with_torch() -> None:
103105
trtorch_dir = os.path.dirname(__file__)
104106
torch.ops.load_library(trtorch_dir + "/lib/libtorchtrt.so")
105107

py/torch_tensorrt/_util.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import torch
55

66

7-
def dump_build_info():
7+
def dump_build_info() -> None:
88
"""Prints build information about the torch_tensorrt distribution to stdout"""
99
print(get_build_info())
1010

@@ -15,20 +15,20 @@ def get_build_info() -> str:
1515
Returns:
1616
str: String containing the build information for torch_tensorrt distribution
1717
"""
18-
build_info = _C.get_build_info()
19-
build_info = (
18+
core_build_info = _C.get_build_info()
19+
build_info = str(
2020
"Torch-TensorRT Version: "
2121
+ str(__version__)
2222
+ "\n"
2323
+ "Using PyTorch Version: "
2424
+ str(torch.__version__)
2525
+ "\n"
26-
+ build_info
26+
+ core_build_info
2727
)
2828
return build_info
2929

3030

31-
def set_device(gpu_id):
31+
def set_device(gpu_id: int) -> None:
3232
_C.set_device(gpu_id)
3333

3434

0 commit comments

Comments
 (0)