Skip to content

Commit d859859

Browse files
peri044narendasan
andauthored
feat: cherry-pick of Selectively enable different frontends (#2693) (#2761)
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]> Co-authored-by: Naren Dasan <[email protected]>
1 parent d7768ee commit d859859

File tree

84 files changed

+2199
-1001
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+2199
-1001
lines changed

.github/workflows/build-test.yml

+27
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,30 @@ jobs:
229229
${CONDA_RUN} python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_partitioning_test_results.xml partitioning/
230230
${CONDA_RUN} python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_lowering_test_results.xml lowering/
231231
popd
232+
233+
tests-py-core:
234+
name: Test core [Python]
235+
needs: [generate-matrix, build]
236+
strategy:
237+
fail-fast: false
238+
matrix:
239+
include:
240+
- repository: pytorch/tensorrt
241+
package-name: torch_tensorrt
242+
pre-script: packaging/pre_build_script.sh
243+
uses: pytorch/tensorrt/.github/workflows/linux-test.yml@main
244+
with:
245+
job-name: tests-py-core
246+
repository: "pytorch/tensorrt"
247+
ref: ""
248+
test-infra-repository: pytorch/test-infra
249+
test-infra-ref: main
250+
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
251+
pre-script: ${{ matrix.pre-script }}
252+
script: |
253+
export USE_HOST_DEPS=1
254+
pushd .
255+
cd tests/py/core
256+
${CONDA_RUN} python -m pip install --pre pytest-xdist timm transformers parameterized expecttest==0.1.6 --use-deprecated=legacy-resolver
257+
${CONDA_RUN} python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_core_test_results.xml .
258+
popd

.pre-commit-config.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
exclude: ^.github/actions/assigner/dist
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.4.0
4+
rev: v4.5.0
55
hooks:
66
- id: check-yaml
77
- id: trailing-whitespace
@@ -16,38 +16,38 @@ repos:
1616
- --fix=lf
1717
exclude: ^docs
1818
- repo: https://github.com/pre-commit/mirrors-clang-format
19-
rev: v16.0.6
19+
rev: v18.1.1
2020
hooks:
2121
- id: clang-format
2222
types_or: [c++, c, cuda]
2323
- repo: https://github.com/keith/pre-commit-buildifier
24-
rev: 6.1.0.2
24+
rev: 6.4.0
2525
hooks:
2626
- id: buildifier
2727
args:
2828
- --warnings=all
2929
- id: buildifier-lint
3030
- repo: https://github.com/abravalheri/validate-pyproject
31-
rev: v0.13
31+
rev: v0.16
3232
hooks:
3333
- id: validate-pyproject
3434
- repo: https://github.com/pycqa/isort
35-
rev: 5.12.0
35+
rev: 5.13.2
3636
hooks:
3737
- id: isort
3838
name: isort (python)
3939
- repo: https://github.com/pre-commit/mirrors-mypy
40-
rev: 'v1.4.1'
40+
rev: 'v1.9.0'
4141
hooks:
4242
- id: mypy
4343
exclude: "^py/torch_tensorrt/fx|^examples|^tests|^py/torch_tensorrt/dynamo/_experimental|^tools|^docs|noxfile.py|setup.py|versions.py"
4444
- repo: https://github.com/astral-sh/ruff-pre-commit
4545
# Ruff version.
46-
rev: v0.0.278
46+
rev: v0.3.3
4747
hooks:
4848
- id: ruff
4949
- repo: https://github.com/psf/black
50-
rev: 24.1.1
50+
rev: 24.3.0
5151
hooks:
5252
- id: black
5353
exclude: ^examples/custom_converters/elu_converter/setup.py|^docs

BUILD

+35
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ pkg_tar(
3333
],
3434
)
3535

36+
pkg_tar(
37+
name = "include_rt",
38+
package_dir = "include/torch_tensorrt",
39+
deps = [
40+
"//core/runtime:include",
41+
],
42+
)
43+
3644
pkg_tar(
3745
name = "include",
3846
srcs = [
@@ -55,6 +63,18 @@ pkg_tar(
5563
package_dir = "lib/",
5664
)
5765

66+
pkg_tar(
67+
name = "lib_rt",
68+
srcs = select({
69+
":windows": ["//cpp/lib:torch_tensorrt_runtime.dll"],
70+
"//conditions:default": [
71+
"//cpp/lib:libtorchtrt_runtime.so",
72+
],
73+
}),
74+
mode = "0755",
75+
package_dir = "lib/",
76+
)
77+
5878
pkg_tar(
5979
name = "bin",
6080
srcs = [
@@ -82,3 +102,18 @@ pkg_tar(
82102
"//conditions:default": [":bin"],
83103
}),
84104
)
105+
106+
pkg_tar(
107+
name = "libtorchtrt_runtime",
108+
srcs = [
109+
"//:LICENSE",
110+
"//bzl_def:BUILD",
111+
"//bzl_def:WORKSPACE",
112+
],
113+
extension = "tar.gz",
114+
package_dir = "torch_tensorrt_runtime",
115+
deps = [
116+
":include_rt",
117+
":lib_rt",
118+
],
119+
)

core/runtime/RTDevice.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ namespace torch_tensorrt {
77
namespace core {
88
namespace runtime {
99

10-
const std::string DEVICE_INFO_DELIM = "%";
11-
1210
typedef enum { ID_IDX = 0, SM_MAJOR_IDX, SM_MINOR_IDX, DEVICE_TYPE_IDX, DEVICE_NAME_IDX } SerializedDeviceInfoIndex;
1311

1412
RTDevice::RTDevice() : id{-1}, major{-1}, minor{-1}, device_type{nvinfer1::DeviceType::kGPU} {}

core/runtime/RTDevice.h

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ namespace torch_tensorrt {
66
namespace core {
77
namespace runtime {
88

9+
const std::string DEVICE_INFO_DELIM = "%";
10+
911
struct RTDevice {
1012
int64_t id; // CUDA device id
1113
int64_t major; // CUDA compute major version

core/runtime/register_jit_hooks.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ static auto TORCHTRT_UNUSED TRTEngineTSRegistrtion =
116116
TORCH_LIBRARY(tensorrt, m) {
117117
m.def("execute_engine", execute_engine);
118118
m.def("SERIALIZED_ENGINE_BINDING_DELIM", []() -> std::string { return std::string(1, TRTEngine::BINDING_DELIM); });
119+
m.def("SERIALIZED_RT_DEVICE_DELIM", []() -> std::string { return DEVICE_INFO_DELIM; });
119120
m.def("ABI_VERSION", []() -> std::string { return ABI_VERSION; });
120121
m.def("get_multi_device_safe_mode", []() -> bool { return MULTI_DEVICE_SAFE_MODE; });
121122
m.def("set_multi_device_safe_mode", [](bool multi_device_safe_mode) -> void {

docsrc/py_api/torch_tensorrt.rst

+1-5
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ Classes
3737
:members:
3838
:special-members: __init__
3939

40-
.. autoclass:: TRTModuleNext
41-
:members:
42-
:special-members: __init__
43-
4440
Enums
4541
-------
4642

@@ -50,7 +46,7 @@ Enums
5046

5147
.. autoclass:: EngineCapability
5248

53-
.. autoclass:: TensorFormat
49+
.. autoclass:: memory_format
5450

5551
Submodules
5652
----------

examples/dynamo/torch_compile_stable_diffusion.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1919

2020
import torch
21-
from diffusers import DiffusionPipeline
22-
2321
import torch_tensorrt
22+
from diffusers import DiffusionPipeline
2423

2524
model_id = "CompVis/stable-diffusion-v1-4"
2625
device = "cuda:0"
@@ -39,7 +38,7 @@
3938
backend=backend,
4039
options={
4140
"truncate_long_and_double": True,
42-
"precision": torch.float16,
41+
"enabled_precisions": {torch.float32, torch.float16},
4342
},
4443
dynamic=False,
4544
)

0 commit comments

Comments
 (0)