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:
38
src/PIM/Common/Support/Diagnostics.hpp
Normal file
38
src/PIM/Common/Support/Diagnostics.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include "mlir/IR/Diagnostics.h"
|
||||
#include "mlir/IR/Operation.h"
|
||||
#include "mlir/Support/LogicalResult.h"
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
|
||||
#include <system_error>
|
||||
|
||||
namespace onnx_mlir::pim {
|
||||
|
||||
/// Emits a consistent diagnostic for target paths that require static shapes.
|
||||
mlir::InFlightDiagnostic emitUnsupportedStaticShapeDiagnostic(mlir::Operation* op, llvm::StringRef valueDescription);
|
||||
|
||||
/// Emits a consistent diagnostic for unsupported ranks while listing the ranks
|
||||
/// accepted by the current lowering/codegen path.
|
||||
mlir::InFlightDiagnostic emitUnsupportedRankDiagnostic(mlir::Operation* op,
|
||||
llvm::StringRef valueDescription,
|
||||
int64_t actualRank,
|
||||
llvm::ArrayRef<int64_t> supportedRanks);
|
||||
|
||||
/// Emits a consistent diagnostic for missing symbol/global references.
|
||||
mlir::InFlightDiagnostic
|
||||
emitMissingSymbolDiagnostic(mlir::Operation* op, llvm::StringRef symbolKind, llvm::StringRef symbolName);
|
||||
|
||||
/// Converts a filesystem error into an MLIR failure diagnostic anchored at
|
||||
/// the relevant IR location.
|
||||
mlir::LogicalResult
|
||||
emitFileSystemError(mlir::Location loc, llvm::StringRef action, llvm::StringRef path, const std::error_code& errorCode);
|
||||
|
||||
template <typename T>
|
||||
mlir::LogicalResult failureOrToLogicalResult(const llvm::FailureOr<T>& value) {
|
||||
return mlir::success(succeeded(value));
|
||||
}
|
||||
|
||||
} // namespace onnx_mlir::pim
|
||||
Reference in New Issue
Block a user