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: support more elementwise and unary dynamo converters #2429

Merged
merged 6 commits into from
Nov 28, 2023

Conversation

zewenli98
Copy link
Collaborator

@zewenli98 zewenli98 commented Nov 1, 2023

Description

Support more elementwise and unary dynamo converters.

For bitwise_op converters, TensorRT doesn't support bitwise ops. Thus, if inputs are int values, they will fall back to pytorch. If inputs are bool, they will be converted with the help of logical_op.

Fixes #2208 #2199

Type of change

  • New feature (non-breaking change which adds functionality)

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: api [Python] Issues re: Python API component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: tests Issues re: Tests labels Nov 1, 2023
@github-actions github-actions bot requested a review from apbose November 1, 2023 22:58
@zewenli98 zewenli98 changed the title More elementwise dynamo converters feat: support more elementwise and unary dynamo converters Nov 1, 2023
@zewenli98 zewenli98 requested a review from gs-olive November 9, 2023 01:45
Copy link
Collaborator

@gs-olive gs-olive left a comment

Choose a reason for hiding this comment

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

Overall looks good - had a few questions and suggestions as mentioned in the comments

@zewenli98 zewenli98 force-pushed the more_elementwise_dynamo_converters branch from 5c88118 to 1b077ca Compare November 9, 2023 23:35
@zewenli98 zewenli98 requested review from apbose and gs-olive November 14, 2023 20:43
Copy link
Collaborator

@gs-olive gs-olive left a comment

Choose a reason for hiding this comment

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

Looks good to me overall! One question - should convert_binary_elementwise also be allowed to handle bool types?

Also - a rebase may be needed to avoid the CircleCI errors.

@zewenli98 zewenli98 force-pushed the more_elementwise_dynamo_converters branch from a210762 to 1645b5e Compare November 16, 2023 01:38
@zewenli98
Copy link
Collaborator Author

Looks good to me overall! One question - should convert_binary_elementwise also be allowed to handle bool types?

Yes, I agree with you. Fixed! Thanks for the comments.

@zewenli98 zewenli98 requested a review from gs-olive November 16, 2023 01:40
Copy link
Collaborator

@gs-olive gs-olive left a comment

Choose a reason for hiding this comment

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

Just a minor comment, bool should likely be added here, to lines 123 + 127 since this PR adds support for bool in convert_binary_elementwise:

if is_lhs_trt_tensor and isinstance(rhs_val, (float, int)):
rhs_val = np.array(
[rhs_val], dtype=unified_dtype_converter(lhs_dtype, Frameworks.NUMPY)
)
if is_rhs_trt_tensor and isinstance(lhs_val, (float, int)):
lhs_val = np.array(
[lhs_val], dtype=unified_dtype_converter(rhs_dtype, Frameworks.NUMPY)
)

Otherwise, seems good to go!

@zewenli98 zewenli98 requested a review from gs-olive November 17, 2023 21:52
@zewenli98 zewenli98 merged commit 53401dd into pytorch:main Nov 28, 2023
15 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: api [Python] Issues re: Python API component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: tests Issues re: Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose IElementWiseLayer in dynamo.conversion.impl
4 participants