-
Notifications
You must be signed in to change notification settings - Fork 365
[feat] add support for aten::reciprocal(int) #1308
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 support for aten::reciprocal(int) #1308
Conversation
auto reciprocal_registration TORCHTRT_UNUSED = RegisterNodeConversionPatterns().pattern( | ||
{"aten::reciprocal(Tensor self) -> Tensor", [](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool { | ||
auto in = args[0].ITensorOrFreeze(ctx); | ||
if (in->getType() == nvinfer1::DataType::kINT32) { |
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.
This might be a large change but would it make sense to just add this to the macro for other unary ops? @peri044 thoughts on what the repercussions would be?
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.
In this case the behavior matches pytorch. For other ops (ex. abs implemented element-wise above) this behavior would be incorrect. I have not checked any of the other ops.
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.
There are two ops which have some restrictions according to the doc but other unary ops must have floating point inputs. https://docs.nvidia.com/deeplearning/tensorrt/api/c_api/classnvinfer1_1_1_i_network_definition.html#a77831224c9a72ad02587a56ded93c672
Generally the input must have a floating-point type (or kINT8 as a quantized float), except for the following operations:
kSIGN accepts a floating-point or Int32 tensor.
kNOT requires a Bool tensor.
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.
We could add the above restrictions in the code in addition to what Michael added, to cover the cases in the doc completely.
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.
I was mostly talking from the pytorch perspective since seems like theres at least a few ops where int inputs are valid
* chore: additional options for perf_run tool Signed-off-by: dperi <[email protected]> * feat: Add fx2trt backend and revamp current perf utility to accept CLI arguments Signed-off-by: Dheeraj Peri <[email protected]> * chore: Refactor fx2trt functionality Signed-off-by: Dheeraj Peri <[email protected]> * chore: Fix fp16 functionality for fx2trt backend Signed-off-by: Dheeraj Peri <[email protected]> * chore: refactor Signed-off-by: Dheeraj Peri <[email protected]> * chore: minor change Signed-off-by: Dheeraj Peri <[email protected]> * refactor: Refactor perf_run and add internal benchmark scripts Signed-off-by: Dheeraj Peri <[email protected]> * chore : minor refactor Signed-off-by: Dheeraj Peri <[email protected]> * chore: Apply precommit tooling Signed-off-by: Dheeraj Peri <[email protected]> * chore: Fix data loader issues and nox file paths Signed-off-by: Dheeraj Peri <[email protected]> * chore: rebase and minor changes Signed-off-by: Dheeraj Peri <[email protected]> * chore: Fix reporting to a file setting Signed-off-by: Dheeraj Peri <[email protected]> * Update lower.py (#1324) * docs: [Automated] Regenerating documenation for e374eb1 Signed-off-by: Torch-TensorRT Github Bot <[email protected]> * refactor: Refactor testing to use cosine similarity, remove redundancy models and restructuring Signed-off-by: Dheeraj Peri <[email protected]> * chore: move to cosine similarity comparison Signed-off-by: Dheeraj Peri <[email protected]> * refactor: Refactor nox file testing Signed-off-by: Dheeraj Peri <[email protected]> * chore: add missing scripts Signed-off-by: Dheeraj Peri <[email protected]> * chore: Linter fixes Signed-off-by: Dheeraj Peri <[email protected]> * fix!: Fixed Windows compilation failures Signed-off-by: Anurag Dixit <[email protected]> * chore: Minor fix Signed-off-by: Dheeraj Peri <[email protected]> * chore: use rn18 instead of rn50 Signed-off-by: Dheeraj Peri <[email protected]> * docs: [Automated] Regenerating documenation for a1a4786 Signed-off-by: Torch-TensorRT Github Bot <[email protected]> * chore: Add cpp tests with cosine sim Signed-off-by: Dheeraj Peri <[email protected]> * chore: linter fixes Signed-off-by: Dheeraj Peri <[email protected]> * [feat] Add support for argmax and argmin (#1312) * [feat] Add support for argmax and argmin Adds support for aten::argmax and aten::argmin. Fixes # (issue) Please delete options that are not relevant and/or add your own. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - This change requires a documentation update - [ ] 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 - [ ] I have added the relevant labels to my PR in so that relevant reviewers are notified * move max.cpp tests to test_max.cpp no functional change * fix permissions on max.cpp * docs: [Automated] Regenerating documenation for 9db2852 Signed-off-by: Torch-TensorRT Github Bot <[email protected]> * chore: Deepcopy other objects Signed-off-by: Dheeraj Peri <[email protected]> * fix: Fix deepcopy issues of PTQ calibrators Signed-off-by: Dheeraj Peri <[email protected]> * chore: linter fixes Signed-off-by: Dheeraj Peri <[email protected]> * chore: Adding a guideline to build on Windows platform (#1337) * chore: Adding Windows build guideline Signed-off-by: Anurag Dixit <[email protected]> * chore: Fix formatting Signed-off-by: Anurag Dixit <[email protected]> Signed-off-by: Anurag Dixit <[email protected]> * docs: [Automated] Regenerating documenation for 00a1f03 Signed-off-by: Torch-TensorRT Github Bot <[email protected]> * chore: minor fixes Signed-off-by: Dheeraj Peri <[email protected]> * chore: Linter fixes Signed-off-by: Dheeraj Peri <[email protected]> * chore: Linter fixes Signed-off-by: Dheeraj Peri <[email protected]> * docs: [Automated] Regenerating documenation for 1efe4b1 Signed-off-by: Torch-TensorRT Github Bot <[email protected]> * docs: [Automated] Regenerating documenation for 10b9ecd Signed-off-by: Torch-TensorRT Github Bot <[email protected]> * add support for aten::reciprocal(int) (#1308) * docs: [Automated] Regenerating documenation for 096fd41 Signed-off-by: Torch-TensorRT Github Bot <[email protected]> Signed-off-by: dperi <[email protected]> Signed-off-by: Dheeraj Peri <[email protected]> Signed-off-by: Torch-TensorRT Github Bot <[email protected]> Signed-off-by: Anurag Dixit <[email protected]> Co-authored-by: dperi <[email protected]> Co-authored-by: Dheeraj Peri <[email protected]> Co-authored-by: Wei <[email protected]> Co-authored-by: Torch-TensorRT Github Bot <[email protected]> Co-authored-by: Anurag Dixit <[email protected]> Co-authored-by: Michael Feliz <[email protected]>
Description
The unary layer does not support integer inputs to RECIP. Pytorch implicitly casts integer inputs to float for aten::reciprocal so we can add the same cast here to add support.
Fixes # (issue)
Type of change
Please delete options that are not relevant and/or add your own.
Checklist: