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

✨[Feature] Let users set input shape, dtype and format using example tensors #514

Closed
narendasan opened this issue Jun 28, 2021 · 3 comments · Fixed by #616
Closed

✨[Feature] Let users set input shape, dtype and format using example tensors #514

narendasan opened this issue Jun 28, 2021 · 3 comments · Fixed by #616
Assignees
Labels
feature request New feature or request
Milestone

Comments

@narendasan
Copy link
Collaborator

Is your feature request related to a problem? Please describe.

Now that we are going to be able to specify tensor properties for inputs such as data type and format, it should be easier to use a tensor I already have as an example of the shape dtype and format I want.

Describe the solution you'd like

compile should be able to accept a list of Tensors to represent my graph inputs. From those tensors compile should be able to infer shape, data type and tensor format for the user. These should be logged in the debug log for easy debugging.

Describe alternatives you've considered

Note: I dont think theres a way to support dynamic shape using this method, so users will need to use trtorch.Input for that

Additional context

@narendasan narendasan added the feature request New feature or request label Jun 28, 2021
@narendasan narendasan self-assigned this Jun 28, 2021
@narendasan narendasan added this to the v0.5.0 milestone Jun 28, 2021
@borisfom
Copy link
Collaborator

Why, if you supply 3 Tensors for min/opt/max, it's no less flexibility than we have with size arguments.

@borisfom
Copy link
Collaborator

This also correlates with #538

@narendasan
Copy link
Collaborator Author

narendasan commented Jul 16, 2021

Why, if you supply 3 Tensors for min/opt/max, it's no less flexibility than we have with size arguments.

There are some issues I see with defining min/opt/max with example tensors, at least how i pictured it. For instance:

trtorch.compile(my_mod, {"inputs": [example_in]})

From example_in we can infer shape, dtype and tensor format directly from the Tensor and create a trtorch.Input internally

In the case of dynamic shape, we need some sort of grouping for the tensor, so maybe you do something like

trtorch.compile(my_mod, {"inputs": [
    {"min": example_in_min, 
     "opt": example_in_opt, 
     "max": example_in_max}
]})

But, in this case, what do we do if something like the dtype or tensor format is inconstant between tensors?
Also doesnt seem like this is that different than doing at this point:

trtorch.compile(my_mod, {"inputs": [
    trtorch.Input(min_shape=example_in_min.shape(), 
        opt_shape=example_in_opt.shape(), 
        max_shape=example_in_max.shape(), dtype=torch.float)
]})

We could maybe have trtorch.Input pull out the shape and error out if the types are inconstant. Really though we wanted to give users a bypass around trtorch.Input with this feature.

@narendasan narendasan mentioned this issue Aug 31, 2021
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants