Skip to content

docs: A tutorial on how to overload converters in Torch-TensorRT #3197

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

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

narendasan
Copy link
Collaborator

Description

Small tutorial on how to overload converters in Torch-TensorRT

Fixes # (issue)

Type of change

Please delete options that are not relevant and/or add your own.

  • 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 the documentation Improvements or additions to documentation label Oct 1, 2024
@narendasan narendasan force-pushed the custom_converter_tutorial branch from 8a91949 to 421e671 Compare October 1, 2024 02:29
Copy link
Collaborator

@peri044 peri044 left a comment

Choose a reason for hiding this comment

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

LGTM.

# %% GeLU Operator in PyTorch
#
# GeLU has 2 modes in PyTorch, one using the ``erf`` function and the other using the ``tanh`` approximation.
# TensorRT natively supports both implementations as am activation layer, but suppose we want to use a custom implementation of GeLU in TensorRT only for ``tanh`` mode.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: as an activation layer

Copy link
Collaborator

@zewenli98 zewenli98 left a comment

Choose a reason for hiding this comment

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

Overall LGTM, just some minor comments.

# %% GeLU Operator in PyTorch
#
# GeLU has 2 modes in PyTorch, one using the ``erf`` function and the other using the ``tanh`` approximation.
# TensorRT natively supports both implementations as am activation layer, but suppose we want to use a custom implementation of GeLU in TensorRT only for ``tanh`` mode.
Copy link
Collaborator

Choose a reason for hiding this comment

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

am -> an

#
# Finally there is the ``priority`` argument, which is an enum from the ``torch_tensorrt.dynamo.conversion.ConverterPriority`` class that defines the priority of the converter. The two options are ``HIGH`` and ``STANDARD``.
# Converters registered with ``STANDARD`` will be appended to the converter list for a given operation, while converters registered with ``HIGH`` will be prepended to the list.
# Canidate converters are evalated for their suitablity in this priority order and the first converter that passes the validator is used.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Canidate -> Candidate

@narendasan narendasan force-pushed the custom_converter_tutorial branch from 421e671 to 3ed806f Compare October 1, 2024 14:23
@narendasan narendasan merged commit cee6d24 into main Oct 1, 2024
10 of 13 checks passed
@narendasan narendasan deleted the custom_converter_tutorial branch October 1, 2024 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants