Skip to content

Makes PyCallable dimension reversing logic consistent with that of PythonExtensionGen#8931

Open
jiawen wants to merge 2 commits intomainfrom
jiawen-pycallable
Open

Makes PyCallable dimension reversing logic consistent with that of PythonExtensionGen#8931
jiawen wants to merge 2 commits intomainfrom
jiawen-pycallable

Conversation

@jiawen
Copy link
Contributor

@jiawen jiawen commented Feb 4, 2026

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:

  • Reverses the order of dimensions if a buffer is C-contiguous.
  • Does not reverse the order of dimensions if a buffer is F-contiguous.
  • Rejects other buffers.

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
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Homebrew pulled these out long ago.


```shell
$ pipx install cmake
pipx install cmake
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the drive-by. My vs code auto-formatted this entire file - but for the better I think.

return Halide::Runtime::Buffer<T, Dims, InClassDimStorage>(t, info.ptr, (int)info.ndim, dims);
}

template<typename T = void,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No longer used.

@jiawen
Copy link
Contributor Author

jiawen commented Feb 4, 2026

I'll work on how hl.Buffer wraps existing Buffers in a followup PR?

@@ -1,4 +1,5 @@
import halide as hl
import numpy as np
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are we ok with this requirement for the test?

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.

1 participant