swh:1:snp:2c68c8bd649bf1bd2cf3bf7bd4f98d247b82b5dc
Revision 2f1587ed6432be601ae8f9f0cf16aaf6ae462836 authored by Steven Johnson on 28 October 2022, 00:18:41 UTC, committed by GitHub on 28 October 2022, 00:18:41 UTC
* Fix Python buffer handling

In the category of "how did this ever work"...

TL;DR: in general, Halide Buffers have the opposite axis ordering from Python/NumPy buffers; in Halide, the most-frequently-varying dimension comes first, while in Python, it comes last. This isn't surprising, though, since Halide's indexing scheme is effectively column-major while NumPy's is row-major.

Anyway: what we *should* have done was to reverse the order of dimensions when converting to/from Halide Buffers vs Python buffers; instead, we kept the same order, then jumped thru hoops to rearrange buffers to fit this setup. This PR does the appropriate axis reordering, fixing the apps and tests as needed.

It also adds some helper code for image reading and writing; by default, we use `imageio` for this, but imageio ~always wants RGB/RGBA images to be interleaved (vs the planar that Halide prefers). So, I added the `halide.imageio` package, that has wrapper functions to quietly convert to/from planar as needed.

Needless to say, this change is likely to break existing code that is using 3d buffers in Halide, but I think it's the right long-term thing to do.

Opinions greatly welcomed here.

* Update PyBuffer.cpp

* -"for better vectorization"

* public halide.imageio utilities should copy() buffers

* PEP8

* Update imageio.py

* Update imageio.py

* add 'reverse_axes' options to Buffer conversions (#7127)

* add 'reverse_axes' options to Buffer conversions
1 parent 48345d9
History
Tip revision: a9ea9b565018774e52bb4028cbc91e14cb86959e authored by Steven Johnson on 02 December 2022, 00:17:48 UTC
Fix for top-of-tree LLVM (#7194)
Tip revision: a9ea9b5
File Mode Size
.github
apps
cmake
dependencies
doc
packaging
python_bindings
src
test
tools
tutorial
util
.clang-format -rw-r--r-- 1.4 KB
.clang-format-ignore -rw-r--r-- 286 bytes
.clang-tidy -rw-r--r-- 2.2 KB
.gitattributes -rw-r--r-- 342 bytes
.gitignore -rw-r--r-- 5.0 KB
.gitmodules -rw-r--r-- 0 bytes
CMakeLists.txt -rw-r--r-- 5.5 KB
CMakePresets.json -rw-r--r-- 5.6 KB
CODE_OF_CONDUCT.md -rw-r--r-- 3.5 KB
LICENSE.txt -rw-r--r-- 13.8 KB
MANIFEST.in -rw-r--r-- 80 bytes
Makefile -rw-r--r-- 103.1 KB
README.md -rw-r--r-- 16.4 KB
README_cmake.md -rw-r--r-- 74.7 KB
README_python.md -rw-r--r-- 32.1 KB
README_rungen.md -rw-r--r-- 12.1 KB
README_webassembly.md -rw-r--r-- 10.5 KB
pyproject.toml -rw-r--r-- 195 bytes
requirements.txt -rw-r--r-- 129 bytes
run-clang-format.sh -rwxr-xr-x 1.4 KB
run-clang-tidy.sh -rwxr-xr-x 3.1 KB
setup.py -rw-r--r-- 1.2 KB

README.md

back to top