Skip to content
Draft
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
10 changes: 6 additions & 4 deletions enzyme/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")

# generate compilation commands for enzymemlir-opt
load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")
load("@llvm-project//mlir:tblgen.bzl", "gentbl_cc_library", "td_library")

licenses(["notice"])
Expand Down Expand Up @@ -586,8 +589,8 @@ cc_library(
],
visibility = ["//visibility:public"],
deps = [
":EnzymeAttributesIncGen",
":EnzymeAttributeInterfacesIncGen",
":EnzymeAttributesIncGen",
":EnzymeEnumsIncGen",
":EnzymeOpInterfacesIncGen",
":EnzymeOpsIncGen",
Expand All @@ -598,13 +601,14 @@ cc_library(
":arith-derivatives",
":cf-derivatives",
":complex-derivatives",
":enzyme-derivatives",
":func-derivatives",
":llvm-derivatives",
":math-derivatives",
":memref-derivatives",
":nvvm-derivatives",
":scf-derivatives",
":enzyme-derivatives",
"@com_google_absl//absl/status:statusor",
"@llvm-project//llvm:Analysis",
"@llvm-project//llvm:Core",
"@llvm-project//llvm:Demangle",
Expand Down Expand Up @@ -688,8 +692,6 @@ cc_binary(

exports_files(["run_lit.sh"])

# generate compilation commands for enzymemlir-opt
load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")
refresh_compile_commands(
name = "refresh_compile_commands",
targets = [":enzymemlir-opt"],
Expand Down
11 changes: 6 additions & 5 deletions enzyme/Enzyme/MLIR/Passes/EnzymeBatchPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "PassDetails.h"
#include "Passes/Passes.h"

#include "absl/status/statusor.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/Builders.h"
#include "mlir/Interfaces/FunctionInterfaces.h"
Expand Down Expand Up @@ -212,7 +213,7 @@ FunctionOpInterface batchCloneFunction(
}

template <typename T>
LogicalResult batchOperation(
absl::StatusOr<func::CallOp> batchOperation(
SymbolTableCollection &symbolTable, T CI,
std::map<BatchCacheKey, FunctionOpInterface> &batchedFunctionCache) {
auto *symbolOp = symbolTable.lookupNearestSymbolFrom(CI, CI.getFnAttr());
Expand All @@ -221,7 +222,7 @@ LogicalResult batchOperation(
}

template <typename T>
LogicalResult batchOperation(
absl::StatusOr<func::CallOp> batchOperation(
T CI, FunctionOpInterface fn,
std::map<BatchCacheKey, FunctionOpInterface> &batchedFunctionCache) {
enzyme::batchutils::BatchCacheKey key{
Expand All @@ -239,7 +240,7 @@ LogicalResult batchOperation(
newFunc = batchCloneFunction(fn, "batched_" + fn.getName(),
CI.getBatchShape(), batchedFunctionCache);
if (!newFunc) {
return failure();
return absl::InternalError("Failed to batch function.");
}
}

Expand All @@ -248,7 +249,7 @@ LogicalResult batchOperation(
CI.getLoc(), newFunc.getName(), newFunc.getResultTypes(), CI.getInputs());
CI.replaceAllUsesWith(dCI);
CI->erase();
return success();
return dCI;
}

} // namespace batchutils
Expand Down Expand Up @@ -281,7 +282,7 @@ struct BatchPass : public BatchPassBase<BatchPass> {
if (auto F = dyn_cast<enzyme::BatchOp>(T)) {
auto res = enzyme::batchutils::batchOperation(symbolTable, F,
batchedFunctionCache);
if (!res.succeeded()) {
if (!res.ok()) {
signalPassFailure();
return;
}
Expand Down
5 changes: 3 additions & 2 deletions enzyme/Enzyme/MLIR/Passes/EnzymeBatchPass.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef ENZYME_BATCH_PASS_H
#define ENZYME_BATCH_PASS_H

#include "absl/status/statusor.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/Builders.h"
#include "mlir/Interfaces/FunctionInterfaces.h"
Expand Down Expand Up @@ -41,12 +42,12 @@ LogicalResult handleCallOp(
std::map<BatchCacheKey, FunctionOpInterface> &batchedFunctionCache);

template <typename T>
LogicalResult batchOperation(
absl::StatusOr<func::CallOp> batchOperation(
SymbolTableCollection &symbolTable, T CI,
std::map<BatchCacheKey, FunctionOpInterface> &batchedFunctionCache);

template <typename T>
LogicalResult batchOperation(
absl::StatusOr<func::CallOp> batchOperation(
T CI, FunctionOpInterface fn,
std::map<BatchCacheKey, FunctionOpInterface> &batchedFunctionCache);

Expand Down
9 changes: 9 additions & 0 deletions enzyme/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,12 @@ load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories()

# Abseil C++ library
http_archive(
name = "com_google_absl",
sha256 = "733726b8c3a6d39a4120d7e45ea8b41a434cdacde401cba500f14236c49b39dc",
strip_prefix = "abseil-cpp-20240116.2",
urls = [
"https://github.com/abseil/abseil-cpp/releases/download/20240116.2/abseil-cpp-20240116.2.tar.gz",
],
)
Loading