Makes PyCallable dimension reversing logic consistent with that of PythonExtensionGen#8931
Makes PyCallable dimension reversing logic consistent with that of PythonExtensionGen#8931
Conversation
| brew install clang-format lld llvm flatbuffers wabt python pybind11 doxygen eigen libpng libjpeg-turbo openblas | ||
| ``` | ||
|
|
||
| The `llvm` package includes `clang`, `clang-format`, and `lld`, too. To ensure |
There was a problem hiding this comment.
Homebrew pulled these out long ago.
doc/BuildingHalideWithCMake.md
Outdated
|
|
||
| ```shell | ||
| $ pipx install cmake | ||
| pipx install cmake |
There was a problem hiding this comment.
Sorry for the drive-by. My vs code auto-formatted this entire file - but for the better I think.
There was a problem hiding this comment.
After the changes we've made to CI and Python dependency management in #8942, we should revert this file and consider improvements in a separate PR.
a450b21 to
0fffb5b
Compare
|
I'll work on how |
| @@ -1,4 +1,5 @@ | |||
| import halide as hl | |||
| import numpy as np | |||
There was a problem hiding this comment.
Are we ok with this requirement for the test?
There was a problem hiding this comment.
Yes, unless it's very incidental. Numpy is all but in the standard Python library at this point.
|
@alexreinking PTAL? |
alexreinking
left a comment
There was a problem hiding this comment.
The code changes look good. Please drop the doc changes from this; we need a bigger update as a separate work item.
README.md
Outdated
| Halide requires C++17 (or later) to use. | ||
|
|
||
| For more detail about what Halide is, see https://halide-lang.org. | ||
| For more detail about what Halide is, see <https://halide-lang.org>. |
There was a problem hiding this comment.
Same thing here. Separate PR for this.
|
@alexreinking Reverted doc changes. |
Unfortunately, |
| void is_any_contiguous(const py::buffer_info &info, bool &c_contig, bool &f_contig) { | ||
| ssize_t c_stride = info.itemsize; | ||
| ssize_t f_stride = info.itemsize; | ||
| c_contig = true; | ||
| f_contig = true; |
There was a problem hiding this comment.
While we're changing things here for ssize_t, I'd rather this returned a std::pair and we could use structured bindings below to unpack them.
There was a problem hiding this comment.
You can probably get away with auto for the type of *_stride.
There was a problem hiding this comment.
I wasted a bunch of time tracking down where ssize_t is defined in PyBind11. py::buffer_info calls it ssize_t, but it's really py::ssize_t and an alias for Py_ssize_t. I didn't realize that ssize_t is POSIX and not part of C. 😠
There was a problem hiding this comment.
Well, glad you got to the bottom of it! py::ssize_t is probably nicer to read than auto? Up to you.
| bool c_contig; | ||
| bool f_contig; | ||
| is_any_contiguous(value_buffer_info, c_contig, f_contig); |
There was a problem hiding this comment.
| bool c_contig; | |
| bool f_contig; | |
| is_any_contiguous(value_buffer_info, c_contig, f_contig); | |
| auto [c_contig, f_contig] = is_any_contiguous(value_buffer_info); |
There was a problem hiding this comment.
Grudgingly ok. C++ lawyers at Google would scren "use a struct and name your fields!"
There was a problem hiding this comment.
If it were used in two places or not in an anonymous namespace, I would have suggested that. 🙂
There was a problem hiding this comment.
Aside: I'm generally more concerned about unexpected non-initialization (sneaky) than switching values around (typically loud logic bugs).
When a generator emits a Python extension, the pipeline only accepts buffers that are C or F contiguous (PythonExtensionGen.cpp), throwing an exception if it's neither.
In contrast, a callable constructed from
generator.compile_to_callable()constructs a pipeline that always reverses the dimensions of input buffers. It also non-contiguous buffers.This PR changes the latter to be consistent with the former. Callables constructed from
generator.compile_to_callable()now: