brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 6a52360 Raw
57 lines · plain
1// RUN: mlir-opt %s -test-lower-to-llvm  | \2// RUN: mlir-runner -e entry -entry-point-result=void  \3// RUN:   -shared-libs=%mlir_c_runner_utils | \4// RUN: FileCheck %s5 6func.func @entry() {7  // Construct test vector.8  %f1 = arith.constant 1.5: f649  %f2 = arith.constant 2.0: f6410  %f3 = arith.constant 3.0: f6411  %f4 = arith.constant 4.0: f6412  %f5 = arith.constant 5.0: f6413  %f6 = arith.constant -1.0: f6414  %f7 = arith.constant -2.0: f6415  %f8 = arith.constant -4.0: f6416  %f9 = arith.constant -0.25: f6417  %f10 = arith.constant -16.0: f6418  %v0 = vector.broadcast %f1 : f64 to vector<10xf64>19  %v1 = vector.insert %f2, %v0[1] : f64 into vector<10xf64>20  %v2 = vector.insert %f3, %v1[2] : f64 into vector<10xf64>21  %v3 = vector.insert %f4, %v2[3] : f64 into vector<10xf64>22  %v4 = vector.insert %f5, %v3[4] : f64 into vector<10xf64>23  %v5 = vector.insert %f6, %v4[5] : f64 into vector<10xf64>24  %v6 = vector.insert %f7, %v5[6] : f64 into vector<10xf64>25  %v7 = vector.insert %f8, %v6[7] : f64 into vector<10xf64>26  %v8 = vector.insert %f9, %v7[8] : f64 into vector<10xf64>27  %v9 = vector.insert %f10, %v8[9] : f64 into vector<10xf64>28  vector.print %v9 : vector<10xf64>29  //30  // test vector:31  //32  // CHECK: ( 1.5, 2, 3, 4, 5, -1, -2, -4, -0.25, -16 )33 34  // Various vector reductions. Not full functional unit tests, but35  // a simple integration test to see if the code runs end-to-end.36  %0 = vector.reduction <add>, %v9 : vector<10xf64> into f6437  vector.print %0 : f6438  // CHECK: -7.7539  %1 = vector.reduction <mul>, %v9 : vector<10xf64> into f6440  vector.print %1 : f6441  // CHECK: -576042  %2 = vector.reduction <minimumf>, %v9 : vector<10xf64> into f6443  vector.print %2 : f6444  // CHECK: -1645  %3 = vector.reduction <maximumf>, %v9 : vector<10xf64> into f6446  vector.print %3 : f6447  // CHECK: 548  %4 = vector.reduction <minnumf>, %v9 : vector<10xf64> into f6449  vector.print %4 : f6450  // CHECK: -1651  %5 = vector.reduction <maxnumf>, %v9 : vector<10xf64> into f6452  vector.print %5 : f6453  // CHECK: 554 55  return56}57