Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions deps/ReactantExtra/API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "src/enzyme_ad/jax/Implementations/XLADerivatives.h"
#include "src/enzyme_ad/jax/Passes/Passes.h"
#include "llvm/Support/TargetSelect.h"
#include "shardy/dialect/sdy/ir/dialect.h"

#include "mlir/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.h"
#include "stablehlo/dialect/ChloOps.h"
Expand Down Expand Up @@ -673,6 +674,7 @@ extern "C" void RegisterDialects(MlirContext cctx) {
context.loadDialect<mlir::mhlo::MhloDialect>();
context.loadDialect<mlir::stablehlo::StablehloDialect>();
context.loadDialect<mlir::chlo::ChloDialect>();
context.loadDialect<mlir::sdy::SdyDialect>();
}

#include "mlir/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.h"
Expand Down Expand Up @@ -701,6 +703,8 @@ extern "C" void InitializeRegistryAndPasses(MlirDialectRegistry creg) {
mlir::registerNVVMDialectImport(registry);
mlir::LLVM::registerInlinerInterface(registry);

mlir::sdy::registerAllDialects(registry);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@wsmoses this should be enough right

Copy link
Member

Choose a reason for hiding this comment

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

Double check if there’s a loadDialect call somewhere too otherwise lgtm


/*
registry.addExtension(+[](MLIRContext *ctx, LLVM::LLVMDialect *dialect) {
LLVM::LLVMFunctionType::attachInterface<MemRefInsider>(*ctx);
Expand Down
15 changes: 15 additions & 0 deletions deps/ReactantExtra/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,21 @@ gentbl_cc_library(
tblgen = "//:mlir-jl-tblgen",
)

gentbl_cc_library(
name = "ShardyJLIncGen",
tbl_outs = [(
["--generator=jl-op-defs", "--disable-module-wrap=0"],
"Shardy.jl"
)
],
td_file = "@shardy//shardy/dialect/sdy/ir:ops.td",
deps = [
"@shardy//shardy/dialect/sdy/ir:sdy_td_files",
],
tblgen = "//:mlir-jl-tblgen",
includes = ["external/shardy"],
)

genrule(
name = "libMLIR_h.jl",
tags = [
Expand Down
11 changes: 10 additions & 1 deletion deps/ReactantExtra/make-bindings.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
const bazel_cmd = if !isnothing(Sys.which("bazelisk"))
"bazelisk"
elseif !isnothing(Sys.which("bazel"))
"bazel"
else
error("Could not find `bazel` or `bazelisk` in PATH!")
end

function build_file(output_path)
file = basename(output_path)
run(
Cmd(
`bazel build --action_env=JULIA=$(Base.julia_cmd().exec[1]) --action_env=JULIA_DEPOT_PATH=$(Base.DEPOT_PATH) --repo_env HERMETIC_PYTHON_VERSION="3.10" --check_visibility=false --verbose_failures //:$file`;
`$(bazel_cmd) build --action_env=JULIA=$(Base.julia_cmd().exec[1]) --action_env=JULIA_DEPOT_PATH=$(Base.DEPOT_PATH) --repo_env HERMETIC_PYTHON_VERSION="3.10" --check_visibility=false --verbose_failures //:$file`;
dir=@__DIR__,
),
)
Expand All @@ -29,6 +37,7 @@ for file in [
"Affine.jl",
"TPU.jl",
"Triton.jl",
"Shardy.jl",
]
build_file(joinpath(src_dir, "mlir", "Dialects", file))
end
Expand Down
Loading