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

[AOT] Added a test for detecting output size post MLF export #13655

Merged
merged 2 commits into from
Jan 9, 2023

Conversation

ashutosh-arm
Copy link
Contributor

@ashutosh-arm ashutosh-arm commented Dec 23, 2022

Follow up from: #12789

-Fixed IO size map preparation in MLF export
-Added a separate test to detect output size from MLF codegen
-MLF size is not used in aot.py because its unavailable in case of packed apis

cc @Mousius

@tvm-bot
Copy link
Collaborator

tvm-bot commented Dec 23, 2022

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@github-actions github-actions bot requested a review from Mousius December 23, 2022 12:53
python/tvm/micro/model_library_format.py Outdated Show resolved Hide resolved
python/tvm/micro/model_library_format.py Outdated Show resolved Hide resolved
data_len_var = actual_data_name + "_len"
main_file.write(
f"const size_t {data_len_var}"
f"= sizeof({actual_data_name})/sizeof({actual_data_name}[0]);\n"
Copy link
Member

Choose a reason for hiding this comment

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

We generate actual_data_name and data_length_var_name in the inputs/outputs already, why are we recalculating it here based on types we've defined within the AOT test harness?

We probably need to add a _LEN macro to the MLF header?

Copy link
Member

Choose a reason for hiding this comment

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

_LENGTH to be clearer 😸

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed offline, the two variables LEN and SIZE serve different purposes. SIZE will come from MLF export whereas LEN will be part of the AOT test harness.

Follow up: apache#12789

-Added a separate test to detect output size from MLF codegen
-Updated test harness to detect correct size from IO arrays
-MLF size was not used in aot.py because its unavailable in case of packed apis
@ashutosh-arm
Copy link
Contributor Author

@Mousius could you please take a look again after the LEN was included from AOT test harness?

Comment on lines 272 to 275
file_list = []
for path in (pathlib.Path(base_path) / "codegen" / "host" / "include").iterdir():
if path.is_file():
file_list.append(path)
Copy link
Member

Choose a reason for hiding this comment

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

Given we know the model_name can we not just look for tvmgen_{model_name}.h rather than looping?

Copy link
Member

Choose a reason for hiding this comment

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

Can we also do this for the input sizes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will extend the check for inputs. We could directly look for the file, but I thought that check maynot work for multiple models. But it does, so I will update that too.

Copy link
Member

Choose a reason for hiding this comment

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

I assume this just requires looking for both headers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, there is just one header in those cases too. Both models' sizes appear in a single header. So, need not be tested additionally.

Copy link
Member

Choose a reason for hiding this comment

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

That sounds wrong, shouldn't there be a tvmgen_model1.h and a tvmgen_model2.h ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad. I confused this with the multi-model test which it is not. In case of multi model test, I do see two separate headers being produced.

Comment on lines 282 to 283
assert contents.count("_SIZE") == 4
assert str(ref_output_size) in contents
Copy link
Member

Choose a reason for hiding this comment

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

We should probably check the _SIZE values match with the appropriate constants rather than them just appearing in the same file together?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried doing that initially. Any short cuts to do that?

Copy link
Member

Choose a reason for hiding this comment

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

Something like:

assert contents.count("_SIZE") == 4
assert f"INPUT_1_SIZE {ref_output_size}" in contents

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah ok. I misunderstood what you were asking for. This makes sense. Thanks for the help.

Change-Id: I07d470e4a8eabc75912675a56c528354c7d40981
@Mousius Mousius merged commit 614e16d into apache:main Jan 9, 2023
@Mousius
Copy link
Member

Mousius commented Jan 9, 2023

LGTM! Thanks @ashutosh-arm !

fzi-peccia pushed a commit to fzi-peccia/tvm that referenced this pull request Mar 27, 2023
…13655)

Follow up: apache#12789

-Added a separate test to detect output size from MLF codegen
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.

3 participants