#pragma once #include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/IR/Operation.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/Value.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "src/Compiler/CompilerOptions.hpp" const llvm::StringRef PimConstantShouldAllocateAttrName = "pim.constant.should_allocate"; inline constexpr llvm::StringRef PimWeightAlwaysAttrName = "weightAlways"; namespace onnx_mlir { std::string getOutputDir(); void createDirectory(const std::string& directory); void dumpModule(mlir::ModuleOp moduleOp, const std::string& name); llvm::FailureOr getPimEntryFunc(mlir::ModuleOp moduleOp); bool hasWeightAlways(mlir::Operation* op); void markWeightAlways(mlir::Operation* op); mlir::memref::GlobalOp lookupGlobalForGetGlobal(mlir::ModuleOp moduleOp, mlir::memref::GetGlobalOp getGlobalOp); llvm::FailureOr getOtherEndOfChannel(mlir::Operation* op, bool opIsReceive, mlir::RewriterBase& rewriter); llvm::SmallVector computeRowMajorStrides(llvm::ArrayRef shape); llvm::SmallVector delinearizeIndex(int64_t linearIndex, llvm::ArrayRef shape, llvm::ArrayRef strides); int64_t linearizeIndex(llvm::ArrayRef indices, llvm::ArrayRef strides); int64_t getNumElements(llvm::ArrayRef shape); bool isMemoryContiguous(llvm::ArrayRef srcShape, llvm::ArrayRef offsets, llvm::ArrayRef sizes, llvm::ArrayRef strides); } // namespace onnx_mlir