Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fx2trt ]add temporary setup.py for fx2trt #1132

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ bazel build //:libtorchtrt --compilation_mode opt
``` shell
bazel build //:libtorchtrt --compilation_mode=dbg
```
### Install only FX module

FX2TRT is python based module in torch_tensorrt. If the users would like to install only the FX module of torch_tensorrt, please run
``` shell
pushd py
python3 setup.py install --fx2trt-only
popd
```

### Native compilation on NVIDIA Jetson AGX
We performed end to end testing on Jetson platform using Jetpack SDK 4.6.
Expand Down Expand Up @@ -316,4 +324,4 @@ Take a look at the [CONTRIBUTING.md](CONTRIBUTING.md)

## License

The Torch-TensorRT license can be found in the LICENSE file. It is licensed with a BSD Style licence
The Torch-TensorRT license can be found in the LICENSE file. It is licensed with a BSD Style licence
53 changes: 40 additions & 13 deletions py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
JETPACK_VERSION = None

__version__ = '1.2.0a0'

FX2TRT_ONLY = False

def get_git_revision_short_hash() -> str:
return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip()

if "--fx2trt-only" in sys.argv:
FX2TRT_ONLY = True
sys.argv.remove("--fx2trt-only")

if "--release" not in sys.argv:
__version__ = __version__ + "+" + get_git_revision_short_hash()
Expand Down Expand Up @@ -138,11 +141,14 @@ def finalize_options(self):
develop.finalize_options(self)

def run(self):
global CXX11_ABI
build_libtorchtrt_pre_cxx11_abi(develop=True, cxx11_abi=CXX11_ABI)
gen_version_file()
copy_libtorchtrt()
develop.run(self)
if FX2TRT_ONLY:
develop.run(self)
else:
global CXX11_ABI
build_libtorchtrt_pre_cxx11_abi(develop=True, cxx11_abi=CXX11_ABI)
gen_version_file()
copy_libtorchtrt()
develop.run(self)


class InstallCommand(install):
Expand All @@ -155,11 +161,14 @@ def finalize_options(self):
install.finalize_options(self)

def run(self):
global CXX11_ABI
build_libtorchtrt_pre_cxx11_abi(develop=False, cxx11_abi=CXX11_ABI)
gen_version_file()
copy_libtorchtrt()
install.run(self)
if FX2TRT_ONLY:
install.run(self)
else:
global CXX11_ABI
build_libtorchtrt_pre_cxx11_abi(develop=False, cxx11_abi=CXX11_ABI)
gen_version_file()
copy_libtorchtrt()
install.run(self)


class BdistCommand(bdist_wheel):
Expand Down Expand Up @@ -254,6 +263,23 @@ def run(self):
] + (["-D_GLIBCXX_USE_CXX11_ABI=1"] if CXX11_ABI else ["-D_GLIBCXX_USE_CXX11_ABI=0"]),
undef_macros=["NDEBUG"])
]
if FX2TRT_ONLY:
ext_modules=None
packages=[
"torch_tensorrt.fx",
"torch_tensorrt.fx.converters",
"torch_tensorrt.fx.passes",
"torch_tensorrt.fx.tools",
"torch_tensorrt.fx.tracer.acc_tracer",
]
package_dir={
"torch_tensorrt.fx": "torch_tensorrt/fx",
"torch_tensorrt.fx.converters": "torch_tensorrt/fx/converters",
"torch_tensorrt.fx.passes": "torch_tensorrt/fx/passes",
"torch_tensorrt.fx.tools": "torch_tensorrt/fx/tools",
"torch_tensorrt.fx.tracer.acc_tracer": "torch_tensorrt/fx/tracer/acc_tracer",
}


with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
Expand Down Expand Up @@ -282,7 +308,8 @@ def run(self):
},
zip_safe=False,
license="BSD",
packages=find_packages(),
packages=packages if FX2TRT_ONLY else find_packages(),
package_dir=package_dir if FX2TRT_ONLY else {},
classifiers=[
"Development Status :: 5 - Stable", "Environment :: GPU :: NVIDIA CUDA",
"License :: OSI Approved :: BSD License", "Intended Audience :: Developers",
Expand Down Expand Up @@ -311,4 +338,4 @@ def run(self):
exclude_package_data={
'': ['*.cpp'],
'torch_tensorrt': ['csrc/*.cpp'],
})
}),