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

fx2trt converters aten::slice,aten::select and aten::matmul #1770

Merged
merged 34 commits into from
Apr 21, 2023

Conversation

apbose
Copy link
Collaborator

@apbose apbose commented Mar 24, 2023

Description

Fixes #1709
Fixed #1714

Copy link

@github-actions github-actions bot left a 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

Copy link

@github-actions github-actions bot left a 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

@apbose apbose changed the title Bose fx2trt converters slice select fx2trt converters aten::slice,aten::select and aten::matmul Mar 24, 2023
@apbose apbose requested a review from gs-olive March 24, 2023 23:59
@apbose apbose added the WIP Work is in progress, pull request should not be merged yet label Mar 25, 2023
Copy link

@github-actions github-actions bot left a 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

Copy link

@github-actions github-actions bot left a 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

@github-actions github-actions bot requested a review from frank-wei March 25, 2023 00:00
@frank-wei frank-wei requested a review from wushirong March 25, 2023 05:58
Copy link

@github-actions github-actions bot left a 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

Copy link

@github-actions github-actions bot left a 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

Copy link
Contributor

@frank-wei frank-wei left a comment

Choose a reason for hiding this comment

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

It is nice to see many activation operators of aten IR are added. But could you minimize the changes on fx2trt side like changes of common_activation ?



def common_activation(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there reason we want to drop this common_activation func and split it into many single functions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi Wei, the common_activation function is not split, instead it is included in the add_activation function in activation.py. The idea is that the activation and the operator functions are split in two (activation.py and operator.py respectively) and the converter_utils.py is for the common functions across the two and other operations.

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 overall, with lots of critical operators and tests. Just made a few comments on in-place modification of layer objects and matmul test coverage.

Comment on lines 546 to 548
output = layer.get_output(0)
output.name = output.name + "_" + target.__name__
return layer.get_output(0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does layer.get_output(0) make a copy of the underlying object? If so, line 547 may have no effect, since it only modifies the output object. Should this be return output instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So the layer.get_output(0) does not make an explicit copy and modifying the output.name causes inplace modification of the layer.get_output(0).name too. Yes it could have been return output too I assume, but any change would be inconsequential.

layer = network.add_matrix_multiply(
input_val, input_matrix_op, other_val, other_matrix_op
)
set_layer_name(layer, target, name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some layer name changes use this function and others directly modify layer.get_output(0).name. Consider standardizing the usage across functions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That makes sense. Just that in the case of set_layer_name the name is changed directly for the layer, while appending acc_ops.target.__name__ to the layer name with the name passed in the above function. Whereas in case of the other we change the name of layer.get_output(0) with only the target.__name__. @frank-wei any thoughts on this to integrate the two?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider adding additional tests for this function since it is used so often. For example, adding multi-dimensional tensors and single-dimensional vector matrix multiplications as well.

gs-olive and others added 5 commits March 28, 2023 20:47
- Add backend adapted from previous `fx2trt_compiler` provided by
Dynamo
- Currently, the TRTSplitter needs work to fully support the `aten` path
- Additionally, the existing `aten` pass was reworked to exclude the
`torch._dynamo.export` call, which may be necessary here
Copy link

@github-actions github-actions bot left a 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

Copy link

@github-actions github-actions bot left a 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

@apbose
Copy link
Collaborator Author

apbose commented Apr 19, 2023

Hi @wushirong, thanks for the review.

  1. Yes, the changes are too big for a single review, hence could you please review - fx2trt converters - change of prototype and addition of activation operation #1745. I will then subsequently put the additional converter changes present in the current review after those changes are reviewed/merged in, so that the changes are done in small increments.
  2. Regarding the second point, yes the purpose of PR fx2trt converters - change of prototype and addition of activation operation #1745, is to make the flow generic for acc and aten operations (Right now the implementation is in acc_ops_converters.py). For that reason the implementation of the converters have been moved from acc_ops_converters.py to a generic interface, activation.py for activation operations and operator.py for operations. acc_ops_converters.py and aten_ops_converters.py call the functions from these two files.
    The changes for reorganization of files-
  3. activation.py - functions for activation operations
  4. operator.py - functions for converter operations
  5. converter_utils.py - common functions for both
    eg: since common_activation is required just for activation operations, this is moved to actovation.py from converter_utils.py

Copy link

@github-actions github-actions bot left a 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

Copy link

@github-actions github-actions bot left a 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

@narendasan narendasan changed the base branch from main to bose_fx2trt_converters April 19, 2023 18:43
Copy link

@github-actions github-actions bot left a 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

Copy link

@github-actions github-actions bot left a 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

@apbose apbose removed the WIP Work is in progress, pull request should not be merged yet label Apr 21, 2023
…mer_encoder

fx2trt converters transformer encoder
@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 Apr 21, 2023
Copy link

@github-actions github-actions bot left a 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

Copy link

@github-actions github-actions bot left a 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

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: core Issues re: The core compiler component: fx component: tests Issues re: Tests fx
Projects
None yet
6 participants