-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Automatically detect C++ dependency presence
- Default automatically to test for presence of C++ dependency and use appropriate runtime if not specified by the user
- Loading branch information
Showing
11 changed files
with
97 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import logging | ||
from typing import Optional | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def use_python_runtime_parser(use_python_runtime: Optional[bool] = None) -> bool: | ||
"""Parses a user-provided input argument regarding Python runtime | ||
Automatically handles cases where the user has not specified a runtime (None) | ||
Returns True if the Python runtime should be used, False if the C++ runtime should be used | ||
""" | ||
using_python_runtime = use_python_runtime | ||
reason = "" | ||
|
||
# Runtime was manually specified by the user | ||
if using_python_runtime is not None: | ||
reason = "as requested by user" | ||
# Runtime was not manually specified by the user, automatically detect runtime | ||
else: | ||
try: | ||
from torch_tensorrt.dynamo._TorchTensorRTModule import TorchTensorRTModule | ||
|
||
using_python_runtime = False | ||
reason = "since C++ dependency was detected as present" | ||
except ImportError: | ||
using_python_runtime = True | ||
reason = "since import failed, C++ dependency not installed" | ||
|
||
logger.info( | ||
f"Using {'Python' if using_python_runtime else 'C++'} {reason} TRT Runtime" | ||
) | ||
|
||
return using_python_runtime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters