Update documentation for custom rewrite specs.

PiperOrigin-RevId: 265485862
This commit is contained in:
MLIR Team 2019-08-26 10:27:38 -07:00 committed by A. Unique TensorFlower
parent 6a501e3d1b
commit cb8c451541
1 changed files with 7 additions and 5 deletions

View File

@ -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<Value *> operands,
ArrayRef<Attribute> attrs,
PatternRewriter &rewriter) {
static Value* createTFLLeakyRelu(PatternRewriter &rewriter, Operation *op,
Value* operand, Attribute attr) {
return rewriter.create<mlir::TFL::LeakyReluOp>(
op->getLoc(), operands[0]->getType(), /*arg=*/operands[0],
/*alpha=*/attrs[0].cast<FloatAttr>());