Refactor PIM/Common (splitting in files, adding helpers, adding brief
Some checks failed
Validate Operations / validate-operations (push) Failing after 18m36s
Some checks failed
Validate Operations / validate-operations (push) Failing after 18m36s
docs)
This commit is contained in:
41
src/PIM/Common/Support/Diagnostics.cpp
Normal file
41
src/PIM/Common/Support/Diagnostics.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
|
||||
#include "src/Accelerators/PIM/Common/Support/Diagnostics.hpp"
|
||||
|
||||
namespace onnx_mlir::pim {
|
||||
|
||||
mlir::InFlightDiagnostic emitUnsupportedStaticShapeDiagnostic(mlir::Operation* op, llvm::StringRef valueDescription) {
|
||||
return op->emitOpError() << "requires statically shaped " << valueDescription;
|
||||
}
|
||||
|
||||
mlir::InFlightDiagnostic emitUnsupportedRankDiagnostic(mlir::Operation* op,
|
||||
llvm::StringRef valueDescription,
|
||||
int64_t actualRank,
|
||||
llvm::ArrayRef<int64_t> supportedRanks) {
|
||||
auto diag = op->emitOpError() << "has unsupported rank " << actualRank << " for " << valueDescription;
|
||||
if (supportedRanks.empty())
|
||||
return diag;
|
||||
|
||||
diag << "; supported rank";
|
||||
if (supportedRanks.size() != 1)
|
||||
diag << 's';
|
||||
diag << ' ';
|
||||
|
||||
llvm::interleaveComma(supportedRanks, diag, [&](int64_t rank) { diag << rank; });
|
||||
return diag;
|
||||
}
|
||||
|
||||
mlir::InFlightDiagnostic
|
||||
emitMissingSymbolDiagnostic(mlir::Operation* op, llvm::StringRef symbolKind, llvm::StringRef symbolName) {
|
||||
return op->emitOpError() << "references missing " << symbolKind << " `" << symbolName << "`";
|
||||
}
|
||||
|
||||
mlir::LogicalResult emitFileSystemError(mlir::Location loc,
|
||||
llvm::StringRef action,
|
||||
llvm::StringRef path,
|
||||
const std::error_code& errorCode) {
|
||||
mlir::emitError(loc) << "failed to " << action << " `" << path << "`: " << errorCode.message();
|
||||
return mlir::failure();
|
||||
}
|
||||
|
||||
} // namespace onnx_mlir::pim
|
||||
Reference in New Issue
Block a user