Changeset View
Changeset View
Standalone View
Standalone View
mlir/include/mlir/Transforms/FoldUtils.h
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
public: | public: | ||||
OperationFolder(MLIRContext *ctx) : interfaces(ctx) {} | OperationFolder(MLIRContext *ctx) : interfaces(ctx) {} | ||||
/// Tries to perform folding on the given `op`, including unifying | /// Tries to perform folding on the given `op`, including unifying | ||||
/// deduplicated constants. If successful, replaces `op`'s uses with | /// deduplicated constants. If successful, replaces `op`'s uses with | ||||
/// folded results, and returns success. `preReplaceAction` is invoked on `op` | /// folded results, and returns success. `preReplaceAction` is invoked on `op` | ||||
/// before it is replaced. 'processGeneratedConstants' is invoked for any new | /// before it is replaced. 'processGeneratedConstants' is invoked for any new | ||||
/// operations generated when folding. If the op was completely folded it is | /// operations generated when folding. If the op was completely folded it is | ||||
/// erased. | /// erased. If it is just updated in place, `inPlaceUpdate` is set to true. | ||||
LogicalResult | LogicalResult | ||||
tryToFold(Operation *op, | tryToFold(Operation *op, | ||||
function_ref<void(Operation *)> processGeneratedConstants = nullptr, | function_ref<void(Operation *)> processGeneratedConstants = nullptr, | ||||
function_ref<void(Operation *)> preReplaceAction = nullptr); | function_ref<void(Operation *)> preReplaceAction = nullptr, | ||||
bool *inPlaceUpdate = nullptr); | |||||
/// Notifies that the given constant `op` should be remove from this | /// Notifies that the given constant `op` should be remove from this | ||||
/// OperationFolder's internal bookkeeping. | /// OperationFolder's internal bookkeeping. | ||||
/// | /// | ||||
/// Note: this method must be called if a constant op is to be deleted | /// Note: this method must be called if a constant op is to be deleted | ||||
/// externally to this OperationFolder. `op` must be a constant op. | /// externally to this OperationFolder. `op` must be a constant op. | ||||
void notifyRemoval(Operation *op); | void notifyRemoval(Operation *op); | ||||
▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines |