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

feat: Add optional tensor domain argument to Input class #1537

Merged
merged 3 commits into from
Feb 9, 2023

Conversation

gs-olive
Copy link
Collaborator

@gs-olive gs-olive commented Dec 8, 2022

Description

  • Add support for specifying one, both, or neither integer bound (in Python) on Tensor domain used for generating a sample tensor in shape analysis
  • Add bounds checking to avoid int32_t overflow issues
  • Add validation for inputs to ensure high bound exceeds low bound and inputs are strictly integers
  • Use [0, 2) as the default bound, which works well as a random-number selection range in cases of Bool, Int, and Float types
  • Add validation in C++ to ensure provided domain arguments have the correct number of elements and ordering
  • Add functionality to print domains as part of both partitioning and initialization, for debugging purposes
  • Add hooks in pybind to capture specified input domain argument and parse values for mirrored internal representation
  • Add new Input constructors with defaults to accommodate new tensor_domain argument

Fixes #1531
Addresses Prototype + MVP of #1425

Type of change

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

Checklist:

  • [ x ] My code follows the style guidelines of this project (You can use the linters)
  • [ x ] I have performed a self-review of my own code
  • [ x ] I have commented my code, particularly in hard-to-understand areas and hacks
  • [ x ] I have made corresponding changes to the documentation
  • [ x ] I have added tests to verify my fix or my feature
    • Manually tested Python API on sample scripts, including invalid input domains
  • [ x ] New and existing unit tests pass locally with my changes
  • [ x ] I have added the relevant labels to my PR in so that relevant reviewers are notified

@gs-olive gs-olive self-assigned this Dec 8, 2022
@github-actions github-actions bot added component: api [Python] Issues re: Python API component: api [C++] Issues re: C++ API component: core Issues re: The core compiler component: partitioning labels Dec 8, 2022
@github-actions github-actions bot added the component: tests Issues re: Tests label Dec 8, 2022
- Add support for specifying one, both, or neither integer bound (in
Python) on Tensor domain used for generating a sample tensor in shape analysis
- Add bounds checking to avoid int32_t overflow issues
- Add validation for inputs to ensure high bound exceeds low bound and
inputs are strictly integers
- Use [0, 2) as the default bound, which works well as a random-number
selection range in cases of Bool, Int, and Float types
- Add validation in C++ to ensure provided domain arguments have the
correct number of elements and ordering
- Add functionality to print domains as part of both partitioning and
initialization, for debugging purposes
- Add hooks in pybind to capture specified input domain argument and
parse values for mirrored internal representation
- Add new Input constructors with defaults to accommodate new `tensor_domain` argument
- Add pybind and torchbind get/set fields for C++ and Python API
compatibility
- Add C++ and Python collections test cases to ensure domain
specification is functional across APIs
@narendasan
Copy link
Collaborator

narendasan commented Dec 13, 2022

@bowang007 can you be the reviewer for this PR?

Copy link
Collaborator

@bowang007 bowang007 left a comment

Choose a reason for hiding this comment

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

LGTM

core/partitioning/shape_analysis.cpp Outdated Show resolved Hide resolved
py/torch_tensorrt/_Input.py Outdated Show resolved Hide resolved
- Update Python API to accept a full domain definition or None, without
intermediates
- Update cpp and Python APIs to include float support
- Update data structure for tensor domain object to _Float64
- Add tests to ensure tensor domain usage in shape analysis is covered
via test cases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: api [C++] Issues re: C++ API component: api [Python] Issues re: Python API component: core Issues re: The core compiler component: partitioning component: tests Issues re: Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨[Feature] Allow specification of integer range for Input class
4 participants