Uh oh!
There was an error while loading. Please reload this page.
[AOT] Name mangling in AOT - #8014
Conversation
giuseros
commented
May 10, 2021
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
giuseros
commented
May 11, 2021
I marked the naming comments "resolved". The meaning is that we will discuss those on the RFC here: https://discuss.tvm.apache.org/t/mini-rfc-name-mangling-in-aot/ |
giuseros
commented
May 12, 2021
I made the name-mangling logic completely decoupled by the non-name-mangling logic. This means that name mangling is enabled only in AOT and in |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
cbb0d21 to
18fadc8Compare
manupak
left a comment
There was a problem hiding this comment.
Hi @giuseros ,
Sorry been busy a bit :)
I did an initial pass.
I guess my main concern is why are we duplicating lowering functions with and without name mangling support. I would naturally think user would want to name mangle the function names if a mod_name is provided and mangled names are strictly superior to non-mangled polluted names, irrespective of whether they are being used in AoT or not, unless Im missing something.
I'd like to hear @areusch thoughts as well.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi @manupa-arm ,
I guess that, in addition to make the tests pass, we need to agree on naming:
|
4ee6f0e to
1da5b29CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
4cd83ac to
b0bcfd4Comparegiuseros
commented
Jun 3, 2021
Hi @manupa-arm , @areusch , |
areusch
left a comment
There was a problem hiding this comment.
just one other nit (honestly mostly care about the unit test, but adding a comment since i saw this)
Uh oh!
There was an error while loading. Please reload this page.
15072dc to
469d10dCompareThis introduces structures generated to provide a documented and stable user
friendly interface to a TVM generated model, as can be seen in the AOT
demo application:
```
struct tvm_default_inputs inputs = {
.input_1 = input_data,
};
struct tvm_default_outputs outputs = {
.output = output_data,
};
int ret_val = tvm_default_run(&inputs, &outputs, NULL, NULL);
```
To facilitate this, some other changes are included:
* Removed dependency on `aot_executor.{c,h}` in tests, pending the
discussion in the interface RFC as to whether we keep them.
* Moved creation of test DLTensor's into the AOT test utils, in future this
can be replaced by loading via the Python API or otherwise
* Introduce `parametrize_aot_options` which can be used to test
permutations of AOT which work together - for now this filters C
interface and packed operators
* Updated demo application to generate the header for demonstration
purposes, we should consider porting the demo application to Model
Library Format and using the toolchain in the Zephyr App via CMake
instead?
This patch builds upon the improvements @giuseros made to AOT testing
and will greatly benefit from name mangling from apache#8014areusch
commented
Jun 22, 2021
apologies, i think i missed this and it now needs a rebase or merge. i discussed this with @jroesch a bit as well, who is now working in earnest to merge #7518 in the next two weeks. following that PR, we'll arrive at a state where we can begin to think of the entire compiler as a series of IRModule passes. our discussion was that, at that point, it probably makes sense to move things like name mangling and e.g. the type signature changes proposed by @Mousius to one end of the compiler stack (i.e. at the relay level or at the end of the TIR passes). this way, the middle part of the compiler remains as generic as possible. we'd like to propose the following:
to that end, we'd like to briefly prioritize #7518 next week over AOT changes to reduce the churn and let it land, since it's a fairly invasive PR. if that's ok with you guys, i'll hand this off to @jroesch to merge while i'm ooo next few days. |
Mini-RFC is here: https://discuss.tvm.apache.org/t/mini-rfc-name-mangling-in-aot With this change we'll mangle the name of global symbols so that we can bundle together multiple models in the same application. The relay.build interface has been left unchanged, which means I am resuing mod_name as a prefix for all functions. If mod_name is None then a "_tvm" prefix is used. I had to add two different compilation functions: - _CompileEngineLowerWithModuleName to mangle all the operators with the mod_name - PartitionGraphWithModName to mangle all the operators produced by BYOC I could have changed signature of both, but that would have meant a very invasive refactoring. I refactored the aot test utils and added some tests for multiple models. Change-Id: I30e93fa075f660054577ea36cf9268ec0c6eebcb
giuseros
commented
Jun 22, 2021
Hi @areusch , @jroesch , Thanks, |
Change-Id: I4f11da7fce1327ad89bb25f25209b57077b2c6a3
giuseros
commented
Jun 24, 2021
A friendly ping @manupa-arm , @jroesch , @areusch ! |
areusch
commented
Jun 25, 2021
areusch
commented
Jun 25, 2021
@manupa-arm@Mousius please take a look and explicitly approve if you're ok w/ this change |
This introduces structures generated to provide a documented and stable user
friendly interface to a TVM generated model, as can be seen in the AOT
demo application:
```
struct tvmgen_default_inputs inputs = {
.input_1 = input_data,
};
struct tvmgen_default_outputs outputs = {
.output = output_data,
};
int ret_val = tvmgen_default_run(&inputs, &outputs, NULL, NULL);
```
To facilitate this, some other changes are included:
* Removed dependency on `aot_executor.{c,h}` in tests, pending the
discussion in the interface RFC as to whether we keep them.
* Moved creation of test DLTensor's into the AOT test utils, in future this
can be replaced by loading via the Python API or otherwise
* Introduce `parametrize_aot_options` which can be used to test
permutations of AOT which work together - for now this filters C
interface and packed operators
* Updated demo application to generate the header for demonstration
purposes, we should consider porting the demo application to Model
Library Format and using the toolchain in the Zephyr App via CMake
instead?
This patch builds upon the improvements @giuseros made to AOT testing
and name mangling from apache#8014This introduces structures generated to provide a documented and stable user
friendly interface to a TVM generated model, as can be seen in the AOT
demo application:
```
struct tvmgen_default_inputs inputs = {
.input_1 = input_data,
};
struct tvmgen_default_outputs outputs = {
.output = output_data,
};
int ret_val = tvmgen_default_run(&inputs, &outputs, NULL, NULL);
```
To facilitate this, some other changes are included:
* Removed dependency on `aot_executor.{c,h}` in tests, pending the
discussion in the interface RFC as to whether we keep them.
* Moved creation of test DLTensor's into the AOT test utils, in future this
can be replaced by loading via the Python API or otherwise
* Introduce `parametrize_aot_options` which can be used to test
permutations of AOT which work together - for now this filters C
interface and packed operators
* Updated demo application to generate the header for demonstration
purposes, we should consider porting the demo application to Model
Library Format and using the toolchain in the Zephyr App via CMake
instead?
This patch builds upon the improvements @giuseros made to AOT testing
and name mangling from apache#8014This introduces structures generated to provide a documented and stable user
friendly interface to a TVM generated model, as can be seen in the AOT
demo application:
```
struct tvmgen_default_inputs inputs = {
.input_1 = input_data,
};
struct tvmgen_default_outputs outputs = {
.output = output_data,
};
int ret_val = tvmgen_default_run(&inputs, &outputs, NULL, NULL);
```
To facilitate this, some other changes are included:
* Removed dependency on `aot_executor.{c,h}` in tests, pending the
discussion in the interface RFC as to whether we keep them.
* Moved creation of test DLTensor's into the AOT test utils, in future this
can be replaced by loading via the Python API or otherwise
* Introduce `parametrize_aot_options` which can be used to test
permutations of AOT which work together - for now this filters C
interface and packed operators
* Updated demo application to generate the header for demonstration
purposes, we should consider porting the demo application to Model
Library Format and using the toolchain in the Zephyr App via CMake
instead?
This patch builds upon the improvements @giuseros made to AOT testing
and name mangling from apache#8014This introduces structures generated to provide a documented and stable user
friendly interface to a TVM generated model, as can be seen in the AOT
demo application:
```
struct tvmgen_default_inputs inputs = {
.input_1 = input_data,
};
struct tvmgen_default_outputs outputs = {
.output = output_data,
};
int ret_val = tvmgen_default_run(&inputs, &outputs, NULL, NULL);
```
To facilitate this, some other changes are included:
* Removed dependency on `aot_executor.{c,h}` in tests, pending the
discussion in the interface RFC as to whether we keep them.
* Moved creation of test DLTensor's into the AOT test utils, in future this
can be replaced by loading via the Python API or otherwise
* Introduce `parametrize_aot_options` which can be used to test
permutations of AOT which work together - for now this filters C
interface and packed operators
* Updated demo application to generate the header for demonstration
purposes, we should consider porting the demo application to Model
Library Format and using the toolchain in the Zephyr App via CMake
instead?
This patch builds upon the improvements @giuseros made to AOT testing
and name mangling from apache#8014This introduces structures generated to provide a documented and stable user
friendly interface to a TVM generated model, as can be seen in the AOT
demo application:
```
struct tvmgen_default_inputs inputs = {
.input_1 = input_data,
};
struct tvmgen_default_outputs outputs = {
.output = output_data,
};
int ret_val = tvmgen_default_run(&inputs, &outputs, NULL, NULL);
```
To facilitate this, some other changes are included:
* Removed dependency on `aot_executor.{c,h}` in tests, pending the
discussion in the interface RFC as to whether we keep them.
* Moved creation of test DLTensor's into the AOT test utils, in future this
can be replaced by loading via the Python API or otherwise
* Introduce `parametrize_aot_options` which can be used to test
permutations of AOT which work together - for now this filters C
interface and packed operators
* Updated demo application to generate the header for demonstration
purposes, we should consider porting the demo application to Model
Library Format and using the toolchain in the Zephyr App via CMake
instead?
This patch builds upon the improvements @giuseros made to AOT testing
and name mangling from apache#8014This introduces structures generated to provide a documented and stable user
friendly interface to a TVM generated model, as can be seen in the AOT
demo application:
```
struct tvmgen_default_inputs inputs = {
.input_1 = input_data,
};
struct tvmgen_default_outputs outputs = {
.output = output_data,
};
int ret_val = tvmgen_default_run(&inputs, &outputs, NULL, NULL);
```
To facilitate this, some other changes are included:
* Removed dependency on `aot_executor.{c,h}` in tests, pending the
discussion in the interface RFC as to whether we keep them.
* Moved creation of test DLTensor's into the AOT test utils, in future this
can be replaced by loading via the Python API or otherwise
* Introduce `parametrize_aot_options` which can be used to test
permutations of AOT which work together - for now this filters C
interface and packed operators
* Updated demo application to generate the header for demonstration
purposes, we should consider porting the demo application to Model
Library Format and using the toolchain in the Zephyr App via CMake
instead?
This patch builds upon the improvements @giuseros made to AOT testing
and name mangling from apache#8014* Introduce --interface-api={c,packed} parameter
This introduces structures generated to provide a documented and stable user
friendly interface to a TVM generated model, as can be seen in the AOT
demo application:
```
struct tvmgen_default_inputs inputs = {
.input_1 = input_data,
};
struct tvmgen_default_outputs outputs = {
.output = output_data,
};
int ret_val = tvmgen_default_run(&inputs, &outputs, NULL, NULL);
```
To facilitate this, some other changes are included:
* Removed dependency on `aot_executor.{c,h}` in tests, pending the
discussion in the interface RFC as to whether we keep them.
* Moved creation of test DLTensor's into the AOT test utils, in future this
can be replaced by loading via the Python API or otherwise
* Introduce `parametrize_aot_options` which can be used to test
permutations of AOT which work together - for now this filters C
interface and packed operators
* Updated demo application to generate the header for demonstration
purposes, we should consider porting the demo application to Model
Library Format and using the toolchain in the Zephyr App via CMake
instead?
This patch builds upon the improvements @giuseros made to AOT testing
and name mangling from #8014
* Tweak metadata variable description and MLF target loop
* Remove direct usage of `relay::Var` in meta_data.h
This looks like the only place that could be causing the Windows CI failures, so trying removing the additional header in meta_data.h
* Linting fix
* Post-rebase files fixing
These tests were somehow transmuted in transit, I've updated them to the
most recent variant of the test helpers.
* Strip back interface API to just inputs and outputs
This removes any speculative structures from the generated code and cleans up some of the documentation.
* Add header guards and tweak documentation* [AOT] Name mangling in AOT Mini-RFC is here: https://discuss.tvm.apache.org/t/mini-rfc-name-mangling-in-aot With this change we'll mangle the name of global symbols so that we can bundle together multiple models in the same application. The relay.build interface has been left unchanged, which means I am resuing mod_name as a prefix for all functions. If mod_name is None then a "_tvm" prefix is used. I had to add two different compilation functions: - _CompileEngineLowerWithModuleName to mangle all the operators with the mod_name - PartitionGraphWithModName to mangle all the operators produced by BYOC I could have changed signature of both, but that would have meant a very invasive refactoring. I refactored the aot test utils and added some tests for multiple models. Change-Id: I30e93fa075f660054577ea36cf9268ec0c6eebcb * retrigger CI Change-Id: I4f11da7fce1327ad89bb25f25209b57077b2c6a3
* Introduce --interface-api={c,packed} parameter
This introduces structures generated to provide a documented and stable user
friendly interface to a TVM generated model, as can be seen in the AOT
demo application:
```
struct tvmgen_default_inputs inputs = {
.input_1 = input_data,
};
struct tvmgen_default_outputs outputs = {
.output = output_data,
};
int ret_val = tvmgen_default_run(&inputs, &outputs, NULL, NULL);
```
To facilitate this, some other changes are included:
* Removed dependency on `aot_executor.{c,h}` in tests, pending the
discussion in the interface RFC as to whether we keep them.
* Moved creation of test DLTensor's into the AOT test utils, in future this
can be replaced by loading via the Python API or otherwise
* Introduce `parametrize_aot_options` which can be used to test
permutations of AOT which work together - for now this filters C
interface and packed operators
* Updated demo application to generate the header for demonstration
purposes, we should consider porting the demo application to Model
Library Format and using the toolchain in the Zephyr App via CMake
instead?
This patch builds upon the improvements @giuseros made to AOT testing
and name mangling from apache#8014
* Tweak metadata variable description and MLF target loop
* Remove direct usage of `relay::Var` in meta_data.h
This looks like the only place that could be causing the Windows CI failures, so trying removing the additional header in meta_data.h
* Linting fix
* Post-rebase files fixing
These tests were somehow transmuted in transit, I've updated them to the
most recent variant of the test helpers.
* Strip back interface API to just inputs and outputs
This removes any speculative structures from the generated code and cleans up some of the documentation.
* Add header guards and tweak documentation* Introduce --interface-api={c,packed} parameter
This introduces structures generated to provide a documented and stable user
friendly interface to a TVM generated model, as can be seen in the AOT
demo application:
```
struct tvmgen_default_inputs inputs = {
.input_1 = input_data,
};
struct tvmgen_default_outputs outputs = {
.output = output_data,
};
int ret_val = tvmgen_default_run(&inputs, &outputs, NULL, NULL);
```
To facilitate this, some other changes are included:
* Removed dependency on `aot_executor.{c,h}` in tests, pending the
discussion in the interface RFC as to whether we keep them.
* Moved creation of test DLTensor's into the AOT test utils, in future this
can be replaced by loading via the Python API or otherwise
* Introduce `parametrize_aot_options` which can be used to test
permutations of AOT which work together - for now this filters C
interface and packed operators
* Updated demo application to generate the header for demonstration
purposes, we should consider porting the demo application to Model
Library Format and using the toolchain in the Zephyr App via CMake
instead?
This patch builds upon the improvements @giuseros made to AOT testing
and name mangling from apache#8014
* Tweak metadata variable description and MLF target loop
* Remove direct usage of `relay::Var` in meta_data.h
This looks like the only place that could be causing the Windows CI failures, so trying removing the additional header in meta_data.h
* Linting fix
* Post-rebase files fixing
These tests were somehow transmuted in transit, I've updated them to the
most recent variant of the test helpers.
* Strip back interface API to just inputs and outputs
This removes any speculative structures from the generated code and cleans up some of the documentation.
* Add header guards and tweak documentation* [AOT] Name mangling in AOT Mini-RFC is here: https://discuss.tvm.apache.org/t/mini-rfc-name-mangling-in-aot With this change we'll mangle the name of global symbols so that we can bundle together multiple models in the same application. The relay.build interface has been left unchanged, which means I am resuing mod_name as a prefix for all functions. If mod_name is None then a "_tvm" prefix is used. I had to add two different compilation functions: - _CompileEngineLowerWithModuleName to mangle all the operators with the mod_name - PartitionGraphWithModName to mangle all the operators produced by BYOC I could have changed signature of both, but that would have meant a very invasive refactoring. I refactored the aot test utils and added some tests for multiple models. Change-Id: I30e93fa075f660054577ea36cf9268ec0c6eebcb * retrigger CI Change-Id: I4f11da7fce1327ad89bb25f25209b57077b2c6a3
Mini-RFC is here: https://discuss.tvm.apache.org/t/mini-rfc-name-mangling-in-aot
With this change we'll mangle the name of global symbols so that we can bundle
together multiple models in the same application.
The relay.build interface has been left unchanged, which means I am
resuing mod_name as a prefix for all functions.
tvmgen_prefix is usedtvmgen_mod_name_prefix is usedI refactored the aot test utils and added some tests for multiple
models.
Change-Id: I310af75c24e422861aeaceb3c3cd4cd602071df5