Skip to content

Commit

Permalink
Fix Windows build failure.
Browse files Browse the repository at this point in the history
The TPU extension didn't build because the MLIR Python binding code requires pybind11 to be included first on Windows, per https://github.com/llvm/llvm-project/blob/9584f5834499e6093797d4a28fde209f927ea556/mlir/include/mlir-c/Bindings/Python/Interop.h#L24

PiperOrigin-RevId: 587049246
  • Loading branch information
hawkinsp authored and jax authors committed Dec 1, 2023
1 parent 95bc2ba commit 50c7223
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions jaxlib/mlir/_mlir_libs/tpu_ext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ limitations under the License.
#include <variant>
#include <vector>

// clang-format: off
// pybind11 must be included before mlir/Bindings/Python/PybindAdaptors.h,
// otherwise this code will not build on Windows.
#include "pybind11/pybind11.h"
// clang-format: on

#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/SmallVectorExtras.h"
Expand All @@ -43,7 +49,6 @@ limitations under the License.
#include "pybind11/cast.h"
#include "pybind11/detail/common.h"
#include "pybind11/numpy.h"
#include "pybind11/pybind11.h"
#include "pybind11/pytypes.h"
#include "absl/log/check.h"
#include "jaxlib/mosaic/dialect/tpu/integrations/c/tpu_dialect.h"
Expand Down Expand Up @@ -577,11 +582,11 @@ PYBIND11_MODULE(_tpu_ext, m) {
for (int64_t i = 0; i < np_arr.ndim(); ++i) {
shape.data()[i] = np_arr.shape()[i];
}
return mlirTpuAssemble(getDefaultInsertionPoint(), ty, layout,
MlirTpuValueArray{
MlirTpuI64ArrayRef{shape.data(), shape.size()},
vals.data()},
TARGET_SHAPE);
return mlirTpuAssemble(
getDefaultInsertionPoint(), ty, layout,
MlirTpuValueArray{MlirTpuI64ArrayRef{shape.data(), shape.size()},
vals.data()},
TARGET_SHAPE);
});
m.def("disassemble", [](MlirTpuVectorLayout layout, MlirValue val) {
NotImplementedDetector detector(getDefaultContext());
Expand Down

0 comments on commit 50c7223

Please sign in to comment.