diff options
| author | River Riddle <riverriddle@google.com> | 2019-10-21 11:31:59 -0700 |
|---|---|---|
| committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-10-21 11:32:39 -0700 |
| commit | 4514cdd5eb4844e10790580ab8df9bce433cbe6e (patch) | |
| tree | 834b1b0f38ad75089b47280c2789c9d9347eb21e /mlir/examples | |
| parent | 941a1c43320afed13bc964452cef3eeafa93a48c (diff) | |
| download | bcm5719-llvm-4514cdd5eb4844e10790580ab8df9bce433cbe6e.tar.gz bcm5719-llvm-4514cdd5eb4844e10790580ab8df9bce433cbe6e.zip | |
Cleanup and rewrite Ch-4.md.
This change rewrites Ch-4.md to introduced interfaces in a detailed step-by-step manner, adds examples, and fixes some errors.
PiperOrigin-RevId: 275887017
Diffstat (limited to 'mlir/examples')
| -rw-r--r-- | mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.td | 7 | ||||
| -rw-r--r-- | mlir/examples/toy/Ch4/toyc.cpp | 1 | ||||
| -rw-r--r-- | mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.td | 7 | ||||
| -rw-r--r-- | mlir/examples/toy/Ch5/toyc.cpp | 1 | ||||
| -rw-r--r-- | mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.td | 5 | ||||
| -rw-r--r-- | mlir/examples/toy/Ch6/toyc.cpp | 1 |
6 files changed, 20 insertions, 2 deletions
diff --git a/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.td b/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.td index 4b1240d28d5..4958b01fd27 100644 --- a/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.td +++ b/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.td @@ -1,4 +1,4 @@ -//===- ShapeInferenceInterface.td - Operation Interface for Shape Inference ----------*- tablegen -*-===// +//===- ShapeInferenceInterface.td - Shape Inference Interface -*- tablegen -==// // // Copyright 2019 The MLIR Authors. // @@ -29,6 +29,11 @@ include "mlir/IR/OpBase.td" #endif // OP_BASE def ShapeInferenceOpInterface : OpInterface<"ShapeInference"> { + let description = [{ + Interface to access a registered method to infer the return types for an + operation that can be used during type inference. + }]; + let methods = [ InterfaceMethod<"Infer and set the output shape for the current operation.", "void", "inferShapes"> diff --git a/mlir/examples/toy/Ch4/toyc.cpp b/mlir/examples/toy/Ch4/toyc.cpp index ac73236fe31..3dd079d7798 100644 --- a/mlir/examples/toy/Ch4/toyc.cpp +++ b/mlir/examples/toy/Ch4/toyc.cpp @@ -132,6 +132,7 @@ int dumpMLIR() { // the operations. pm.addPass(mlir::toy::createShapeInferencePass()); pm.addPass(mlir::createCanonicalizerPass()); + pm.addPass(mlir::createCSEPass()); if (mlir::failed(pm.run(*module))) return 4; diff --git a/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.td b/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.td index 4b1240d28d5..4958b01fd27 100644 --- a/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.td +++ b/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.td @@ -1,4 +1,4 @@ -//===- ShapeInferenceInterface.td - Operation Interface for Shape Inference ----------*- tablegen -*-===// +//===- ShapeInferenceInterface.td - Shape Inference Interface -*- tablegen -==// // // Copyright 2019 The MLIR Authors. // @@ -29,6 +29,11 @@ include "mlir/IR/OpBase.td" #endif // OP_BASE def ShapeInferenceOpInterface : OpInterface<"ShapeInference"> { + let description = [{ + Interface to access a registered method to infer the return types for an + operation that can be used during type inference. + }]; + let methods = [ InterfaceMethod<"Infer and set the output shape for the current operation.", "void", "inferShapes"> diff --git a/mlir/examples/toy/Ch5/toyc.cpp b/mlir/examples/toy/Ch5/toyc.cpp index e4157ea57c4..9b47b43812f 100644 --- a/mlir/examples/toy/Ch5/toyc.cpp +++ b/mlir/examples/toy/Ch5/toyc.cpp @@ -137,6 +137,7 @@ int dumpMLIR() { // the operations. pm.addPass(mlir::toy::createShapeInferencePass()); pm.addPass(mlir::createCanonicalizerPass()); + pm.addPass(mlir::createCSEPass()); } if (isLoweringToAffine) { diff --git a/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.td b/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.td index 19e70e60327..4958b01fd27 100644 --- a/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.td +++ b/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.td @@ -29,6 +29,11 @@ include "mlir/IR/OpBase.td" #endif // OP_BASE def ShapeInferenceOpInterface : OpInterface<"ShapeInference"> { + let description = [{ + Interface to access a registered method to infer the return types for an + operation that can be used during type inference. + }]; + let methods = [ InterfaceMethod<"Infer and set the output shape for the current operation.", "void", "inferShapes"> diff --git a/mlir/examples/toy/Ch6/toyc.cpp b/mlir/examples/toy/Ch6/toyc.cpp index a40056bb646..018dd0f8236 100644 --- a/mlir/examples/toy/Ch6/toyc.cpp +++ b/mlir/examples/toy/Ch6/toyc.cpp @@ -151,6 +151,7 @@ int loadAndProcessMLIR(mlir::MLIRContext &context, // the operations. pm.addPass(mlir::toy::createShapeInferencePass()); pm.addPass(mlir::createCanonicalizerPass()); + pm.addPass(mlir::createCSEPass()); } if (isLoweringToAffine) { |

