diff options
| author | Nicolas Vasilache <ntv@google.com> | 2019-08-09 05:58:19 -0700 |
|---|---|---|
| committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-08-09 05:58:47 -0700 |
| commit | 39f1b9a053a38c8acafbc0244028c0e9d665f63b (patch) | |
| tree | 16209966168c3d7d1cf17cd460192930b38f5a13 /mlir/test/Dialect/VectorOps | |
| parent | 92dc127ab347cbc4cb4b93db04109eea2a3c13e3 (diff) | |
| download | bcm5719-llvm-39f1b9a053a38c8acafbc0244028c0e9d665f63b.tar.gz bcm5719-llvm-39f1b9a053a38c8acafbc0244028c0e9d665f63b.zip | |
Add a higher-order vector.extractelement operation in MLIR
This CL is step 2/n towards building a simple, programmable and portable vector abstraction in MLIR that can go all the way down to generating assembly vector code via LLVM's opt and llc tools.
This CL adds the vector.extractelement operation to the MLIR vector dialect as well as the appropriate roundtrip test. Lowering to LLVM will occur in the following CL.
PiperOrigin-RevId: 262545089
Diffstat (limited to 'mlir/test/Dialect/VectorOps')
| -rw-r--r-- | mlir/test/Dialect/VectorOps/invalid.mlir | 37 | ||||
| -rw-r--r-- | mlir/test/Dialect/VectorOps/ops.mlir | 12 |
2 files changed, 49 insertions, 0 deletions
diff --git a/mlir/test/Dialect/VectorOps/invalid.mlir b/mlir/test/Dialect/VectorOps/invalid.mlir new file mode 100644 index 00000000000..49fcefc475c --- /dev/null +++ b/mlir/test/Dialect/VectorOps/invalid.mlir @@ -0,0 +1,37 @@ +// RUN: mlir-opt %s -split-input-file -verify-diagnostics + +// ----- + +// CHECK-LABEL: position_empty +func @position_empty(%arg0: vector<4x8x16xf32>) { + // expected-error@+1 {{expected non-empty position attribute}} + %1 = vector.extractelement %arg0[] : vector<4x8x16xf32> + return +} + +// ----- + +// CHECK-LABEL: position_rank_overflow +func @position_rank_overflow(%arg0: vector<4x8x16xf32>) { + // expected-error@+1 {{expected position attribute of rank smaller than vector}} + %1 = vector.extractelement %arg0[0 : i32, 0 : i32, 0 : i32, 0 : i32] : vector<4x8x16xf32> + return +} + +// ----- + +// CHECK-LABEL: position_overflow +func @position_overflow(%arg0: vector<4x8x16xf32>) { + // expected-error@+1 {{expected position attribute #2 to be a positive integer smaller than the corresponding vector dimension}} + %1 = vector.extractelement %arg0[0 : i32, 43 : i32, 0 : i32] : vector<4x8x16xf32> + return +} + +// ----- + +// CHECK-LABEL: position_underflow +func @position_overflow(%arg0: vector<4x8x16xf32>) { + // expected-error@+1 {{expected position attribute #3 to be a positive integer smaller than the corresponding vector dimension}} + %1 = vector.extractelement %arg0[0 : i32, 0 : i32, -1 : i32] : vector<4x8x16xf32> + return +} diff --git a/mlir/test/Dialect/VectorOps/ops.mlir b/mlir/test/Dialect/VectorOps/ops.mlir new file mode 100644 index 00000000000..11928adda8f --- /dev/null +++ b/mlir/test/Dialect/VectorOps/ops.mlir @@ -0,0 +1,12 @@ +// RUN: mlir-opt %s | mlir-opt | FileCheck %s + +// CHECK-LABEL: extractelement +func @extractelement(%arg0: vector<4x8x16xf32>) -> (vector<8x16xf32>, vector<16xf32>, f32) { + // CHECK: vector.extractelement {{.*}}[3 : i32] : vector<4x8x16xf32> + %1 = vector.extractelement %arg0[3 : i32] : vector<4x8x16xf32> + // CHECK-NEXT: vector.extractelement {{.*}}[3 : i32, 3 : i32] : vector<4x8x16xf32> + %2 = vector.extractelement %arg0[3 : i32, 3 : i32] : vector<4x8x16xf32> + // CHECK-NEXT: vector.extractelement {{.*}}[3 : i32, 3 : i32, 3 : i32] : vector<4x8x16xf32> + %3 = vector.extractelement %arg0[3 : i32, 3 : i32, 3 : i32] : vector<4x8x16xf32> + return %1, %2, %3 : vector<8x16xf32>, vector<16xf32>, f32 +}
\ No newline at end of file |

