mirror of
https://github.com/zama-ai/concrete.git
synced 2026-04-17 03:00:54 -04:00
feat: support GPU (bootstrapping)
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
|
||||
#include "concretelang/Conversion/Tools.h"
|
||||
#include "concretelang/Dialect/Concrete/IR/ConcreteTypes.h"
|
||||
|
||||
mlir::LogicalResult insertForwardDeclaration(mlir::Operation *op,
|
||||
mlir::OpBuilder &rewriter,
|
||||
@@ -35,3 +36,27 @@ mlir::LogicalResult insertForwardDeclaration(mlir::Operation *op,
|
||||
mlir::SymbolTable::lookupSymbolIn(module, funcName)));
|
||||
return mlir::success();
|
||||
}
|
||||
|
||||
/// Returns the value of the context argument from the enclosing func
|
||||
mlir::Value getContextArgument(mlir::Operation *op) {
|
||||
mlir::Block *block = op->getBlock();
|
||||
while (block != nullptr) {
|
||||
if (llvm::isa<mlir::func::FuncOp>(block->getParentOp())) {
|
||||
|
||||
auto context = std::find_if(
|
||||
block->getArguments().rbegin(), block->getArguments().rend(),
|
||||
[](mlir::BlockArgument &arg) {
|
||||
return arg.getType()
|
||||
.isa<mlir::concretelang::Concrete::ContextType>();
|
||||
});
|
||||
|
||||
assert(context != block->getArguments().rend() &&
|
||||
"Cannot find the Concrete.context");
|
||||
|
||||
return *context;
|
||||
}
|
||||
block = block->getParentOp()->getBlock();
|
||||
}
|
||||
assert("can't find a function that enclose the op");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user