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

Include bin and headers to packaging and provide option to ensure tests can use precompiled trtorch libs #670

Merged
merged 11 commits into from
Oct 20, 2021

Conversation

peri044
Copy link
Collaborator

@peri044 peri044 commented Oct 18, 2021

Description

Include bin and headers to packaging and provide option to ensure tests can use precompiled trtorch libs

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes

@github-actions github-actions bot added component: api [Python] Issues re: Python API component: build system Issues re: Build system component: tests Issues re: Tests labels Oct 18, 2021
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes that do not conform to Python style guidelines:

Reformatting /workspace/py/trtorch/logging.py
Reformatting /workspace/py/trtorch/_compile_spec.py
Reformatting /workspace/py/trtorch/__init__.py
Reformatting /workspace/py/trtorch/ptq.py
Reformatting /workspace/py/trtorch/Input.py
Reformatting /workspace/py/trtorch/_types.py
Reformatting /workspace/py/trtorch/_compiler.py
Reformatting /workspace/py/trtorch/Device.py
--- /workspace/py/setup.py	(original)
+++ /workspace/py/setup.py	(reformatted)
@@ -105,6 +105,7 @@
    with open(dir_path + '/trtorch/_version.py', 'w') as f:
        print("creating version file")
        f.write("__version__ = \"" + __version__ + '\"')
+

def copy_libtrtorch(multilinux=False):
    if not os.path.exists(dir_path + '/trtorch/lib'):
@@ -257,27 +258,16 @@
      python_requires='>=3.6',
      include_package_data=True,
      package_data={
-          'trtorch': ['lib/*',
-                      'include/trtorch/*.h',
-                      'include/trtorch/core/*.h',
-                      'include/trtorch/core/conversion/*.h',
-                      'include/trtorch/core/conversion/conversionctx/*.h',
-                      'include/trtorch/core/conversion/converters/*.h',
-                      'include/trtorch/core/conversion/evaluators/*.h',
-                      'include/trtorch/core/conversion/tensorcontainer/*.h',
-                      'include/trtorch/core/conversion/var/*.h',
-                      'include/trtorch/core/ir/*.h',
-                      'include/trtorch/core/lowering/*.h',
-                      'include/trtorch/core/lowering/passes/*.h',
-                      'include/trtorch/core/partitioning/*.h',
-                      'include/trtorch/core/plugins/*.h',
-                      'include/trtorch/core/plugins/impl/*.h',
-                      'include/trtorch/core/runtime/*.h',
-                      'include/trtorch/core/util/*.h',
-                      'include/trtorch/core/util/logging/*.h',
-                      'bin/*',
-                      'BUILD',
-                      'WORKSPACE'],
+          'trtorch': [
+              'lib/*', 'include/trtorch/*.h', 'include/trtorch/core/*.h', 'include/trtorch/core/conversion/*.h',
+              'include/trtorch/core/conversion/conversionctx/*.h', 'include/trtorch/core/conversion/converters/*.h',
+              'include/trtorch/core/conversion/evaluators/*.h', 'include/trtorch/core/conversion/tensorcontainer/*.h',
+              'include/trtorch/core/conversion/var/*.h', 'include/trtorch/core/ir/*.h',
+              'include/trtorch/core/lowering/*.h', 'include/trtorch/core/lowering/passes/*.h',
+              'include/trtorch/core/partitioning/*.h', 'include/trtorch/core/plugins/*.h',
+              'include/trtorch/core/plugins/impl/*.h', 'include/trtorch/core/runtime/*.h',
+              'include/trtorch/core/util/*.h', 'include/trtorch/core/util/logging/*.h', 'bin/*', 'BUILD', 'WORKSPACE'
+          ],
      },
      exclude_package_data={
          '': ['*.cpp'],
Reformatting /workspace/py/setup.py
ERROR: Some files do not conform to style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes that do not conform to Python style guidelines:

Reformatting /workspace/py/trtorch/logging.py
Reformatting /workspace/py/trtorch/_compile_spec.py
Reformatting /workspace/py/trtorch/__init__.py
Reformatting /workspace/py/trtorch/ptq.py
Reformatting /workspace/py/trtorch/Input.py
Reformatting /workspace/py/trtorch/_types.py
Reformatting /workspace/py/trtorch/_compiler.py
Reformatting /workspace/py/trtorch/Device.py
--- /workspace/py/setup.py	(original)
+++ /workspace/py/setup.py	(reformatted)
@@ -105,6 +105,7 @@
    with open(dir_path + '/trtorch/_version.py', 'w') as f:
        print("creating version file")
        f.write("__version__ = \"" + __version__ + '\"')
+

def copy_libtrtorch(multilinux=False):
    if not os.path.exists(dir_path + '/trtorch/lib'):
@@ -257,27 +258,16 @@
      python_requires='>=3.6',
      include_package_data=True,
      package_data={
-          'trtorch': ['lib/*',
-                      'include/trtorch/*.h',
-                      'include/trtorch/core/*.h',
-                      'include/trtorch/core/conversion/*.h',
-                      'include/trtorch/core/conversion/conversionctx/*.h',
-                      'include/trtorch/core/conversion/converters/*.h',
-                      'include/trtorch/core/conversion/evaluators/*.h',
-                      'include/trtorch/core/conversion/tensorcontainer/*.h',
-                      'include/trtorch/core/conversion/var/*.h',
-                      'include/trtorch/core/ir/*.h',
-                      'include/trtorch/core/lowering/*.h',
-                      'include/trtorch/core/lowering/passes/*.h',
-                      'include/trtorch/core/partitioning/*.h',
-                      'include/trtorch/core/plugins/*.h',
-                      'include/trtorch/core/plugins/impl/*.h',
-                      'include/trtorch/core/runtime/*.h',
-                      'include/trtorch/core/util/*.h',
-                      'include/trtorch/core/util/logging/*.h',
-                      'bin/*',
-                      'BUILD',
-                      'WORKSPACE'],
+          'trtorch': [
+              'lib/*', 'include/trtorch/*.h', 'include/trtorch/core/*.h', 'include/trtorch/core/conversion/*.h',
+              'include/trtorch/core/conversion/conversionctx/*.h', 'include/trtorch/core/conversion/converters/*.h',
+              'include/trtorch/core/conversion/evaluators/*.h', 'include/trtorch/core/conversion/tensorcontainer/*.h',
+              'include/trtorch/core/conversion/var/*.h', 'include/trtorch/core/ir/*.h',
+              'include/trtorch/core/lowering/*.h', 'include/trtorch/core/lowering/passes/*.h',
+              'include/trtorch/core/partitioning/*.h', 'include/trtorch/core/plugins/*.h',
+              'include/trtorch/core/plugins/impl/*.h', 'include/trtorch/core/runtime/*.h',
+              'include/trtorch/core/util/*.h', 'include/trtorch/core/util/logging/*.h', 'bin/*', 'BUILD', 'WORKSPACE'
+          ],
      },
      exclude_package_data={
          '': ['*.cpp'],
Reformatting /workspace/py/setup.py
ERROR: Some files do not conform to style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes that do not conform to Python style guidelines:

Reformatting /workspace/py/trtorch/logging.py
Reformatting /workspace/py/trtorch/_compile_spec.py
Reformatting /workspace/py/trtorch/__init__.py
Reformatting /workspace/py/trtorch/ptq.py
Reformatting /workspace/py/trtorch/Input.py
Reformatting /workspace/py/trtorch/_types.py
Reformatting /workspace/py/trtorch/_compiler.py
Reformatting /workspace/py/trtorch/Device.py
--- /workspace/py/setup.py	(original)
+++ /workspace/py/setup.py	(reformatted)
@@ -105,6 +105,7 @@
    with open(dir_path + '/trtorch/_version.py', 'w') as f:
        print("creating version file")
        f.write("__version__ = \"" + __version__ + '\"')
+

def copy_libtrtorch(multilinux=False):
    if not os.path.exists(dir_path + '/trtorch/lib'):
@@ -257,27 +258,16 @@
      python_requires='>=3.6',
      include_package_data=True,
      package_data={
-          'trtorch': ['lib/*',
-                      'include/trtorch/*.h',
-                      'include/trtorch/core/*.h',
-                      'include/trtorch/core/conversion/*.h',
-                      'include/trtorch/core/conversion/conversionctx/*.h',
-                      'include/trtorch/core/conversion/converters/*.h',
-                      'include/trtorch/core/conversion/evaluators/*.h',
-                      'include/trtorch/core/conversion/tensorcontainer/*.h',
-                      'include/trtorch/core/conversion/var/*.h',
-                      'include/trtorch/core/ir/*.h',
-                      'include/trtorch/core/lowering/*.h',
-                      'include/trtorch/core/lowering/passes/*.h',
-                      'include/trtorch/core/partitioning/*.h',
-                      'include/trtorch/core/plugins/*.h',
-                      'include/trtorch/core/plugins/impl/*.h',
-                      'include/trtorch/core/runtime/*.h',
-                      'include/trtorch/core/util/*.h',
-                      'include/trtorch/core/util/logging/*.h',
-                      'bin/*',
-                      'BUILD',
-                      'WORKSPACE'],
+          'trtorch': [
+              'lib/*', 'include/trtorch/*.h', 'include/trtorch/core/*.h', 'include/trtorch/core/conversion/*.h',
+              'include/trtorch/core/conversion/conversionctx/*.h', 'include/trtorch/core/conversion/converters/*.h',
+              'include/trtorch/core/conversion/evaluators/*.h', 'include/trtorch/core/conversion/tensorcontainer/*.h',
+              'include/trtorch/core/conversion/var/*.h', 'include/trtorch/core/ir/*.h',
+              'include/trtorch/core/lowering/*.h', 'include/trtorch/core/lowering/passes/*.h',
+              'include/trtorch/core/partitioning/*.h', 'include/trtorch/core/plugins/*.h',
+              'include/trtorch/core/plugins/impl/*.h', 'include/trtorch/core/runtime/*.h',
+              'include/trtorch/core/util/*.h', 'include/trtorch/core/util/logging/*.h', 'bin/*', 'BUILD', 'WORKSPACE'
+          ],
      },
      exclude_package_data={
          '': ['*.cpp'],
Reformatting /workspace/py/setup.py
ERROR: Some files do not conform to style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to C++ style guidelines

Signed-off-by: Dheeraj Peri <[email protected]>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes that do not conform to Python style guidelines:

Reformatting /workspace/py/trtorch/logging.py
Reformatting /workspace/py/trtorch/_compile_spec.py
Reformatting /workspace/py/trtorch/__init__.py
Reformatting /workspace/py/trtorch/ptq.py
Reformatting /workspace/py/trtorch/Input.py
Reformatting /workspace/py/trtorch/_types.py
Reformatting /workspace/py/trtorch/_compiler.py
Reformatting /workspace/py/trtorch/Device.py
--- /workspace/py/setup.py	(original)
+++ /workspace/py/setup.py	(reformatted)
@@ -105,6 +105,7 @@
    with open(dir_path + '/trtorch/_version.py', 'w') as f:
        print("creating version file")
        f.write("__version__ = \"" + __version__ + '\"')
+

def copy_libtrtorch(multilinux=False):
    if not os.path.exists(dir_path + '/trtorch/lib'):
@@ -257,27 +258,16 @@
      python_requires='>=3.6',
      include_package_data=True,
      package_data={
-          'trtorch': ['lib/*',
-                      'include/trtorch/*.h',
-                      'include/trtorch/core/*.h',
-                      'include/trtorch/core/conversion/*.h',
-                      'include/trtorch/core/conversion/conversionctx/*.h',
-                      'include/trtorch/core/conversion/converters/*.h',
-                      'include/trtorch/core/conversion/evaluators/*.h',
-                      'include/trtorch/core/conversion/tensorcontainer/*.h',
-                      'include/trtorch/core/conversion/var/*.h',
-                      'include/trtorch/core/ir/*.h',
-                      'include/trtorch/core/lowering/*.h',
-                      'include/trtorch/core/lowering/passes/*.h',
-                      'include/trtorch/core/partitioning/*.h',
-                      'include/trtorch/core/plugins/*.h',
-                      'include/trtorch/core/plugins/impl/*.h',
-                      'include/trtorch/core/runtime/*.h',
-                      'include/trtorch/core/util/*.h',
-                      'include/trtorch/core/util/logging/*.h',
-                      'bin/*',
-                      'BUILD',
-                      'WORKSPACE'],
+          'trtorch': [
+              'lib/*', 'include/trtorch/*.h', 'include/trtorch/core/*.h', 'include/trtorch/core/conversion/*.h',
+              'include/trtorch/core/conversion/conversionctx/*.h', 'include/trtorch/core/conversion/converters/*.h',
+              'include/trtorch/core/conversion/evaluators/*.h', 'include/trtorch/core/conversion/tensorcontainer/*.h',
+              'include/trtorch/core/conversion/var/*.h', 'include/trtorch/core/ir/*.h',
+              'include/trtorch/core/lowering/*.h', 'include/trtorch/core/lowering/passes/*.h',
+              'include/trtorch/core/partitioning/*.h', 'include/trtorch/core/plugins/*.h',
+              'include/trtorch/core/plugins/impl/*.h', 'include/trtorch/core/runtime/*.h',
+              'include/trtorch/core/util/*.h', 'include/trtorch/core/util/logging/*.h', 'bin/*', 'BUILD', 'WORKSPACE'
+          ],
      },
      exclude_package_data={
          '': ['*.cpp'],
Reformatting /workspace/py/setup.py
ERROR: Some files do not conform to style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to C++ style guidelines

py/setup.py Outdated
@@ -258,9 +257,29 @@ def run(self):
python_requires='>=3.6',
include_package_data=True,
package_data={
'trtorch': ['lib/*.so'],
'trtorch': ['lib/*',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to list every directory, can we not glob?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably can use python glob library (glob.glob(pattern) - requires 3/4 patterns).
Naive globbing (eg: providing directly include/**/*.h, include/**/**/*.h etc in trtorch key doesn't work. Referred to pytorch setup.py which included all directories https://github.com/pytorch/pytorch/blob/master/setup.py#L918

@@ -76,7 +76,6 @@ cc_test(
"//tests/modules:jit_models",
],
deps = [
"//cpp:trtorch",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did we not have to replace any of these dependencies?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get your question. We replaced //cpp:trtorch with //tests/util which adds //cpp:trtorch based on the trtorch_src flag

Signed-off-by: Naren Dasan <[email protected]>
Signed-off-by: Naren Dasan <[email protected]>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes that do not conform to Python style guidelines:

Reformatting /workspace/py/trtorch/logging.py
Reformatting /workspace/py/trtorch/_compile_spec.py
Reformatting /workspace/py/trtorch/__init__.py
Reformatting /workspace/py/trtorch/ptq.py
Reformatting /workspace/py/trtorch/Input.py
Reformatting /workspace/py/trtorch/_types.py
Reformatting /workspace/py/trtorch/_compiler.py
Reformatting /workspace/py/trtorch/Device.py
--- /workspace/py/setup.py	(original)
+++ /workspace/py/setup.py	(reformatted)
@@ -106,6 +106,7 @@
        print("creating version file")
        f.write("__version__ = \"" + __version__ + '\"')

+
def copy_libtrtorch(multilinux=False):
    if not os.path.exists(dir_path + '/trtorch/lib'):
        os.makedirs(dir_path + '/trtorch/lib')
@@ -171,15 +172,8 @@
class CleanCommand(Command):
    """Custom clean command to tidy up the project root."""
    PY_CLEAN_FILES = [
-        './build',
-        './dist',
-        './trtorch/__pycache__',
-        './trtorch/lib',
-        './trtorch/include',
-        './trtorch/bin',
-        './*.pyc',
-        './*.tgz',
-        './*.egg-info'
+        './build', './dist', './trtorch/__pycache__', './trtorch/lib', './trtorch/include', './trtorch/bin', './*.pyc',
+        './*.tgz', './*.egg-info'
    ]
    description = "Command to tidy up the project root"
    user_options = []
@@ -265,27 +259,16 @@
      python_requires='>=3.6',
      include_package_data=True,
      package_data={
-          'trtorch': ['lib/*',
-                      'include/trtorch/*.h',
-                      'include/trtorch/core/*.h',
-                      'include/trtorch/core/conversion/*.h',
-                      'include/trtorch/core/conversion/conversionctx/*.h',
-                      'include/trtorch/core/conversion/converters/*.h',
-                      'include/trtorch/core/conversion/evaluators/*.h',
-                      'include/trtorch/core/conversion/tensorcontainer/*.h',
-                      'include/trtorch/core/conversion/var/*.h',
-                      'include/trtorch/core/ir/*.h',
-                      'include/trtorch/core/lowering/*.h',
-                      'include/trtorch/core/lowering/passes/*.h',
-                      'include/trtorch/core/partitioning/*.h',
-                      'include/trtorch/core/plugins/*.h',
-                      'include/trtorch/core/plugins/impl/*.h',
-                      'include/trtorch/core/runtime/*.h',
-                      'include/trtorch/core/util/*.h',
-                      'include/trtorch/core/util/logging/*.h',
-                      'bin/*',
-                      'BUILD',
-                      'WORKSPACE'],
+          'trtorch': [
+              'lib/*', 'include/trtorch/*.h', 'include/trtorch/core/*.h', 'include/trtorch/core/conversion/*.h',
+              'include/trtorch/core/conversion/conversionctx/*.h', 'include/trtorch/core/conversion/converters/*.h',
+              'include/trtorch/core/conversion/evaluators/*.h', 'include/trtorch/core/conversion/tensorcontainer/*.h',
+              'include/trtorch/core/conversion/var/*.h', 'include/trtorch/core/ir/*.h',
+              'include/trtorch/core/lowering/*.h', 'include/trtorch/core/lowering/passes/*.h',
+              'include/trtorch/core/partitioning/*.h', 'include/trtorch/core/plugins/*.h',
+              'include/trtorch/core/plugins/impl/*.h', 'include/trtorch/core/runtime/*.h',
+              'include/trtorch/core/util/*.h', 'include/trtorch/core/util/logging/*.h', 'bin/*', 'BUILD', 'WORKSPACE'
+          ],
      },
      exclude_package_data={
          '': ['*.cpp'],
Reformatting /workspace/py/setup.py
ERROR: Some files do not conform to style guidelines

Signed-off-by: Naren Dasan <[email protected]>
Signed-off-by: Naren Dasan <[email protected]>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to Python style guidelines

@narendasan narendasan merged commit 601ca12 into master Oct 20, 2021
@narendasan narendasan deleted the build_workspace branch October 20, 2021 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: api [Python] Issues re: Python API component: build system Issues re: Build system component: tests Issues re: Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants