From cb8c451541390a4096584bb1fbe9501711d67c35 Mon Sep 17 00:00:00 2001 From: MLIR Team Date: Mon, 26 Aug 2019 10:27:38 -0700 Subject: [PATCH] Update documentation for custom rewrite specs. PiperOrigin-RevId: 265485862 --- mlir/g3doc/QuickstartRewrites.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mlir/g3doc/QuickstartRewrites.md b/mlir/g3doc/QuickstartRewrites.md index 19045f6..17cc0f4 100644 --- a/mlir/g3doc/QuickstartRewrites.md +++ b/mlir/g3doc/QuickstartRewrites.md @@ -127,14 +127,16 @@ consists of defining a pattern as well as adding a C++ function to perform the replacement: ```td {.td} -def : Pat<(TF_LeakyReluOp $arg, F32Attr:$a), - (cOp<"createTFLLeakyRelu"> $arg, $a)>; +def createTFLLeakyRelu : NativeCodeCall< + "createTFLLeakyRelu($_builder, $0->getDefiningOp(), $1, $2)">; + +def : Pat<(TF_LeakyReluOp:$old_value, $arg, F32Attr:$a), + (createTFLLeakyRelu $old_value, $arg, $a)>; ``` ```c++ -static Value *createTFLLeakyRelu(Operation *op, ArrayRef operands, - ArrayRef attrs, - PatternRewriter &rewriter) { +static Value* createTFLLeakyRelu(PatternRewriter &rewriter, Operation *op, + Value* operand, Attribute attr) { return rewriter.create( op->getLoc(), operands[0]->getType(), /*arg=*/operands[0], /*alpha=*/attrs[0].cast()); -- 2.7.4