Skip to content

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

Merged
leandron merged 1 commit into
apache:mainfrom
vinceab:tvmc_cross_compiler_options
May 21, 2021
Merged

[TVMC] add the support of the cross compiler options#7922
leandron merged 1 commit into
apache:mainfrom
vinceab:tvmc_cross_compiler_options

Conversation

@vinceab

@vinceab vinceab commented Apr 26, 2021

Copy link
Copy Markdown
Contributor

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

@leandron leandron left a comment

Copy link
Copy Markdown
Contributor

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?

Comment thread python/tvm/driver/tvmc/compiler.py Outdated
cross : str or callable object, optional
Function that performs the actual compilation

cross_options : sst of cross compilation options

Copy link
Copy Markdown
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.

Comment thread python/tvm/driver/tvmc/compiler.py Outdated
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
Copy Markdown
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 thread python/tvm/driver/tvmc/compiler.py Outdated
Comment on lines +261 to +262
def save_module(module_path, graph, lib, params, cross=None,
cross_options=None):

Copy link
Copy Markdown
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

vinceab commented Apr 26, 2021

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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

vinceab commented May 5, 2021

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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

vinceab commented May 12, 2021

Copy link
Copy Markdown
Contributor Author

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

@leandron

Copy link
Copy Markdown
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

vinceab commented May 12, 2021

Copy link
Copy Markdown
Contributor Author

@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

vinceab commented May 19, 2021

Copy link
Copy Markdown
Contributor Author

@leandron

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

@leandron

Copy link
Copy Markdown
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

@leandron leandron left a comment

Copy link
Copy Markdown
Contributor

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 <vincent.abriou@st.com>
@vinceab vinceab force-pushed the tvmc_cross_compiler_options branch from a06f7bf to 189f9bb Compare May 20, 2021 14:22
@vinceab

vinceab commented May 20, 2021

Copy link
Copy Markdown
Contributor Author

@leandron formatting/linter fixed

@leandron leandron self-assigned this May 21, 2021

@leandron leandron left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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 <vincent.abriou@st.com>
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 <vincent.abriou@st.com>
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