This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Python] Check numpy in Python bindings configuration.
ClosedPublic

Authored by zhanghb97 on Nov 29 2020, 1:58 AM.

Details

Summary

The test process of the ir_array_attributes.py depends on numpy. This patch checks numpy in Python bindings configuration.

  • Add NumPy in find_package as a required component to check numpy.
  • If numpy is found, print the version and include directory.

Diff Detail

Event Timeline

zhanghb97 created this revision.Nov 29 2020, 1:58 AM
zhanghb97 requested review of this revision.Nov 29 2020, 1:58 AM
mehdi_amini added inline comments.Nov 29 2020, 8:58 AM
mlir/CMakeLists.txt
82

Numpy can just be one of the COMPONENTS here I believe?

zhanghb97 edited the summary of this revision. (Show Details)

Check numpy in find_package by adding OPTIONAL_COMPONENTS NumPy.

mlir/CMakeLists.txt
82

I use OPTIONAL_COMPONENTS here, because I think the lack of numpy does not affect the building process of Python bindings, it only fails the test so I also report a WARNING.

mehdi_amini added inline comments.Nov 30 2020, 9:45 AM
mlir/CMakeLists.txt
82

If we can't run the test for the python bindings, I rather error out here and make it required.

88

Is pip the universal and only solution to get numpy? What if the user has configured Conda or something like that?

mlir/CMakeLists.txt
88

Of course it's not :)

I would just add an "or equiv" to the end.

But I think this whole condition goes away if making it required.

zhanghb97 edited the summary of this revision. (Show Details)

Add NumPy as a required component.

mlir/CMakeLists.txt
82

Done - Add the NumPy as a required component.

88

The NumPy is added to the required component, so we don't need the condition now.

zhanghb97 marked 4 inline comments as done.Nov 30 2020, 10:55 PM

I can't figure out why checking the numpy can fail the LLVM codegen test?

mehdi_amini accepted this revision.Dec 1 2020, 9:35 AM

It can't.

This revision is now accepted and ready to land.Dec 1 2020, 9:35 AM
This revision was landed with ongoing or failed builds.Dec 1 2020, 5:29 PM
This revision was automatically updated to reflect the committed changes.