fix output paths
add gemm test
This commit is contained in:
@@ -1,17 +1,40 @@
|
||||
#include "llvm/Support/raw_os_ostream.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
#include "src/Accelerators/PIM/Common/PIMCommon.hpp"
|
||||
#include "src/Accelerators/PIM/Dialect/Spatial/SpatialOps.hpp"
|
||||
#include "src/Compiler/CompilerOptions.hpp"
|
||||
|
||||
using namespace mlir;
|
||||
|
||||
namespace onnx_mlir {
|
||||
|
||||
llvm::FailureOr<Operation *> getOtherEndOfChannel(
|
||||
Operation *op, bool opIsReceive, RewriterBase &rewriter) {
|
||||
std::string getOutputDir() { return outputBaseName.substr(0, outputBaseName.find_last_of('/')); }
|
||||
|
||||
void createDirectory(const std::string& directory) {
|
||||
std::error_code errorCode;
|
||||
std::filesystem::create_directories(directory, errorCode);
|
||||
assert(!errorCode && ("Failed to create directory: " + errorCode.message()).data());
|
||||
}
|
||||
|
||||
void dumpModule(ModuleOp moduleOp, const std::string& name) {
|
||||
std::string dialectsDir = getOutputDir() + "/dialects";
|
||||
createDirectory(dialectsDir);
|
||||
|
||||
std::fstream file(dialectsDir + "/" + name + ".mlir", std::ios::out);
|
||||
llvm::raw_os_ostream os(file);
|
||||
os << *moduleOp;
|
||||
os.flush();
|
||||
file.close();
|
||||
}
|
||||
|
||||
FailureOr<Operation*> getOtherEndOfChannel(Operation* op, bool opIsReceive, RewriterBase& rewriter) {
|
||||
|
||||
auto channelNewOp = op->getOperand(0).getDefiningOp<spatial::SpatChannelNewOp>();
|
||||
if (!channelNewOp) {
|
||||
op->emitError(
|
||||
"User of Channel must have the first operand created by ChannelNewOp.");
|
||||
op->emitError("User of Channel must have the first operand created by ChannelNewOp.");
|
||||
return failure();
|
||||
}
|
||||
// channelNewOp should have two users: `op` and a
|
||||
@@ -35,12 +58,14 @@ llvm::FailureOr<Operation *> getOtherEndOfChannel(
|
||||
"more than two found.");
|
||||
return failure();
|
||||
}
|
||||
Operation *notOpUser;
|
||||
Operation* notOpUser;
|
||||
if (firstUser == op) {
|
||||
notOpUser = secondUser;
|
||||
} else if (secondUser == op) {
|
||||
}
|
||||
else if (secondUser == op) {
|
||||
notOpUser = firstUser;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
op->emitError("Operand generated by ChannelNewOp must have two users, "
|
||||
"and one of them must be me, but"
|
||||
"none of them is actually me.");
|
||||
@@ -54,7 +79,8 @@ llvm::FailureOr<Operation *> getOtherEndOfChannel(
|
||||
return failure();
|
||||
}
|
||||
return notOpUser;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (!isa<spatial::SpatChannelReceiveOp>(notOpUser)) {
|
||||
op->emitError("Operand generated by ChannelNewOp has two user, one is "
|
||||
"me, the other is not a ChannelReceiveOp.");
|
||||
@@ -64,4 +90,4 @@ llvm::FailureOr<Operation *> getOtherEndOfChannel(
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace onnx_mlir
|
||||
} // namespace onnx_mlir
|
||||
|
||||
@@ -3,14 +3,22 @@
|
||||
#include "mlir/IR/Operation.h"
|
||||
#include "mlir/IR/PatternMatch.h"
|
||||
#include "mlir/IR/Value.h"
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
|
||||
const llvm::StringRef PIM_CONSTANT_SHOULD_ALLOCATE_ATTR_NAME =
|
||||
"pim.constant.should_allocate";
|
||||
#include "src/Compiler/CompilerOptions.hpp"
|
||||
|
||||
const llvm::StringRef PIM_CONSTANT_SHOULD_ALLOCATE_ATTR_NAME = "pim.constant.should_allocate";
|
||||
|
||||
namespace onnx_mlir {
|
||||
|
||||
llvm::FailureOr<mlir::Operation *> getOtherEndOfChannel(
|
||||
mlir::Operation *op, bool opIsReceive, mlir::RewriterBase &rewriter);
|
||||
std::string getOutputDir();
|
||||
|
||||
} // namespace onnx_mlir
|
||||
void createDirectory(const std::string &directory);
|
||||
|
||||
void dumpModule(mlir::ModuleOp moduleOp, const std::string &name);
|
||||
|
||||
llvm::FailureOr<mlir::Operation*>
|
||||
getOtherEndOfChannel(mlir::Operation* op, bool opIsReceive, mlir::RewriterBase& rewriter);
|
||||
|
||||
} // namespace onnx_mlir
|
||||
|
||||
Reference in New Issue
Block a user