In parallel to the microbenchmarking effort for the Vector dialect (see AVX512 case study under Talks - MLIR), Nicolas and I wrote a test suite of “integration” tests for most of the Vector dialect operations. The test suite currently consists of tests for broadcast, constant-mask, contraction, create-mask, extract-slices, extract-strided-slice, flat-transpose-col/row, fma, insert-slices, insert-strided-slice, matrix-multiply-col/row, outer product, reductions, shape-cast, shuffle, transfer-read, transfer-write, and transpose.
Each test sets up test vectors, performs various different forms of one particular operation, and, driven by a RUN command line (mlir-opt/mlir-cpu-runner and small runtime support library for printing), verifies the result using vector.print and CHECK. An example is shown below. These tests serve several purposes:
- verify that the lowering to LLVM IR for CPU yields correct code
- ensure future changes do not break the lowering
- supplement the documentation with real-working and illustrative examples
- provide a test suite for other lowering paths
As such, I would really like to move this suite from a closed repository into the MLIR repository. This way, others can benefit from and contribute to the suite. Only small vectors are tested, keeping the suite’s running overhead very light.
Questions.
- is there an interest in such a suite?
- what would be a good place to put the suite?
Some suggestions for such a location:
llvm/llvm-project/mlir/test/mlir-cpu-runner/vector
llvm/llvm-project/mlir/test/Dialect/Vector/integration
llvm/llvm-project/mlir/test/Target/CPU/vector
SAMPLE TEST
// RUN: mlir-opt %s ... | mlir-cpu-runner ... | FileCheck %s func @entry() { %f1 = constant 1.0: f32 %f2 = constant 2.0: f32 %v1 = vector.broadcast %f1 : f32 to vector<2x4xf32> %v2 = vector.broadcast %f2 : f32 to vector<2x4xf32> vector.print %v1 : vector<2x4xf32> vector.print %v2 : vector<2x4xf32> // // test vectors: // // CHECK: ( ( 1, 1, 1, 1 ), ( 1, 1, 1, 1 ) ) // CHECK: ( ( 2, 2, 2, 2 ), ( 2, 2, 2, 2 ) ) %v3 = vector.shuffle %v1, %v2 [3, 1, 2] : vector<2x4xf32>, vector<2x4xf32> vector.print %v3 : vector<3x4xf32> // CHECK: ( ( 2, 2, 2, 2 ), ( 1, 1, 1, 1 ), ( 2, 2, 2, 2 ) ) return }