Skip to content

Add Python Programming Example #590

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

Merged
merged 20 commits into from
Jun 6, 2024
Merged

Add Python Programming Example #590

merged 20 commits into from
Jun 6, 2024

Conversation

hunhoffe
Copy link
Contributor

@hunhoffe hunhoffe commented Jun 4, 2024

Add a python programming example that is checked end-to-end by the CI workflow. This example includes multiple workflows for how to run the code (defined using AIR python bindings) on an NPU.

To support some of the additional passes used in test/xrt (including those for dependencies), I added a new argument, --experimental, to aircc.py, which will run those additional passes. It works on my example but I suspect that this will need to be changed/updated as more examples are made but I believe what I have is a reasonable starting point.

To simplify the example, I also added a wrapper around the python dma_memcpy_nd function to supply default values and allow the caller to use python integers.

abisca and others added 5 commits June 4, 2024 11:22
WIP: First steps toward build/run on npu for python example. Builds but does not run yet.

test.ccp is not correct but it is now running on the device. Also removed lit files for now while I debug

wip: small progress

test is running now, but does not check values in a meaningful way

'make run' now passes with a meaningful check!
@hunhoffe hunhoffe changed the title First Python Programming Example Add Python Programming Example Jun 4, 2024
@hunhoffe hunhoffe marked this pull request as ready for review June 5, 2024 17:11

## Run and test with AIR utility functions

This is the cleanest and simplest method of running MLIR-AIR code on NPUs, and uses code in the [run.py](run.py) file.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This might be a little generic, it doesn't really describe what is happening: compile + run/verify

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! I elaborated quite a bit in a recent commit. Can you double check that what I wrote is precise/correct/understandable?

I wasn't sure how much to put for explanation, as I think this is just an example and not part of a programming guide. But maybe that thinking is wrong?

@jgmelber jgmelber requested a review from fifield June 6, 2024 15:45
@jgmelber
Copy link
Collaborator

jgmelber commented Jun 6, 2024

@fifield is the --experimental argument okay with you?

Comment on lines +21 to +31
if (NOT WSL)
set(CMAKE_C_COMPILER gcc-13)
set(CMAKE_CXX_COMPILER g++-13)
set(BOOST_ROOT /usr/include/boost CACHE STRING "Path to Boost install")
set(XRT_INC_DIR /opt/xilinx/xrt/include CACHE STRING "Path to XRT cloned repo")
set(XRT_LIB_DIR /opt/xilinx/xrt/lib CACHE STRING "Path to xrt_coreutil.lib")
else()
set(BOOST_ROOT C:/Technical/thirdParty/boost_1_83_0 CACHE STRING "Path to Boost install")
set(XRT_INC_DIR C:/Technical/XRT/src/runtime_src/core/include CACHE STRING "Path to XRT cloned repo")
set(XRT_LIB_DIR C:/Technical/xrtNPUfromDLL CACHE STRING "Path to xrt_coreutil.lib")
endif()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know this is cut and paste, and probably useful, but I'll note we don't really have any windows support in mlir-air.

@fifield
Copy link
Collaborator

fifield commented Jun 6, 2024

@fifield is the --experimental argument okay with you?

Yup. However I would like it to become not experimental and have the pass pipeline work with all the examples and tests.

@hunhoffe hunhoffe merged commit 424d4e2 into main Jun 6, 2024
11 checks passed
@hunhoffe hunhoffe deleted the bindings branch June 6, 2024 17:58
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.

4 participants