Skip to content

Reorganization of the model folder and format - #1

Open
christophe0606 wants to merge 12 commits into
MatthiasHertelArm:mainfrom
christophe0606:main
Open

Reorganization of the model folder and format#1
christophe0606 wants to merge 12 commits into
MatthiasHertelArm:mainfrom
christophe0606:main

Conversation

@christophe0606

Copy link
Copy Markdown

Summary

This PR change the way models are represented and used. All the data needed for a test is now contained in the pte file:

  • Model
  • Input patterns
  • Expected outputs
  • Test thresholds
  • Input memory format (channel first or last)

It looks like tensors are exported as channel first when going through the constant_methods export path but some tests need channel last memory format. So a memory format boolean is used by the C++ test to correct the memory format of input tensor and expected output for some tests.

The model folder no more contain subdirectories but only the pte files.
The manifest.json now only contain the strings. Other data is in the pte.

The models are now used through the new EmbeddedModule class that is very similar to the executorch Module class. But original Module class uses posix API like mmap so cannot be used for embedded development.

Added new semihosting functions to quit the simulator at the end (since simulation was blocked at the end for some compilers).

cproject and csolution are listing the versions of the PyTorch pack to use. So if version is upgraded, those files will need a change.

The new tensor extension is built (but may not be needed for those tests)
AC6 is using full-fp mode so that gelu, isnan and isinf tests are passing.

A simpler memory allocator is used for the
temporary memory allocations. Athough not needed for those tests, it is generally advised to
use such an allocator for the temporary memory allocator.

arm_embedded_module.cpp added to the project. It is a customization of the
original Meta module.cpp as explained by the copyright header.
But it lives in a different namespace.

EmbeddedModel has been modified. It no more needs an EmbeddedBuffer since the test patterns
come from the pte.
Other field coming from pte have been removed.

gen_embedded_models.py has been modified to use the pte files directly (without any subfolders)
and to use the new manifest.json format

main.cpp

More comments have been added to main.cpp

Some debug functions have been added : to display a tensor or check its memory format.

A new function to_channels_last_4d_float to correct the memory format of the tensor has been added : note that
it makes a dynamic memory allocation which is ok for a test.

The test functions have been seperated:

  • tensor_all_close for float (using standard all_close naming)
  • Exact equality for all other datatypes

Error handling may be improved but it is assumed that the pte have been generated in the right format.

But tested only on a restricted set of operators.
Updated python script for new manifest format and new
models folder organization.
pte now contains the test patterns and the
thresholds for the test.

memory format_channel last is not exported
by pytorch (it is exported as channel_first
for the constant_methods) so in those cases, the
memory format of the input and expected tensors is
converted before testing the operator.

Additional semihosting exit function
Some tests were generated with random weights.
It has been fixed and as result the model to
test have changed.
This commit updates the tests to use the new models.
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.

1 participant