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 support for aten::reciprocal(int) #1308

Merged

Conversation

mfeliz-cruise
Copy link
Contributor

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.

  • 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

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
  • I have added the relevant labels to my PR in so that relevant reviewers are notified

@github-actions github-actions bot added component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: core Issues re: The core compiler component: tests Issues re: Tests labels Aug 25, 2022
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) {
Copy link
Collaborator

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?

Copy link
Contributor Author

@mfeliz-cruise mfeliz-cruise Aug 25, 2022

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.

Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Collaborator

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

@narendasan narendasan merged commit 096fd41 into pytorch:master Sep 8, 2022
narendasan added a commit that referenced this pull request Sep 9, 2022
* chore: additional options for perf_run tool

Signed-off-by: dperi <dperi@nvidia.com>

* feat: Add fx2trt backend and revamp current perf utility to accept CLI arguments

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* chore: Refactor fx2trt functionality

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* chore: Fix fp16 functionality for fx2trt backend

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* chore: refactor

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* chore: minor change

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* refactor: Refactor perf_run and add internal benchmark scripts

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* chore : minor refactor

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* chore: Apply precommit tooling

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* chore: Fix data loader issues and nox file paths

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* chore: rebase and minor changes

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* chore: Fix reporting to a file setting

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* Update lower.py (#1324)

* docs: [Automated] Regenerating documenation for e374eb1

Signed-off-by: Torch-TensorRT Github Bot <torch-tensorrt.github.bot@nvidia.com>

* refactor: Refactor testing to use cosine similarity, remove redundancy models and restructuring

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* chore: move to cosine similarity comparison

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* refactor: Refactor nox file testing

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* chore: add missing scripts

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* chore: Linter fixes

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* fix!: Fixed Windows compilation failures

Signed-off-by: Anurag Dixit <a.dixit91@gmail.com>

* chore: Minor fix

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* chore: use rn18 instead of rn50

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* docs: [Automated] Regenerating documenation for a1a4786

Signed-off-by: Torch-TensorRT Github Bot <torch-tensorrt.github.bot@nvidia.com>

* chore: Add cpp tests with cosine sim

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* chore: linter fixes

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* [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 <torch-tensorrt.github.bot@nvidia.com>

* chore: Deepcopy other objects

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* fix: Fix deepcopy issues of PTQ calibrators

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* chore: linter fixes

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* chore: Adding a guideline to build on Windows platform (#1337)

* chore: Adding Windows build guideline

Signed-off-by: Anurag Dixit <a.dixit91@gmail.com>

* chore: Fix formatting

Signed-off-by: Anurag Dixit <a.dixit91@gmail.com>

Signed-off-by: Anurag Dixit <a.dixit91@gmail.com>

* docs: [Automated] Regenerating documenation for 00a1f03

Signed-off-by: Torch-TensorRT Github Bot <torch-tensorrt.github.bot@nvidia.com>

* chore: minor fixes

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* chore: Linter fixes

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* chore: Linter fixes

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>

* docs: [Automated] Regenerating documenation for 1efe4b1

Signed-off-by: Torch-TensorRT Github Bot <torch-tensorrt.github.bot@nvidia.com>

* docs: [Automated] Regenerating documenation for 10b9ecd

Signed-off-by: Torch-TensorRT Github Bot <torch-tensorrt.github.bot@nvidia.com>

* add support for aten::reciprocal(int) (#1308)

* docs: [Automated] Regenerating documenation for 096fd41

Signed-off-by: Torch-TensorRT Github Bot <torch-tensorrt.github.bot@nvidia.com>

Signed-off-by: dperi <dperi@nvidia.com>
Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>
Signed-off-by: Torch-TensorRT Github Bot <torch-tensorrt.github.bot@nvidia.com>
Signed-off-by: Anurag Dixit <a.dixit91@gmail.com>
Co-authored-by: dperi <dperi@nvidia.com>
Co-authored-by: Dheeraj Peri <peri.dheeraj@gmail.com>
Co-authored-by: Wei <wwei6@fb.com>
Co-authored-by: Torch-TensorRT Github Bot <torch-tensorrt.github.bot@nvidia.com>
Co-authored-by: Anurag Dixit <a.dixit91@gmail.com>
Co-authored-by: Michael Feliz <104801882+mfeliz-cruise@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: core Issues re: The core compiler component: tests Issues re: Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants