-
Notifications
You must be signed in to change notification settings - Fork 320
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
Adds option to specify graph entry point name #1663
Conversation
Can one of the admins verify this patch? |
1 similar comment
Can one of the admins verify this patch? |
@jenkins-droid test this please |
@kernhanda thank you for the patch! could you please look at why lit tests failed? You can check it locally by using |
Signed-off-by: Kern Handa <kern.handa@gmail.com>
Signed-off-by: Kern Handa <kern.handa@gmail.com>
Signed-off-by: Kern Handa <kern.handa@gmail.com>
9f7cbef
to
4656d9e
Compare
test/mlir/krnl/entry_point.mlir
Outdated
@@ -13,7 +11,7 @@ module { | |||
// CHECK: llvm.mlir.global external constant @_entry_point_0_in_sig("[in_sig]\00") | |||
// CHECK: llvm.mlir.global external constant @_entry_point_0_out_sig("[out_sig]\00") | |||
|
|||
// CHECK-LABEL: llvm.func @run_main_graph | |||
// CHECK-LABEL: llvm.func @run_first_entry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the default continue to be generated as run_main_graph
?
Also, we should have at least one test to validate providing a different name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the default continue to be generated as run_main_graph?
This is open for debate, IMO. I'm fine if the answer is "yes", but I'd like some clarification.
With this change, if the user provides their own graph name, thus overriding main_graph
, for an ONNX model, the entry point emitted would still be run_main_graph
, somewhat defeating the purpose. I could update the behavior such that run_main_graph
is emitted if the user didn't override the default graph name.
The other scenario is where an existing MLIR file is being compiled, where there is only one kernel entry point specified. In this case, the current behavior is to disregard the name of the entry point and always emit run_main_graph
. TBH, this doesn't make sense to me, but if there are reasons/dependencies that rely upon this behavior, I can make the change more selective.
Also, we should have at least one test to validate providing a different name.
I'll add an ONNX model graph test, then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in the source, main_graph
is still the default sometimes. There should be a test for this and if it's never the default, it should not be in the source. It sounds like we need at least 3 tests for the entry points.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the test to ensure the default scenario is tested and then a scenario where the single entry point has a non-default name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the three tests I would expect to see are:
- default "main_graph". My understanding is that if no name is specified, this is the name picked. Now both tests are specifying a name (though one of them is specifying "main_graph")
- entry point with name in the graph
- Using the command line option to specify a name other than "main_graph"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any existing tests that import a basic ONNX model? I see that the repository has a mnist.onnx
in the docs
directory, but AFAICT, there are no tests that act on an ONNX model.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have tests that import an ONNX model directly but @sorenlassen recenlty add tests that create a small ONNX model in JSON and pass it to onnx-mlir
command line. One example is: https://github.com/onnx/onnx-mlir/blob/main/test/mlir/onnx/parse/test_abs.json. Hope it helps.
Can one of the admins verify this patch? |
1 similar comment
Can one of the admins verify this patch? |
Signed-off-by: Kern Handa <kern.handa@gmail.com>
Signed-off-by: Kern Handa <kern.handa@gmail.com>
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
@jenkins-droid test this please |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
@jenkins-droid test this please |
I see a big advantage of specifying a custom entry point name: users have two (single entry) onnx models and they want to run them in the same Python/C program. In this case, entry points should be different.
I prefer this. Since we say that default graph name is
I am not so convince that onnx-mlir users will compile an MLIR file as input. It's mainly for onnx-mlir developers. So it looks fine to use the entry point as it is. |
Yes, that's exactly the motivation here.
With this change, if you import a model and don't specify the graph name, it does default to
Do you think it's necessary to make the change so that if a MLIR file has a single entry point named something other than ^ This is the only question at the moment as it's the only difference in existing functionality. Otherwise, if you don't specify the graph name option, the behavior is the same as it is without this change. |
If users specify an entry point in an MLIR via |
I agree! This PR matches that functionality then 😄 @sstamenova requested tests that exercise the model import scenario, but I couldn't find any existing tests that do this. Any guidance on how to do this or if it's necessary would be appreciated. |
std::string dynEntryPointName = "run_" + staticEntryPointFuncName.str(); | ||
if (singleEntryPoint) | ||
dynEntryPointName = DEFAULT_DYN_ENTRY_POINT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kernhanda because we don't use singleEntryPoint
anymore, could you please remove it elsewhere, e.g. in function arguments? Thanks!
@kernhanda any update on this? |
@kernhanda we would like to have this functionality, so do you have time to update this PR? If not I can take it over and create a new PR. thanks! |
Can one of the admins verify this patch? |
This changes the behavior when a single entry point is specified. Prior to this change, the entry point would be ignored if there was only a single entry point and
run_main_graph
would be emitted. After this change, the entry point name is honored, even if there's only one entry point.