aartbik 91801a7c34 [mlir] [integration-test] [VectorOps] Start an integration test directory for MLIR
Summary:
This CL introduces an integration test directory for MLIR in general, with
vector dialect integration tests in particular as a first working suite. To
run all the integration tests (and currently just the vector suite):

$ cmake --build . --target check-mlir-integration
[0/1] Running the MLIR integration tests
Testing Time: 0.24s
Passed: 22

The general call is to contribute to this integration test directory with more
tests and other suites, running end-to-end examples that may be too heavy for
the regular test directory, but should be tested occasionally to verify the
health of MLIR.

Background discussion at:
https://llvm.discourse.group/t/vectorops-rfc-add-suite-of-integration-tests-for-vector-dialect-operations/1213/

Reviewers: nicolasvasilache, reidtatge, andydavis1, rriddle, ftynse, mehdi_amini, jpienaar, stephenneuendorffer

Reviewed By: nicolasvasilache, stephenneuendorffer

Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, msifontes

Tags: #mlir

Differential Revision: https://reviews.llvm.org/D81626
2020-06-15 11:05:58 -07:00

45 lines
1.6 KiB
MLIR

// RUN: mlir-opt %s -convert-scf-to-std -convert-vector-to-llvm -convert-std-to-llvm | \
// RUN: mlir-cpu-runner -e entry -entry-point-result=void \
// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_c_runner_utils%shlibext | \
// RUN: FileCheck %s
func @entry() {
%f1 = constant 1.0: f32
%f2 = constant 2.0: f32
%f3 = constant 3.0: f32
%f4 = constant 4.0: f32
%f5 = constant 5.0: f32
%f6 = constant 6.0: f32
// Construct test vector.
%0 = vector.broadcast %f1 : f32 to vector<3x2xf32>
%1 = vector.insert %f2, %0[0, 1] : f32 into vector<3x2xf32>
%2 = vector.insert %f3, %1[1, 0] : f32 into vector<3x2xf32>
%3 = vector.insert %f4, %2[1, 1] : f32 into vector<3x2xf32>
%4 = vector.insert %f5, %3[2, 0] : f32 into vector<3x2xf32>
%x = vector.insert %f6, %4[2, 1] : f32 into vector<3x2xf32>
vector.print %x : vector<3x2xf32>
// CHECK: ( ( 1, 2 ), ( 3, 4 ), ( 5, 6 ) )
// Reshapes.
%a = vector.shape_cast %x : vector<3x2xf32> to vector<3x2xf32>
%b = vector.shape_cast %x : vector<3x2xf32> to vector<2x3xf32>
%c = vector.shape_cast %x : vector<3x2xf32> to vector<6xf32>
%d = vector.shape_cast %c : vector<6xf32> to vector<2x3xf32>
%e = vector.shape_cast %c : vector<6xf32> to vector<3x2xf32>
// Reshaped vectors:
// CHECK: ( ( 1, 2 ), ( 3, 4 ), ( 5, 6 ) )
// CHECK: ( ( 1, 2, 3 ), ( 4, 5, 6 ) )
// CHECK: ( 1, 2, 3, 4, 5, 6 )
// CHECK: ( ( 1, 2, 3 ), ( 4, 5, 6 ) )
// CHECK: ( ( 1, 2 ), ( 3, 4 ), ( 5, 6 ) )
vector.print %a : vector<3x2xf32>
vector.print %b : vector<2x3xf32>
vector.print %c : vector<6xf32>
vector.print %d : vector<2x3xf32>
vector.print %e : vector<3x2xf32>
return
}