Skip to content

Commit 0fffb5b

Browse files
committed
Makes PyCallable dimension reversing logic consistent with that of PyExtensionGen
1 parent 59bcd4b commit 0fffb5b

5 files changed

Lines changed: 171 additions & 69 deletions

File tree

README.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ in Python without C++.
1717

1818
Halide requires C++17 (or later) to use.
1919

20-
For more detail about what Halide is, see https://halide-lang.org.
20+
For more detail about what Halide is, see <https://halide-lang.org>.
2121

22-
For API documentation see https://halide-lang.org/docs.
22+
For API documentation see <https://halide-lang.org/docs>.
2323

2424
For some example code, read through the tutorials online
25-
at https://halide-lang.org/tutorials. The corresponding code is in the
25+
at <https://halide-lang.org/tutorials>. The corresponding code is in the
2626
`tutorials/` directory. Larger examples are in the `apps/` directory.
2727

2828
If you've acquired a full source distribution and want to build Halide, see the
@@ -39,14 +39,14 @@ the easiest way to get a binary build of Halide.
3939
Full releases may be installed with `pip` like so:
4040

4141
```shell
42-
$ pip install halide
42+
pip install halide
4343
```
4444

4545
Every commit to `main` is published to Test PyPI as a development version and
4646
these may be installed with a few extra flags:
4747

4848
```shell
49-
$ pip install halide --pre --extra-index-url https://test.pypi.org/simple
49+
pip install halide --pre --extra-index-url https://test.pypi.org/simple
5050
```
5151

5252
Currently, we provide wheels for: Windows x86-64, macOS x86-64, macOS arm64, and
@@ -59,7 +59,7 @@ installed it in. On Windows, you will need to add the virtual environment root
5959
directory to `CMAKE_PREFIX_PATH`. This can be done by running
6060
`set CMAKE_PREFIX_PATH=%VIRTUAL_ENV%` in `cmd`.
6161

62-
Other build systems can find the Halide root path by running `python -c
62+
Other build systems can find the Halide root path by running `python -c
6363
"import halide; print(halide.install_dir())"`.
6464

6565
## Homebrew
@@ -68,13 +68,13 @@ Alternatively, if you use macOS, you can install Halide via
6868
[Homebrew](https://brew.sh/) like so:
6969

7070
```
71-
$ brew install halide
71+
brew install halide
7272
```
7373

7474
## Binary tarballs
7575

7676
The latest version of Halide can always be found on GitHub
77-
at https://github.com/halide/Halide/releases
77+
at <https://github.com/halide/Halide/releases>
7878

7979
We provide binary releases for many popular platforms and architectures,
8080
including 32/64-bit x86 Windows, 64-bit x86/ARM macOS, and 32/64-bit x86/ARM
@@ -86,24 +86,24 @@ need to adjust compiler options accordingly if you're using an older XCode which
8686
does not default to libc++.
8787

8888
We use a recent Ubuntu LTS to build the Linux releases; if your distribution is
89-
too old, it might not have the requisite glibc.
89+
too old, it might not have the requisite glibc.
9090

9191
Nightly builds of Halide and the LLVM versions we use in CI are also available
92-
at https://buildbot.halide-lang.org/
92+
at <https://buildbot.halide-lang.org/>
9393

9494
## Vcpkg
9595

9696
If you use [vcpkg](https://github.com/microsoft/vcpkg) to manage dependencies,
9797
you can install Halide via:
9898

9999
```
100-
$ vcpkg install halide:x64-windows # or x64-linux/x64-osx
100+
vcpkg install halide:x64-windows # or x64-linux/x64-osx
101101
```
102102

103103
One caveat: vcpkg installs only the minimum Halide backends required to compile
104104
code for the active platform. If you want to include all the backends, you
105105
should install `halide[target-all]:x64-windows` instead. Note that since this
106-
will build LLVM, it will take a _lot_ of disk space (up to 100GB).
106+
will build LLVM, it will take a *lot* of disk space (up to 100GB).
107107

108108
## Other package managers
109109

@@ -118,7 +118,7 @@ you have experience publishing packages we would be happy to work with you!
118118

119119
There are two sets of platform requirements relevant to Halide: those required
120120
to run the compiler library in either JIT or AOT mode, and those required to run
121-
the _binary outputs_ of the AOT compiler.
121+
the *binary outputs* of the AOT compiler.
122122

123123
These are the **tested** host toolchain and platform combinations for building
124124
and running the Halide compiler library.
@@ -137,7 +137,7 @@ MSVC. We do not actively test these scenarios, however, so your mileage may
137137
vary.
138138

139139
Beyond these, we are willing to support (by accepting PRs for) platform and
140-
toolchain combinations that still receive _active, first-party, public support_
140+
toolchain combinations that still receive *active, first-party, public support*
141141
from their original vendors. For instance, at time of writing, this excludes
142142
Windows 7 and includes Ubuntu 18.04 LTS.
143143

@@ -158,14 +158,14 @@ It is simplest to get a binary release of LLVM on macOS by using
158158
Linux, the [LLVM APT repo](https://apt.llvm.org) is best; use the provided
159159
installation script. We know of no suitable official binary releases for
160160
Windows, however the ones we use in CI can usually be found at
161-
https://buildbot.halide-lang.org, along with tarballs for our other tested
161+
<https://buildbot.halide-lang.org>, along with tarballs for our other tested
162162
platforms. See [the section on Windows](#windows) below for further advice.
163163

164164
If your OS does not have packages for LLVM, or you want more control over the
165165
configuration, you can build it yourself. First check it out from GitHub:
166166

167167
```shell
168-
$ git clone --depth 1 --branch llvmorg-21.1.1 https://github.com/llvm/llvm-project.git
168+
git clone --depth 1 --branch llvmorg-21.1.1 https://github.com/llvm/llvm-project.git
169169
```
170170

171171
(LLVM 21.1.1 is the most recent released LLVM at the time of writing. For
@@ -202,8 +202,8 @@ parallelism. If you choose to omit `-G Ninja`, Makefiles will be generated
202202
instead. In this case, enable parallelism with `cmake --build build -j NNN`
203203
where `NNN` is the number of parallel jobs, i.e. the number of CPUs you have.
204204

205-
Note that you _must_ add `clang` and `lld` to `LLVM_ENABLE_PROJECTS` and
206-
`WebAssembly` and `X86` _must_ be included in `LLVM_TARGETS_TO_BUILD`.
205+
Note that you *must* add `clang` and `lld` to `LLVM_ENABLE_PROJECTS` and
206+
`WebAssembly` and `X86` *must* be included in `LLVM_TARGETS_TO_BUILD`.
207207
`LLVM_ENABLE_RUNTIMES=compiler-rt` is only required to build the fuzz tests, and
208208
`clang-tools-extra` is only necessary if you plan to contribute code to Halide
209209
(so that you can run `clang-tidy` on your pull requests). You can disable
@@ -223,7 +223,7 @@ Follow the above instructions to build LLVM or acquire a suitable binary
223223
release. Then change directory to the Halide repository and run:
224224

225225
```shell
226-
$ cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Release -DHalide_LLVM_ROOT=$LLVM_ROOT
226+
$ cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Release -DHalide_LLVM_ROOT=$LLVM_ROOT
227227
$ cmake --build build
228228
```
229229

@@ -274,7 +274,7 @@ to build. You can manually delete the build trees afterward, but vcpkg will not
274274
do this automatically.
275275

276276
See [BuildingHalideWithCMake.md](./doc/BuildingHalideWithCMake.md#vcpkg-presets)
277-
for directions to use Vcpkg for everything _except_ LLVM.
277+
for directions to use Vcpkg for everything *except* LLVM.
278278

279279
#### Building Halide
280280

@@ -352,9 +352,9 @@ must add two flags to Halide's CMake configure command line. First, disable LLVM
352352
with `-DVCPKG_OVERLAY_PORTS=cmake/vcpkg`. Second, point CMake to our newly built
353353
Halide with `-DHalide_LLVM_ROOT=D:/llvm-install`.
354354

355-
#### If all else fails...
355+
#### If all else fails
356356

357-
Do what the buildbots do: https://buildbot.halide-lang.org/master/#/builders
357+
Do what the buildbots do: <https://buildbot.halide-lang.org/master/#/builders>
358358

359359
If the row that best matches your system is red, then maybe things aren't just
360360
broken for you. If it's green, then you can click through to the latest build
@@ -377,25 +377,25 @@ want to use a different LLVM, such as a custom-built one following the
377377
instructions above, set the following environment variable:
378378

379379
```shell
380-
$ export LLVM_CONFIG="$LLVM_ROOT/bin/llvm-config"
380+
export LLVM_CONFIG="$LLVM_ROOT/bin/llvm-config"
381381
```
382382

383383
Now you should be able to just run `make` in the root directory of the Halide
384384
source tree. `make run_tests` will run the JIT test suite, and `make test_apps`
385385
will make sure all the apps compile and run (but won't check their output).
386386

387-
When building the tests, you can set the AOT compilation target with the
387+
When building the tests, you can set the AOT compilation target with the
388388
`HL_TARGET` environment variable.
389389

390390
### Building Halide out-of-tree with make
391391

392392
If you wish to build Halide in a separate directory, you can do that like so:
393393

394394
```shell
395-
$ cd ..
396-
$ mkdir halide_build
397-
$ cd halide_build
398-
$ make -f ../Halide/Makefile
395+
cd ..
396+
mkdir halide_build
397+
cd halide_build
398+
make -f ../Halide/Makefile
399399
```
400400

401401
# Some useful environment variables

doc/BuildingHalideWithCMake.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ We recommend installing CMake using [pipx] to avoid package conflicts and
6363
redundant installations. After installing pipx, run:
6464

6565
```shell
66-
$ pipx install cmake
66+
pipx install cmake
6767
```
6868

6969
Alternatively, you can use a normal virtual environment:
7070

7171
```shell
72-
$ python -m pip install cmake
72+
python -m pip install cmake
7373
```
7474

7575
If you don't want Python to manage your CMake installation, you can either
@@ -84,6 +84,7 @@ On Windows, there are two primary methods for installing an up-to-date CMake:
8484

8585
1. You can get CMake through the Visual Studio 2022 installer.
8686
2. You can use Windows's built-in package manager, [winget][winget]:
87+
8788
```shell
8889
winget install Kitware.CMake
8990
```
@@ -96,7 +97,7 @@ Microsoft's [documentation][vs-cmake-docs] for more details.
9697
[Homebrew] keeps its [CMake package][brew-cmake] up to date. Simply run:
9798

9899
```shell
99-
$ brew install cmake
100+
brew install cmake
100101
```
101102

102103
## Ubuntu Linux
@@ -219,7 +220,7 @@ To build the documentation, you will need to install [Doxygen]. This can be done
219220
either from the [Doxygen website][doxygen-download] or through [winget][winget]:
220221

221222
```shell
222-
$ winget install DimitriVanHeesch.Doxygen
223+
winget install DimitriVanHeesch.Doxygen
223224
```
224225

225226
To build the Python bindings, you will need to install Python 3. This should be
@@ -234,7 +235,7 @@ Once Python is installed, you can install the Python module dependencies either
234235
globally or in a [virtual environment][venv] by running
235236

236237
```shell
237-
$ python -m pip install -r requirements.txt
238+
python -m pip install -r requirements.txt
238239
```
239240

240241
from the root of the repository.
@@ -244,14 +245,13 @@ from the root of the repository.
244245
On macOS, it is possible to install all dependencies via [Homebrew][homebrew]:
245246

246247
```shell
247-
$ brew install llvm flatbuffers wabt python pybind11 doxygen eigen libpng libjpeg-turbo openblas
248+
brew install clang-format lld llvm flatbuffers wabt python pybind11 doxygen eigen libpng libjpeg-turbo openblas
248249
```
249250

250-
The `llvm` package includes `clang`, `clang-format`, and `lld`, too. To ensure
251-
CMake can find LLVM, set the following cache variable:
251+
To ensure that CMake can find LLVM, set the following cache variable:
252252

253253
```shell
254-
$ cmake ... -DHalide_ROOT=/opt/homebrew/opt/llvm
254+
cmake ... -DHalide_LLVM_ROOT=/opt/homebrew/opt/llvm
255255
```
256256

257257
Or use the `macOS` CMake preset, which does this for you.
@@ -275,8 +275,8 @@ dependencies. These are tabulated in `requirements.txt` and may be installed
275275
with:
276276

277277
```shell
278-
$ python -m pip install -U pip "setuptools[core]" wheel
279-
$ python -m pip install -r requirements.txt
278+
python -m pip install -U pip "setuptools[core]" wheel
279+
python -m pip install -r requirements.txt
280280
```
281281

282282
# Building Halide
@@ -299,16 +299,16 @@ You should either open the correct Developer Command Prompt directly or run the
299299
following:
300300

301301
```shell
302-
$ "C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
303-
$ "C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64_x86
304-
$ "C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64_arm
302+
"C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
303+
"C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64_x86
304+
"C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64_arm
305305
```
306306

307307
Then, assuming that vcpkg is installed to `D:\vcpkg`, simply run:
308308

309309
```shell
310-
$ cmake -G Ninja -S . -B build --toolchain D:\vcpkg\scripts\buildsystems\vcpkg.cmake -DCMAKE_BUILD_TYPE=Release
311-
$ cmake --build .\build
310+
cmake -G Ninja -S . -B build --toolchain D:\vcpkg\scripts\buildsystems\vcpkg.cmake -DCMAKE_BUILD_TYPE=Release
311+
cmake --build .\build
312312
```
313313

314314
Valid values of [`CMAKE_BUILD_TYPE`][cmake_build_type] are `Debug`,
@@ -351,8 +351,8 @@ The instructions here are straightforward. Assuming your environment is set up
351351
correctly, just run:
352352

353353
```shell
354-
$ cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Release
355-
$ cmake --build build
354+
cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Release
355+
cmake --build build
356356
```
357357

358358
If you omit `-G Ninja`, a Makefile-based generator will likely be used instead.
@@ -368,11 +368,11 @@ convenient. The following CMake preset commands correspond to the longer ones
368368
above.
369369

370370
```shell
371-
$ cmake --preset=win64 # VS 2022 generator, 64-bit build, vcpkg deps
372-
$ cmake --preset=win32 # VS 2022 generator, 32-bit build, vcpkg deps
373-
$ cmake --preset=macOS # Ninja generator, macOS host build, Homebrew deps
374-
$ cmake --preset=debug # Debug mode, any single-config generator / compiler
375-
$ cmake --preset=release # Release mode, any single-config generator / compiler
371+
cmake --preset=win64 # VS 2022 generator, 64-bit build, vcpkg deps
372+
cmake --preset=win32 # VS 2022 generator, 32-bit build, vcpkg deps
373+
cmake --preset=macOS # Ninja generator, macOS host build, Homebrew deps
374+
cmake --preset=debug # Debug mode, any single-config generator / compiler
375+
cmake --preset=release # Release mode, any single-config generator / compiler
376376
```
377377

378378
### Vcpkg presets
@@ -481,15 +481,15 @@ separate project. On any platform, this means running the
481481
single-configuration generator (like Ninja), run either:
482482

483483
```shell
484-
$ cmake --install ./build --prefix /path/to/Halide-install
485-
$ cmake --install .\build --prefix X:\path\to\Halide-install
484+
cmake --install ./build --prefix /path/to/Halide-install
485+
cmake --install .\build --prefix X:\path\to\Halide-install
486486
```
487487

488488
For a multi-configuration generator (like Visual Studio) run:
489489

490490
```shell
491-
$ cmake --install ./build --prefix /path/to/Halide-install --config Release
492-
$ cmake --install .\build --prefix X:\path\to\Halide-install --config Release
491+
cmake --install ./build --prefix /path/to/Halide-install --config Release
492+
cmake --install .\build --prefix X:\path\to\Halide-install --config Release
493493
```
494494

495495
Of course, make sure that you build the corresponding config before attempting

python_bindings/src/halide/halide_/PyBuffer.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ Halide::Runtime::Buffer<T, Dims, InClassDimStorage> pybufferinfo_to_halidebuffer
3232
return Halide::Runtime::Buffer<T, Dims, InClassDimStorage>(t, info.ptr, (int)info.ndim, dims);
3333
}
3434

35-
template<typename T = void,
36-
int Dims = AnyDims,
37-
int InClassDimStorage = (Dims == AnyDims ? 4 : std::max(Dims, 1))>
38-
Halide::Runtime::Buffer<T, Dims, InClassDimStorage> pybuffer_to_halidebuffer(const py::buffer &pyb, bool writable, bool reverse_axes) {
39-
return pybufferinfo_to_halidebuffer(pyb.request(writable), reverse_axes);
40-
}
41-
4235
} // namespace PythonBindings
4336
} // namespace Halide
4437

0 commit comments

Comments
 (0)