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

Document supported ops #1475

Merged
merged 23 commits into from
Jun 13, 2022

Conversation

AlexandreEichenberger
Copy link
Collaborator

@AlexandreEichenberger AlexandreEichenberger commented May 31, 2022

Add format to testing file to register our current support. Example of format:

################################################################################
# SEMANTIC for LABELING (one line per directive)
#
# ==ARCH== <arch>
#   where <arch> is cpu/NNPA/... this option is valid until reset by another ARCH dir
#
# ==OP== <op> <text>
#   where <op> is the ONNX op name
#   where <text> qualifies the opset currently being supported. When "current" is 
#   provided, the postprocessing will automatically changed highest opset currently
#   supported. When no <text> is provided, the operation is assumed to be fully 
#   unsupported.
#
# ==LIM== <text> 
#   where <text> qualifies the current restrictions to the implementation.
#
# ==TODO== <text>
#   where <text> add "private" info about what needs to be fixed. 
#

Where this info will be scanned, parsed, and generate a md file listing our current support

@AlexandreEichenberger AlexandreEichenberger marked this pull request as draft May 31, 2022 23:51
@AlexandreEichenberger AlexandreEichenberger linked an issue Jun 2, 2022 that may be closed by this pull request
Signed-off-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Alexandre Eichenberger <[email protected]>
@AlexandreEichenberger AlexandreEichenberger marked this pull request as ready for review June 8, 2022 13:09
@AlexandreEichenberger
Copy link
Collaborator Author

@chentong319 now using the version info from gen_onnx_mlir

@AlexandreEichenberger
Copy link
Collaborator Author

@cjvolzka Please check if the output generated is ok by you. You can visualize this md file. docs/SupportedONNXOps-cpu.md

@chentong319
Copy link
Collaborator

chentong319 commented Jun 9, 2022

At the beginning of this project, only a small portion of backend tests are supported. Therefore, we created a dictionary for enabled tests. Now it is the time to assume the default status of a test is enabled for static, dynamic and constant with every dimension ({-1:{-1}}). Then we can have a dictionary for test cases that can not enabled with the default value. An entry in the dictionary (for one test case) is also a dictionary with following possible entries:

  • Key "Disabled": string, why this test is disabled
  • Key " DYNAMIC_SHAPE" : the dimension string
  • Key "CONSTANT_SHAPE" : then dimension string

Benefits:

  1. Compare the all_test_names (line 68 test.py) and this dictionary, we can get which op is supported and which is not
  2. Easier to enable new test case without going into third_part/onnx to figure out the test names
  3. Reduce the redundancy in dimension info: most of them are the default value
  4. The reason becomes part of the python code, not just comments.

Should we open a new PR after this PR is closed or merged?

@AlexandreEichenberger
Copy link
Collaborator Author

Should we open a new PR after this PR is closed or merged?

The development team has expressed interest in having the list of supported ops on the GitHub pages, so I think we should merge it in, then you can change the testing logic as you see fit and I will find a way to recreate the info, using either the same or slightly different annotations.

@chentong319
Copy link
Collaborator

Should we open a new PR after this PR is closed or merged?

The development team has expressed interest in having the list of supported ops on the GitHub pages, so I think we should merge it in, then you can change the testing logic as you see fit and I will find a way to recreate the info, using either the same or slightly different annotations.

Sure. I will review this PR.

Copy link
Collaborator

@chentong319 chentong319 left a comment

Choose a reason for hiding this comment

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

Should we in general put the update of the component of third_part in an independent PR?

#
################################################################################
#
# This file convert .mlir from stdin into a FileCheck file format. It also
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update the header comment, which seems to be copied from mlir2FileCheck.py

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch, sorry.

if arch != target_arch:
continue
# Scan op (op followed by any text).
p = re.search(r'==OP==\s+(\w+)', l)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The op-set for an Op in ONNX dialect is determined by gen_mlir_onnx.py. If that op-set is not the version specified in the version of onnx we are using, the backend test always goes with the onnx. It is a little confusion to say which op-set we are supporting. Anyway, we should not need to specify op-set in the backend test. Let's fix it in future PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As a matter of fact, I removed the text after the ==OP== as you rightly suggested to use the gen_onnx_mlir.py info on the opsets.

.format(schema.name)+
" has a newer version {} over old version {}"
.format(schema.since_version, version_dict[schema.name][0]))
if not list_only:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did I miss some code? I did not see the extra work when list_only is true. I just wonder that you print out all the versions of an Op or just the top version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I should have given more input. The current gen_onnx_mlir.py --check-operation-version gives additional output, which is disabled when list_only is on. The reason I needed no additional output is that in the documentOps, I run a subprocess that run gen_onnx_mlir.py --check-operation-version which print a dictionary, which I then evaluate in the current python script to gather the proper info. I could not simply include that script as both scripts needs to parse distinct input arguments from the command line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After discussions with @chentong319 , we are now using directly the gen_onnx_mlir version_dict directly. He also requested that we only report the largest opset (and not the list of opsets). All these changes have now been implemented.

@cjvolzka
Copy link
Collaborator

@cjvolzka Please check if the output generated is ok by you. You can visualize this md file. docs/SupportedONNXOps-cpu.md

Overall looks good. I think it'll be useful info to have but also for debugging. For example if a model doesn't work, it should be easy to reference what Ops are supported and then tell if you have an unsupported op.

I do have a couple of small comments/questions related to the column headers:

  1. Opset: Does this need a little more clarity?
    • For example on "Add" it only shows Opset 14. Does that mean we don't support it for other Opsets or we just only tested it on 14? It's a little ambiguous to me because some Ops (like "Clip") we explicitly list specific Opsets but most others we only list one. However then on "Loop" we only show 16 but then explicitly call out Opsets that aren't supported.
  2. Todo: Should be renamed to something like Notes

@chentong319
Copy link
Collaborator

@cjvolzka Please check if the output generated is ok by you. You can visualize this md file. docs/SupportedONNXOps-cpu.md

Overall looks good. I think it'll be useful info to have but also for debugging. For example if a model doesn't work, it should be easy to reference what Ops are supported and then tell if you have an unsupported op.

I do have a couple of small comments/questions related to the column headers:

  1. Opset: Does this need a little more clarity?

    • For example on "Add" it only shows Opset 14. Does that mean we don't support it for other Opsets or we just only tested it on 14? It's a little ambiguous to me because some Ops (like "Clip") we explicitly list specific Opsets but most others we only list one. However then on "Loop" we only show 16 but then explicitly call out Opsets that aren't supported.
  2. Todo: Should be renamed to something like Notes

Good suggestion. We will let our model importer read this table and generate error message when there is an unsupported Op in the model.

@AlexandreEichenberger
Copy link
Collaborator Author

AlexandreEichenberger commented Jun 10, 2022

@chentong319

Something I don't understand with the gen_onnx_mlir script. If you look at loop op, its listed as 13 but when you run the script it list it at 16.

python ../utils/gen_onnx_mlir.py --check-operation-version | grep Loop
Check-operation-version: Operation Loop has a newer version 16 over old version 13
 'Loop': [16],

Can you show me how to preserve the '13' for this PR?

UPDATE: now implemented, all good.

@AlexandreEichenberger
Copy link
Collaborator Author

@cjvolzka Thanks for looking into the output.

Opset: Does this need a little more clarity?

Its the same as in the standard: it list the LAST opset that "improved" the given operation. So Add is in 16, but it was last modified in 14, so it list 14.

I will give it an explanation.

For loop, we support the "syntax" of 13, but only when the syntax satisfies some constraints, namely that of 9.

Signed-off-by: Alexandre Eichenberger <[email protected]>
@chentong319
Copy link
Collaborator

There is a version number for onnx. For example, we are using onnx.1.11.0. In one onnx version, ops may have different opset number, depending on whether the Op is modified or not. Sometimes the highest opset number in a version is used to denote that onnx version.
In onnx-mlir compiler, we should have a table for the opset number of each Op we support, and the current opset number of each Op in the version of onnx we are using. Currently we have the opset number only in gen_onnx_mlir.py, not in the compiler. Warning and conversion in our Builder should be based on the two tables, not just one opset number.
Not sure whether we want to fix this issue in this PR or not. @AlexandreEichenberger , it's your call.

Copy link
Collaborator

@chentong319 chentong319 left a comment

Choose a reason for hiding this comment

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

LGTM!

@AlexandreEichenberger
Copy link
Collaborator Author

In onnx-mlir compiler, we should have a table for the opset number of each Op we support, and the current opset number of each Op in the version of onnx we are using. Currently we have the opset number only in gen_onnx_mlir.py, not in the compiler. Warning and conversion in our Builder should be based on the two tables, not just one opset number.

For the sake of expediency, this PR implement the right thing for the doc. Will tabulate larger changes for supporting opset to a later PR.

Copy link
Collaborator

@chentong319 chentong319 left a comment

Choose a reason for hiding this comment

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

LGTM!

@chentong319 chentong319 self-requested a review June 13, 2022 14:07
Copy link
Collaborator

@chentong319 chentong319 left a comment

Choose a reason for hiding this comment

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

Another try to approve

@chentong319
Copy link
Collaborator

Whenever I submitted an approval, the approval was turned into a comment. Something wrong with my git account. I could not merge my own approved PR, either.

Copy link
Collaborator

@chentong319 chentong319 left a comment

Choose a reason for hiding this comment

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

Again!

@chentong319 chentong319 merged commit c192123 into onnx:main Jun 13, 2022
@jenkins-droid
Copy link
Collaborator

Jenkins Linux s390x Build #6355 [push] Document supported ops (... started at 10:44

@jenkins-droid
Copy link
Collaborator

Jenkins Linux ppc64le Build #5477 [push] Document supported ops (... started at 10:46

@jenkins-droid
Copy link
Collaborator

Jenkins Linux amd64 Build #6339 [push] Document supported ops (... started at 09:44

@jenkins-droid
Copy link
Collaborator

Jenkins Linux amd64 Build #6339 [push] Document supported ops (... passed after 1 hr 8 min

@jenkins-droid
Copy link
Collaborator

Jenkins Linux s390x Build #6355 [push] Document supported ops (... passed after 1 hr 19 min

@jenkins-droid
Copy link
Collaborator

Jenkins Linux ppc64le Build #5477 [push] Document supported ops (... passed after 1 hr 41 min

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supported opset doc?
4 participants