|
1 |
| -// RUN: mlir-opt %s --transform-interpreter -canonicalize -cse -split-input-file | FileCheck %s |
| 1 | +// RUN: mlir-opt %s --transform-interpreter -canonicalize -cse -split-input-file -verify-diagnostics | FileCheck %s |
2 | 2 |
|
3 | 3 | // Offset per thread:
|
4 | 4 | // CHECK-DAG: affine_map<(d0)[s0] -> (d0 * (s0 ceildiv 10))>
|
@@ -451,3 +451,128 @@ module attributes {transform.with_named_sequence} {
|
451 | 451 | }
|
452 | 452 | }
|
453 | 453 |
|
| 454 | +// ----- |
| 455 | + |
| 456 | +// CHECK-DAG: #[[$map0:.+]] = affine_map<()[s0] -> (s0 ceildiv 10)> |
| 457 | +// CHECK-DAG: #[[$map1:.+]] = affine_map<()[s0] -> (s0 ceildiv 20)> |
| 458 | +// CHECK-DAG: #[[$map2:.+]] = affine_map<(d0)[s0] -> (d0 * -10 + s0, 10)> |
| 459 | +// CHECK-DAG: #[[$map4:.+]] = affine_map<(d0)[s0] -> (d0 * -20 + s0, 20)> |
| 460 | +// CHECK-DAG: #[[$map5:.+]] = affine_map<(d0) -> (d0 * 10)> |
| 461 | +// CHECK-DAG: #[[$map6:.+]] = affine_map<(d0) -> (d0 * 20)> |
| 462 | + |
| 463 | +// CHECK-LABEL: matmul_tile_size_dynamic_param( |
| 464 | +// CHECK-SAME: %[[A:[0-9a-z]+]]: tensor<?x?xf32> |
| 465 | +// CHECK-SAME: %[[B:[0-9a-z]+]]: tensor<?x?xf32> |
| 466 | +// CHECK-SAME: %[[C:[0-9a-z]+]]: tensor<?x?xf32> |
| 467 | +func.func @matmul_tile_size_dynamic_param(%A: tensor<?x?xf32>, %B: tensor<?x?xf32>, %C: tensor<?x?xf32>) -> tensor<?x?xf32> { |
| 468 | + // CHECK: %[[M:.+]] = tensor.dim %[[A]], %c0 : |
| 469 | + // CHECK: %[[N:.+]] = tensor.dim %[[B]], %c1 : |
| 470 | + // CHECK: %[[NT0:.+]] = affine.apply #map()[%[[M]]] |
| 471 | + // CHECK: %[[NT1:.+]] = affine.apply #map1()[%[[N]]] |
| 472 | + // CHECK: scf.forall (%[[IV0:.+]], %[[IV1:.+]]) in (%[[NT0]], %[[NT1]]) shared_outs(%[[C_BLK:.*]] = %[[C]]) |
| 473 | + // CHECK: %[[TS0:.+]] = affine.min #[[$map2]](%[[IV0]])[%[[M]]] |
| 474 | + // CHECK: %[[TS1:.+]] = affine.min #[[$map4]](%[[IV1]])[%[[N]]] |
| 475 | + // CHECK: %[[LB0:.+]] = affine.apply #[[$map5]](%[[IV0]]) |
| 476 | + // CHECK: %[[LB1:.+]] = affine.apply #[[$map6]](%[[IV1]]) |
| 477 | + // CHECK: tensor.extract_slice %[[A]] |
| 478 | + // CHECK: tensor.extract_slice %[[B]] |
| 479 | + // CHECK: tensor.extract_slice %[[C_BLK]] |
| 480 | + // CHECK: linalg.matmul |
| 481 | + // CHECK: scf.forall.in_parallel |
| 482 | + // CHECK-NEXT: tensor.parallel_insert_slice |
| 483 | + %0 = linalg.matmul ins(%A, %B : tensor<?x?xf32>, tensor<?x?xf32>) |
| 484 | + outs(%C : tensor<?x?xf32>) -> (tensor<?x?xf32>) |
| 485 | + return %0 : tensor<?x?xf32> |
| 486 | +} |
| 487 | + |
| 488 | +module attributes {transform.with_named_sequence} { |
| 489 | + transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) { |
| 490 | + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op |
| 491 | + %sz = transform.param.constant 10 : i64 -> !transform.param<i64> |
| 492 | + %1:2 = transform.structured.tile_using_forall %0 tile_sizes [%sz : !transform.param<i64>, 20] |
| 493 | + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) |
| 494 | + transform.yield |
| 495 | + } |
| 496 | +} |
| 497 | + |
| 498 | +// ----- |
| 499 | + |
| 500 | +// CHECK-DAG: #[[$map0:.+]] = affine_map<()[s0] -> (s0 ceildiv 10)> |
| 501 | +// CHECK-DAG: #[[$map1:.+]] = affine_map<()[s0] -> (s0 ceildiv 20)> |
| 502 | +// CHECK-DAG: #[[$map2:.+]] = affine_map<(d0)[s0] -> (d0 * -10 + s0, 10)> |
| 503 | +// CHECK-DAG: #[[$map4:.+]] = affine_map<(d0)[s0] -> (d0 * -20 + s0, 20)> |
| 504 | +// CHECK-DAG: #[[$map5:.+]] = affine_map<(d0) -> (d0 * 10)> |
| 505 | +// CHECK-DAG: #[[$map6:.+]] = affine_map<(d0) -> (d0 * 20)> |
| 506 | + |
| 507 | +// CHECK-LABEL: matmul_tile_size_dynamic_param( |
| 508 | +// CHECK-SAME: %[[A:[0-9a-z]+]]: tensor<?x?xf32> |
| 509 | +// CHECK-SAME: %[[B:[0-9a-z]+]]: tensor<?x?xf32> |
| 510 | +// CHECK-SAME: %[[C:[0-9a-z]+]]: tensor<?x?xf32> |
| 511 | +func.func @matmul_tile_size_dynamic_param(%A: tensor<?x?xf32>, %B: tensor<?x?xf32>, %C: tensor<?x?xf32>) -> tensor<?x?xf32> { |
| 512 | + // CHECK: %[[M:.+]] = tensor.dim %[[A]], %c0 : |
| 513 | + // CHECK: %[[N:.+]] = tensor.dim %[[B]], %c1 : |
| 514 | + // CHECK: %[[NT0:.+]] = affine.apply #map()[%[[M]]] |
| 515 | + // CHECK: %[[NT1:.+]] = affine.apply #map1()[%[[N]]] |
| 516 | + // CHECK: scf.forall (%[[IV0:.+]], %[[IV1:.+]]) in (%[[NT0]], %[[NT1]]) shared_outs(%[[C_BLK:.*]] = %[[C]]) |
| 517 | + // CHECK: %[[TS0:.+]] = affine.min #[[$map2]](%[[IV0]])[%[[M]]] |
| 518 | + // CHECK: %[[TS1:.+]] = affine.min #[[$map4]](%[[IV1]])[%[[N]]] |
| 519 | + // CHECK: %[[LB0:.+]] = affine.apply #[[$map5]](%[[IV0]]) |
| 520 | + // CHECK: %[[LB1:.+]] = affine.apply #[[$map6]](%[[IV1]]) |
| 521 | + // CHECK: tensor.extract_slice %[[A]] |
| 522 | + // CHECK: tensor.extract_slice %[[B]] |
| 523 | + // CHECK: tensor.extract_slice %[[C_BLK]] |
| 524 | + // CHECK: linalg.matmul |
| 525 | + // CHECK: scf.forall.in_parallel |
| 526 | + // CHECK-NEXT: tensor.parallel_insert_slice |
| 527 | + %0 = linalg.matmul ins(%A, %B : tensor<?x?xf32>, tensor<?x?xf32>) |
| 528 | + outs(%C : tensor<?x?xf32>) -> (tensor<?x?xf32>) |
| 529 | + return %0 : tensor<?x?xf32> |
| 530 | +} |
| 531 | + |
| 532 | +module attributes {transform.with_named_sequence} { |
| 533 | + transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) { |
| 534 | + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op |
| 535 | + %sz = transform.param.constant [10 : i64, 20 : i64] -> !transform.any_param |
| 536 | + %1:2 = transform.structured.tile_using_forall %0 tile_sizes *(%sz : !transform.any_param) |
| 537 | + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) |
| 538 | + transform.yield |
| 539 | + } |
| 540 | +} |
| 541 | + |
| 542 | +// ----- |
| 543 | + |
| 544 | +func.func @matmul_tile_size_param_not_array(%A: tensor<?x?xf32>, %B: tensor<?x?xf32>, %C: tensor<?x?xf32>) -> tensor<?x?xf32> { |
| 545 | + %0 = linalg.matmul ins(%A, %B : tensor<?x?xf32>, tensor<?x?xf32>) |
| 546 | + outs(%C : tensor<?x?xf32>) -> (tensor<?x?xf32>) |
| 547 | + return %0 : tensor<?x?xf32> |
| 548 | +} |
| 549 | + |
| 550 | +module attributes {transform.with_named_sequence} { |
| 551 | + transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) { |
| 552 | + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op |
| 553 | + %sz = transform.param.constant "[10 : i64, 20 : i64]" -> !transform.any_param |
| 554 | + // expected-error @below {{expected ArrayAttr}} |
| 555 | + %1:2 = transform.structured.tile_using_forall %0 tile_sizes *(%sz : !transform.any_param) |
| 556 | + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) |
| 557 | + transform.yield |
| 558 | + } |
| 559 | +} |
| 560 | + |
| 561 | +// ----- |
| 562 | + |
| 563 | +func.func @matmul_tile_size_param_not_array(%A: tensor<?x?xf32>, %B: tensor<?x?xf32>, %C: tensor<?x?xf32>) -> tensor<?x?xf32> { |
| 564 | + %0 = linalg.matmul ins(%A, %B : tensor<?x?xf32>, tensor<?x?xf32>) |
| 565 | + outs(%C : tensor<?x?xf32>) -> (tensor<?x?xf32>) |
| 566 | + return %0 : tensor<?x?xf32> |
| 567 | +} |
| 568 | + |
| 569 | +module attributes {transform.with_named_sequence} { |
| 570 | + transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) { |
| 571 | + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op |
| 572 | + %sz = transform.param.constant ["10", "20"] -> !transform.any_param |
| 573 | + // expected-error @below {{expected IntegerAttr}} |
| 574 | + %1:2 = transform.structured.tile_using_forall %0 tile_sizes *(%sz : !transform.any_param) |
| 575 | + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) |
| 576 | + transform.yield |
| 577 | + } |
| 578 | +} |
0 commit comments