-
Notifications
You must be signed in to change notification settings - Fork 372
support Long/Double type IValue #322
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
Conversation
Signed-off-by: inocsin <[email protected]>
|
@inocsin I dont really understand the point of this change? Seems like its casting the input Tensor based on the already existing type of the Tensor and nothing else really changes. |
There was a problem hiding this 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
There was a problem hiding this 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
Some values in torchscript are stored as at::kLong and at::kDouble, but the tensorRT doesn't support those two type. So in conversion time, it will throw an error. That's why we must convert at::Double and at::kLong to trt support datatype to pass the conversion. |
|
Isnt this potentially dangerous? We would be truncating values in double precision to single precision and in this case it would be done silently |
Yeah, maybe we can throw a warning? But if we doesn't support the type conversion, the module cann't be compiled by trt |
|
Are tensors from PyTorch in your target module actually double precision? I think its better in that case that we catch this and fully error out telling users to put in a type cast to floating point so they make the choice explicitly. |
Yeah, the original values are double precision. In my situation, some users may not want to convert precision explicitly, so that's why I think we should do this for them. |
|
We can add a setting to the CompileSpec {
...
bool truncate_long_and_double = False;
}So while by default you will error out, if you explicitly opt in, weights will be truncated for you. Then we can tell if say an accuracy issue may be the result of truncating or some other issue. |
|
I can PR into your branch the API to do this and the checks if you think this would be sufficient |
|
@peri044 says we should also put a warning in so even if someone opts in you get a message if it actually truncates. |
Description
Type of change
Please delete options that are not relevant and/or add your own.
Checklist: