File: vector-scalable-create-mask-lowering.mlir

package info (click to toggle)
swiftlang 6.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,604 kB
  • sloc: cpp: 9,901,740; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (42 lines) | stat: -rw-r--r-- 1,984 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// RUN: mlir-opt %s --transform-interpreter | FileCheck %s

// CHECK-LABEL: func.func @create_mask_2d_trailing_scalable(
// CHECK-SAME: %[[arg:.*]]: index) -> vector<3x[4]xi1> {
// CHECK-DAG: %[[zero_mask_1d:.*]] = arith.constant dense<false> : vector<[4]xi1>
// CHECK-DAG: %[[zero_mask_2d:.*]] = arith.constant dense<false> : vector<3x[4]xi1>
// CHECK-NEXT: %[[create_mask_1d:.*]] = vector.create_mask %[[arg]] : vector<[4]xi1>
// CHECK-NEXT: %[[res_0:.*]] = vector.insert %[[create_mask_1d]], %[[zero_mask_2d]] [0] : vector<[4]xi1> into vector<3x[4]xi1>
// CHECK-NEXT: %[[res_1:.*]] = vector.insert %[[create_mask_1d]], %[[res_0]] [1] : vector<[4]xi1> into vector<3x[4]xi1>
// CHECK-NEXT: %[[res_2:.*]] = vector.insert %[[zero_mask_1d]], %[[res_1]] [2] : vector<[4]xi1> into vector<3x[4]xi1>
// CHECK-NEXT: return %[[res_2]] : vector<3x[4]xi1>
func.func @create_mask_2d_trailing_scalable(%a: index) -> vector<3x[4]xi1> {
  %c2 = arith.constant 2 : index
  %mask = vector.create_mask %c2, %a : vector<3x[4]xi1>
  return %mask : vector<3x[4]xi1>
}

// -----

/// The following cannot be lowered as the current lowering requires unrolling
/// the leading dim.

// CHECK-LABEL: func.func @cannot_create_mask_2d_leading_scalable(
// CHECK-SAME: %[[arg:.*]]: index) -> vector<[4]x4xi1> {
// CHECK: %{{.*}} = vector.create_mask %[[arg]], %{{.*}} : vector<[4]x4xi1>
func.func @cannot_create_mask_2d_leading_scalable(%a: index) -> vector<[4]x4xi1> {
  %c1 = arith.constant 1 : index
  %mask = vector.create_mask %a, %c1 : vector<[4]x4xi1>
  return %mask : vector<[4]x4xi1>
}

module attributes {transform.with_named_sequence} {
  transform.named_sequence @__transform_main(%module_op: !transform.any_op {transform.readonly}) {
    %f = transform.structured.match ops{["func.func"]} in %module_op
      : (!transform.any_op) -> !transform.any_op

    transform.apply_patterns to %f {
      transform.apply_patterns.vector.lower_create_mask
    } : !transform.any_op
    transform.yield
  }
}