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

Add functions that prepare tensors as input args for IREE tools #418

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

sogartar
Copy link
Contributor

One drawback of using npy files is that they don't support some datatypes.

This change adds functionality to prepare arguments from Torch tensors in the form
--input=1x2xbf16=@arg0.bin
These can then be passed to tools like iree-run-module and iree-benchmark-module.

@sogartar sogartar force-pushed the iree-tool-input-arg-helpers branch 2 times, most recently from 2a159db to 2c5eb6e Compare January 27, 2025 13:51
@sogartar sogartar changed the title Add functions that prepares tensors as input args for IREE tools Add functions that prepare tensors as input args for IREE tools Jan 27, 2025
@sogartar sogartar force-pushed the iree-tool-input-arg-helpers branch from 2c5eb6e to 8979355 Compare January 27, 2025 13:52
@sogartar sogartar marked this pull request as draft January 27, 2025 14:08
@sogartar sogartar force-pushed the iree-tool-input-arg-helpers branch from 8979355 to 680995d Compare January 27, 2025 14:23
@sogartar sogartar requested a review from dan-garvey January 28, 2025 21:20
@sogartar sogartar marked this pull request as ready for review January 30, 2025 16:44
@sogartar sogartar requested a review from ScottTodd February 3, 2025 14:49
Copy link
Member

@ScottTodd ScottTodd left a comment

Choose a reason for hiding this comment

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

Cool, having more helper functions in the installable tools will be great. I'd love to have enough of these utils available for test suites too, so we don't constantly rewrite them downstream:

iree/turbine/support/tools.py Show resolved Hide resolved
iree/turbine/support/conversions.py Show resolved Hide resolved
iree/turbine/support/tools.py Outdated Show resolved Hide resolved
iree/turbine/support/tools.py Outdated Show resolved Hide resolved
tests/support/conversions_test.py Outdated Show resolved Hide resolved
tests/support/tools_test.py Outdated Show resolved Hide resolved
@sogartar sogartar force-pushed the iree-tool-input-arg-helpers branch from 680995d to 21ba9a8 Compare February 6, 2025 01:18
@sogartar sogartar requested a review from ScottTodd February 6, 2025 01:22
Copy link
Member

@ScottTodd ScottTodd left a comment

Choose a reason for hiding this comment

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

LGTM! Please resolve the DCO check

One drawback of using npy files is that they don't support some
datatypes.

This change adds functionality to prepare arguments from Torch tensors
in the form
--input=1x2xbf16=@arg0.bin
These can then be passed to tools like iree-run-module and
iree-benchmark-module.

Signed-off-by: Boian Petkantchin <boian.petkantchin@amd.com>
@sogartar sogartar force-pushed the iree-tool-input-arg-helpers branch from 528d5fd to 6930b12 Compare February 6, 2025 21:42
@sogartar sogartar enabled auto-merge (squash) February 6, 2025 21:43
@sogartar sogartar merged commit 4b9d699 into iree-org:main Feb 6, 2025
9 of 10 checks passed
Comment on lines +37 to +60
"""Write the raw contents of tensors to files without any metadata.
Returns the CLI input args description.

If file_path_prefix is given, will chose a default naming for argument files.
It is treated as a string prefix and not as directory.
Example:
```
file_path_prefix="/some/path/arg"
```

returns
```
[
"1x2x3xf32=@/some/path/arg0.bin",
"4x5xi8=@/some/path/arg1.bin"
]
```

This results can be prefixed with "--input=" to arrive at the final CLI flags
expected by IREE tools.

Exactly one of file_paths and file_path_prefix must be provided.
Does not create parent directory(s).
"""
Copy link
Member

Choose a reason for hiding this comment

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

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