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

[TVMC] add the support of the cross compiler options #7922

Merged
merged 1 commit into from
May 21, 2021

Conversation

vinceab
Copy link
Contributor

@vinceab vinceab commented Apr 26, 2021

Add the possibility to provide the cross compiler options when using the
tvmc compile functionality.
With some cross compiler toolchains --sysroot option (at least) need to be defined.

@leandron

Copy link
Contributor

@leandron leandron left a comment

Choose a reason for hiding this comment

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

The change looks OK to me. Apart from my comments below, is there a chance to add a test case for this PR?

@@ -271,7 +277,7 @@ def save_module(module_path, graph, lib, params, cross=None):
The parameters (weights) for the TVM module.
cross : str or callable object, optional
Function that performs the actual compilation

cross_options : sst of cross compilation options
Copy link
Contributor

Choose a reason for hiding this comment

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

Modifying it to comply with Numpy docstring format.

Suggested change
cross_options : sst of cross compilation options
cross_options : str, optional
Command line options to be passed to the cross compiler.

@@ -283,7 +289,7 @@ def save_module(module_path, graph, lib, params, cross=None):
lib.export_library(path_lib)
else:
logger.debug("exporting library to %s , using cross compiler %s", path_lib, cross)
lib.export_library(path_lib, cc.cross_compiler(cross))
lib.export_library(path_lib, cc.cross_compiler(cross, options=cross_options.split(' ')))
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it makes sense to add the command line options to the debug message on the line above?

Comment on lines 261 to 262
def save_module(module_path, graph, lib, params, cross=None,
cross_options=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def save_module(module_path, graph, lib, params, cross=None,
cross_options=None):
def save_module(module_path, graph, lib, params, cross=None, cross_options=None):

@vinceab
Copy link
Contributor Author

vinceab commented Apr 26, 2021

The change looks OK to me. Apart from my comments below, is there a chance to add a test case for this PR?

I will do the update of the patch.
Regarding the test of this PR, I have tested it with the STM32MP157 board. In which location I can add a test case?

Vincent

@leandron
Copy link
Contributor

The change looks OK to me. Apart from my comments below, is there a chance to add a test case for this PR?

I will do the update of the patch.
Regarding the test of this PR, I have tested it with the STM32MP157 board. In which location I can add a test case?

Vincent

I was referring to unit tests, just to try validate the API changes. The unit tests are currently hosted at - https://github.com/apache/tvm/tree/main/tests/python/driver/tvmc

@vinceab
Copy link
Contributor Author

vinceab commented May 5, 2021

The change looks OK to me. Apart from my comments below, is there a chance to add a test case for this PR?

I will do the update of the patch.
Regarding the test of this PR, I have tested it with the STM32MP157 board. In which location I can add a test case?
Vincent

I was referring to unit tests, just to try validate the API changes. The unit tests are currently hosted at - https://github.com/apache/tvm/tree/main/tests/python/driver/tvmc

@leandron how do you execute the tests?
On tvm main branch, I tries test_cross_compile_aarch64_tflite_module function and it fails with this error:
assert llvm_id != 0, "%s is not an LLVM intrinsic" % name
AssertionError: llvm.aarch64.neon.umull is not an LLVM intrinsic

@leandron
Copy link
Contributor

The change looks OK to me. Apart from my comments below, is there a chance to add a test case for this PR?

I will do the update of the patch.
Regarding the test of this PR, I have tested it with the STM32MP157 board. In which location I can add a test case?
Vincent

I was referring to unit tests, just to try validate the API changes. The unit tests are currently hosted at - https://github.com/apache/tvm/tree/main/tests/python/driver/tvmc

@leandron how do you execute the tests?
On tvm main branch, I tries test_cross_compile_aarch64_tflite_module function and it fails with this error:
assert llvm_id != 0, "%s is not an LLVM intrinsic" % name
AssertionError: llvm.aarch64.neon.umull is not an LLVM intrinsic

Hi, sorry for the delay. I don't think this error is related to tvmc specifically. It probably has something to do with the way your TVM was built. Which LLVM version are you linking TVM with?

@vinceab
Copy link
Contributor Author

vinceab commented May 12, 2021

@leandron the LLVM version I use is the v6.0.0.

@leandron
Copy link
Contributor

@leandron the LLVM version I use is the v6.0.0.

I see. I appreciate the docs mention "LLVM 4.0 or higher is needed for build with LLVM. Note that version of LLVM from default apt may lower than 4.0.", but I don't think we test with anything < LLVM 9. Probably something to investigate in a separate issue.

Is that possible at all for your to try with some newer LLVM, like LLVM 11, which is the one we use in most of the CI jobs here?

@vinceab
Copy link
Contributor Author

vinceab commented May 12, 2021

@leandron the LLVM version I use is the v6.0.0.

I see. I appreciate the docs mention "LLVM 4.0 or higher is needed for build with LLVM. Note that version of LLVM from default apt may lower than 4.0.", but I don't think we test with anything < LLVM 9. Probably something to investigate in a separate issue.

Is that possible at all for your to try with some newer LLVM, like LLVM 11, which is the one we use in most of the CI jobs here?

I just tested with LLVM v10 and it seems to work.
Base on this I will propose an extension of the tests to include cross compiler options

@vinceab vinceab force-pushed the tvmc_cross_compiler_options branch from 9e6dcf3 to a06f7bf Compare May 19, 2021 10:35
@vinceab
Copy link
Contributor Author

vinceab commented May 19, 2021

@leandron

I have rebase the patch on the main branch and add tests.

@leandron
Copy link
Contributor

@leandron

I have rebase the patch on the main branch and add tests.

I think the linter is complaining about formatting on your patch (the log is here). You can check some command lines to run the exact same linter locally on your machine here: https://tvm.apache.org/docs/contribute/pull_request.html#submit-a-pull-request

Copy link
Contributor

@leandron leandron left a comment

Choose a reason for hiding this comment

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

LGTM, pending on formatting/linter fixes.

Add the possibility to provide the cross compiler options when using the
tvmc compile functionality.
With some cross compiler, toolchains --sysroot option (at least) need to be
defined.

tvmc/test_compile.py as been updated to introduce simple tests to validate
the cross options functionnality.

Signed-off-by: Vincent ABRIOU <[email protected]>
@vinceab vinceab force-pushed the tvmc_cross_compiler_options branch from a06f7bf to 189f9bb Compare May 20, 2021 14:22
@vinceab
Copy link
Contributor Author

vinceab commented May 20, 2021

@leandron formatting/linter fixed

@leandron leandron self-assigned this May 21, 2021
Copy link
Contributor

@leandron leandron left a comment

Choose a reason for hiding this comment

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

LGTM

@leandron leandron merged commit 5a7c081 into apache:main May 21, 2021
@leandron
Copy link
Contributor

Thanks @vinceab!

trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Jun 17, 2021
Add the possibility to provide the cross compiler options when using the
tvmc compile functionality.
With some cross compiler, toolchains --sysroot option (at least) need to be
defined.

tvmc/test_compile.py as been updated to introduce simple tests to validate
the cross options functionnality.

Signed-off-by: Vincent ABRIOU <[email protected]>
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Jun 17, 2021
Add the possibility to provide the cross compiler options when using the
tvmc compile functionality.
With some cross compiler, toolchains --sysroot option (at least) need to be
defined.

tvmc/test_compile.py as been updated to introduce simple tests to validate
the cross options functionnality.

Signed-off-by: Vincent ABRIOU <[email protected]>
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.

2 participants