34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "mlir/Dialect/Arith/IR/Arith.h"
|
|
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
|
#include "mlir/IR/PatternMatch.h"
|
|
#include "mlir/IR/Value.h"
|
|
#include "mlir/Transforms/FoldUtils.h"
|
|
|
|
#include <optional>
|
|
|
|
namespace onnx_mlir {
|
|
|
|
mlir::Block* getConstantInsertionBlock(mlir::Operation* anchorOp);
|
|
|
|
mlir::Value
|
|
getOrCreateConstant(mlir::OperationFolder& folder, mlir::Operation* anchorOp, mlir::Attribute value, mlir::Type type);
|
|
|
|
mlir::Value
|
|
getOrCreateConstant(mlir::RewriterBase& rewriter, mlir::Operation* anchorOp, mlir::Attribute value, mlir::Type type);
|
|
|
|
mlir::Value getOrCreateConstantLike(mlir::OperationFolder& folder, mlir::arith::ConstantOp constantOp);
|
|
|
|
mlir::Value getOrCreateIndexConstant(mlir::OperationFolder& folder, mlir::Operation* anchorOp, int64_t value);
|
|
|
|
mlir::Value getOrCreateIndexConstant(mlir::RewriterBase& rewriter, mlir::Operation* anchorOp, int64_t value);
|
|
|
|
void hoistAndUniquifyIndexConstants(mlir::func::FuncOp funcOp, mlir::RewriterBase& rewriter);
|
|
|
|
std::optional<int64_t> matchConstantIndexValue(mlir::Value value);
|
|
|
|
std::optional<int64_t> matchConstantIndexValue(mlir::OpFoldResult value);
|
|
|
|
} // namespace onnx_mlir
|