test-create-mask.mlir 6.83 KB
// 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() {
  %c0 = constant 0 : index
  %c1 = constant 1 : index
  %c2 = constant 2 : index
  %c3 = constant 3 : index
  %c6 = constant 6 : index

  //
  // 1-D.
  //

  %1 = vector.create_mask %c2 : vector<5xi1>
  vector.print %1 : vector<5xi1>
  // CHECK: ( 1, 1, 0, 0, 0 )

  scf.for %i = %c0 to %c6 step %c1 {
    %2 = vector.create_mask %i : vector<5xi1>
    vector.print %2 : vector<5xi1>
  }
  // CHECK: ( 0, 0, 0, 0, 0 )
  // CHECK: ( 1, 0, 0, 0, 0 )
  // CHECK: ( 1, 1, 0, 0, 0 )
  // CHECK: ( 1, 1, 1, 0, 0 )
  // CHECK: ( 1, 1, 1, 1, 0 )
  // CHECK: ( 1, 1, 1, 1, 1 )

  //
  // 2-D.
  //

  %3 = vector.create_mask %c2, %c3 : vector<5x5xi1>
  vector.print %3 : vector<5x5xi1>
  // CHECK: ( ( 1, 1, 1, 0, 0 ), ( 1, 1, 1, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )

  %4 = vector.create_mask %c3, %c2 : vector<5x5xi1>
  vector.print %4 : vector<5x5xi1>
  // CHECK: ( ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )

  scf.for %i = %c0 to %c6 step %c1 {
    %5 = vector.create_mask %c2, %i : vector<5x5xi1>
    vector.print %5 : vector<5x5xi1>
  }
  // CHECK: ( ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0,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( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
  // CHECK: ( ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
  // CHECK: ( ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ) )

  scf.for %i = %c0 to %c6 step %c1 {
    scf.for %j = %c0 to %c6 step %c1 {
      %7 = vector.create_mask %i, %j : vector<5x5xi1>
      vector.print %7 : vector<5x5xi1>
    }
  }
  // CHECK: ( ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
  // CHECK: ( ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
  // CHECK: ( ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
  // CHECK: ( ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
  // CHECK: ( ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
  // CHECK: ( ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
  // CHECK: ( ( 0, 0, 0, 0, 0 ), ( 0,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