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

Document iree.build package #19019

Open
1 of 4 tasks
ScottTodd opened this issue Nov 4, 2024 · 6 comments
Open
1 of 4 tasks

Document iree.build package #19019

ScottTodd opened this issue Nov 4, 2024 · 6 comments
Assignees
Labels
bindings/python Python wrapping IREE's C API compiler/tools IREE's compiler tooling (iree-compile, iree-opt, etc) documentation ✏️ Improvements or additions to documentation

Comments

@ScottTodd
Copy link
Member

ScottTodd commented Nov 4, 2024

These PRs have started implementing a new iree.build package:

Documentation tasks:

Other related tasks:

We could wait until more of the package architecture and usage solidifies, but trying it out early would help inform the design.

@ScottTodd ScottTodd added bindings/python Python wrapping IREE's C API compiler/tools IREE's compiler tooling (iree-compile, iree-opt, etc) documentation ✏️ Improvements or additions to documentation labels Nov 4, 2024
@stellaraccident
Copy link
Collaborator

Thanks.

It really needs a handful more patches and a first use or two for me to stand behind it. Soon. Need it for some very near term priorities.

@ScottTodd ScottTodd self-assigned this Nov 20, 2024
@ScottTodd
Copy link
Member Author

I started trying out the iree.build package over in https://github.com/iree-org/iree-test-suites on this branch today: https://github.com/ScottTodd/iree-test-suites/tree/onnx-ops-build, as an alternate way to implement the onnx operator test conversion script. The package feels a bit heavy for that usage, but I'm learning as I go and that will help with documentation. The turbine_generate rule from iree-org/iree-turbine#249 may help with writing PyTorch tests too.

We also have downstream usage in shortfin here: https://github.com/nod-ai/shark-ai/blob/main/shortfin/python/shortfin_apps/sd/components/builders.py.

@stellaraccident
Copy link
Collaborator

Thanks
This desperately needs to be finished. Just ran out of time while juggling priorities :/

@stellaraccident
Copy link
Collaborator

I think that there are likely some API wrappers that would make single shot cases work well, in addition to the more complicated pipeline cases

@ScottTodd
Copy link
Member Author

For https://github.com/iree-org/iree-test-suites/blob/main/onnx_ops/import_onnx_tests.py, which I started migrating to use iree.build yesterday, the usage will be like:

def import_action(folder_with_upstream_onnx_test_case):
  # .onnx -> .mlir
  import_onnx(folder / "model.onnx")
  # input_0.pb, input_1.pb, ..., input_n.pb --> input_0.bin, ...
  # output_0.pb, ... -> output_0.bin, ...
  # run_module_io_flags.txt
  import_test_inputs_and_outputs_from_pb_to_bin(folder)

for test_case in test_cases: # around 1000 of these
  # Enqueue a build task for the test case. Each of these is independent.
  import_action(test_case)

So at least one custom build action to convert the .pb upstream test files to .bin IREE test files, then ~1000 groups of actions that can run in parallel. Right now I'm using with Pool(args.jobs) as pool to run the imports in parallel. The 1 folder with N files in it --> 1 folder with N+1 files in it relationship is an interesting case for the dependency modeling, compared to other flows that go 1 file --> 1 file --> 1 file.

Since the build graph goes wide instead of deep, I'm not sure if using iree.build makes a whole lot of sense, but uniformity and more code samples across our projects will help users too.


I also found a few spots where the code could be reworked to better support Windows, like

def allocate_file(
self, path: str, namespace: FileNamespace = FileNamespace.GEN
) -> BuildFile:
"""Allocates a file in the build tree with local path |path|.
If |path| is absoluate (starts with '/'), then it is used as-is. Otherwise,
it is joined with the path of this context.
"""
if not path.startswith("/"):
path = join_namespace(self.path, path)
build_file = BuildFile(executor=self.executor, path=path, namespace=namespace)
return build_file

-        if not path.startswith("/"):
+        if not Path(path).is_absolute():

I'll send a PR once I'm a bit further along.

ScottTodd added a commit that referenced this issue Nov 21, 2024
…19236)

Progress on #19019 and
#5477.

We have API documentation for the Python APIs hosted at
https://iree-python-api.readthedocs.io/, but it has been pretty
neglected, to the point where that URL is buried at
https://iree.dev/reference/bindings/python/#usage. I'm not actually sure
if any users have found that page (readthedocs does provide traffic data
analytics, but we don't have enough views for that to register).

This makes a few incremental improvements while I learn my way around
Sphinx and what we have already for doc configuration, docstrings in
source files, packages, etc.

* Updated documentation for building the Sphinx website locally and
recommended developers use `sphinx-autobuild`
* Added an initial page for the `iree.build` package
* Used code blocks in more places consistently, and closed some that
were opened without closing ` characters
* Fixed a few other warnings from Sphinx (wrong indentation, section
delimiters not using enough characters, etc.)
* Worked around a weird style issue with some custom css
* Bumped the copyright year (as we do for https://iree.dev)
@ScottTodd
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bindings/python Python wrapping IREE's C API compiler/tools IREE's compiler tooling (iree-compile, iree-opt, etc) documentation ✏️ Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants