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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745
|
// RUN: mlir-opt %s -test-linalg-greedy-fusion -split-input-file | FileCheck %s
func.func @f1(%A: memref<?x?xf32, strided<[?, 1], offset: 0>>,
%B: memref<?x?xf32, strided<[?, 1], offset: 0>>,
%C: memref<?x?xf32, strided<[?, 1], offset: 0>>,
%D: memref<?x?xf32, strided<[?, 1], offset: 0>>,
%E: memref<?x?xf32, strided<[?, 1], offset: 0>>
) -> memref<?x?xf32, strided<[?, 1], offset: 0>> {
%c0 = arith.constant 0 : index
%c4 = arith.constant 4 : index
%c3 = arith.constant 3 : index
%c2 = arith.constant 2 : index
%c1 = arith.constant 1 : index
%0 = memref.dim %A, %c0 : memref<?x?xf32, strided<[?, 1], offset: 0>>
%1 = memref.dim %A, %c1 : memref<?x?xf32, strided<[?, 1], offset: 0>>
%2 = memref.dim %B, %c1 : memref<?x?xf32, strided<[?, 1], offset: 0>>
linalg.matmul ins(%A, %B : memref<?x?xf32, strided<[?, 1], offset: 0>>,
memref<?x?xf32, strided<[?, 1], offset: 0>>)
outs(%C : memref<?x?xf32, strided<[?, 1], offset: 0>>)
scf.for %arg5 = %c0 to %0 step %c2 {
scf.for %arg6 = %c0 to %2 step %c3 {
scf.for %arg7 = %c0 to %1 step %c4 {
%5 = memref.subview %A[%arg5, %arg7][%c2, %c4][%c1, %c1] :
memref<?x?xf32, strided<[?, 1], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%7 = memref.subview %B[%arg7, %arg6][%c4, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, 1], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%8 = memref.subview %C[%arg5, %arg6][%c2, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, 1], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
linalg.matmul ins(%5, %7 : memref<?x?xf32, strided<[?, ?], offset: ?>>,
memref<?x?xf32, strided<[?, ?], offset: ?>>)
outs(%8: memref<?x?xf32, strided<[?, ?], offset: ?>>)
}
}
}
return %E : memref<?x?xf32, strided<[?, 1], offset: 0>>
}
// CHECK-LABEL: func @f1
// CHECK: (%[[A:.*]]:{{.*}}, %[[B:.*]]:{{.*}}, %[[C:.*]]:{{.*}}, %[[D:.*]]:{{.*}}, %[[E:.*]]:{{.*}})
// CHECK: scf.for
// CHECK: scf.for
// CHECK: scf.for
// CHECK: linalg.matmul
// CHECK: linalg.matmul
// -----
func.func @f2(%A: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%B: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%C: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%D: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%E: memref<?x?xf32, strided<[?, ?], offset: 0>>
) -> memref<?x?xf32, strided<[?, ?], offset: 0>> {
%c1 = arith.constant 1 : index
%c0 = arith.constant 0 : index
%c4 = arith.constant 4 : index
%c3 = arith.constant 3 : index
%c2 = arith.constant 2 : index
linalg.matmul ins(%A, %B : memref<?x?xf32, strided<[?, ?], offset: 0>>,
memref<?x?xf32, strided<[?, ?], offset: 0>>)
outs(%C: memref<?x?xf32, strided<[?, ?], offset: 0>>)
%0 = memref.dim %C, %c0 : memref<?x?xf32, strided<[?, ?], offset: 0>>
%1 = memref.dim %C, %c1 : memref<?x?xf32, strided<[?, ?], offset: 0>>
%2 = memref.dim %D, %c1 : memref<?x?xf32, strided<[?, ?], offset: 0>>
scf.for %arg5 = %c0 to %0 step %c2 {
scf.for %arg6 = %c0 to %2 step %c3 {
scf.for %arg7 = %c0 to %1 step %c4 {
%5 = memref.subview %C[%arg5, %arg7][%c2, %c4][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%7 = memref.subview %D[%arg7, %arg6][%c4, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%8 = memref.subview %E[%arg5, %arg6][%c2, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
linalg.matmul ins(%5, %7 : memref<?x?xf32, strided<[?, ?], offset: ?>>,
memref<?x?xf32, strided<[?, ?], offset: ?>>)
outs(%8 : memref<?x?xf32, strided<[?, ?], offset: ?>>)
}
}
}
return %E : memref<?x?xf32, strided<[?, ?], offset: 0>>
}
// CHECK-LABEL: func @f2
// CHECK: (%[[A:.*]]:{{.*}}, %[[B:.*]]:{{.*}}, %[[C:.*]]:{{.*}}, %[[D:.*]]:{{.*}}, %[[E:.*]]:{{.*}})
// CHECK-DAG: %[[C_0:.*]] = memref.dim %[[C]], %c0{{[_0-9]*}} : memref<?x?xf32, strided<[?, ?]>>
// CHECK-DAG: %[[C_1:.*]] = memref.dim %[[C]], %c1{{[_0-9]*}} : memref<?x?xf32, strided<[?, ?]>>
// CHECK-DAG: %[[D_1:.*]] = memref.dim %[[D]], %c1{{[_0-9]*}} : memref<?x?xf32, strided<[?, ?]>>
// CHECK: scf.for %{{.*}} = %{{.*}} to %[[C_0]] step %{{.*}} {
// CHECK: scf.for %{{.*}} = %{{.*}} to %[[D_1]] step %{{.*}} {
// CHECK: scf.for %{{.*}} = %{{.*}} to %[[C_1]] step %{{.*}} {
// CHECK: linalg.matmul
// CHECK: linalg.matmul
// -----
func.func @f3(%A: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%B: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%C: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%D: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%E: memref<?x?xf32, strided<[?, ?], offset: 0>>
) -> memref<?x?xf32, strided<[?, ?], offset: 0>> {
%c1 = arith.constant 1 : index
%c0 = arith.constant 0 : index
%c4 = arith.constant 4 : index
%c3 = arith.constant 3 : index
%c2 = arith.constant 2 : index
linalg.matmul ins(%A, %B : memref<?x?xf32, strided<[?, ?], offset: 0>>,
memref<?x?xf32, strided<[?, ?], offset: 0>>)
outs(%C : memref<?x?xf32, strided<[?, ?], offset: 0>>)
%0 = memref.dim %D, %c0 : memref<?x?xf32, strided<[?, ?], offset: 0>>
%1 = memref.dim %D, %c1 : memref<?x?xf32, strided<[?, ?], offset: 0>>
%2 = memref.dim %C, %c1 : memref<?x?xf32, strided<[?, ?], offset: 0>>
scf.for %arg5 = %c0 to %0 step %c2 {
scf.for %arg6 = %c0 to %2 step %c3 {
scf.for %arg7 = %c0 to %1 step %c4 {
%5 = memref.subview %D[%arg5, %arg7][%c2, %c4][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%7 = memref.subview %C[%arg7, %arg6][%c4, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%8 = memref.subview %E[%arg5, %arg6][%c2, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
linalg.matmul ins(%5, %7 : memref<?x?xf32, strided<[?, ?], offset: ?>>,
memref<?x?xf32, strided<[?, ?], offset: ?>>)
outs(%8 : memref<?x?xf32, strided<[?, ?], offset: ?>>)
}
}
}
return %E : memref<?x?xf32, strided<[?, ?], offset: 0>>
}
// CHECK-LABEL: func @f3
// CHECK: (%[[A:.*]]:{{.*}}, %[[B:.*]]:{{.*}}, %[[C:.*]]:{{.*}}, %[[D:.*]]:{{.*}}, %[[E:.*]]:{{.*}})
// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
// CHECK-DAG: %[[C1:.*]] = arith.constant 1 : index
// CHECK: %[[D_0:.*]] = memref.dim %[[D]], %[[C0]] : memref<?x?xf32, strided<[?, ?]>>
// CHECK: %[[D_1:.*]] = memref.dim %[[D]], %[[C1]] : memref<?x?xf32, strided<[?, ?]>>
// CHECK: %[[C_1:.*]] = memref.dim %[[C]], %[[C1]] : memref<?x?xf32, strided<[?, ?]>>
// CHECK: scf.for %{{.*}} = %{{.*}} to %[[D_0]] step %{{.*}} {
// CHECK: scf.for %{{.*}} = %{{.*}} to %[[C_1]] step %{{.*}} {
// CHECK: scf.for %{{.*}} = %{{.*}} to %[[D_1]] step %{{.*}} {
// CHECK: linalg.matmul
// CHECK: linalg.matmul
// -----
func.func @f4(%A: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%B: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%C: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%D: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%E: memref<?x?xf32, strided<[?, ?], offset: 0>>
) -> memref<?x?xf32, strided<[?, ?], offset: 0>> {
%c1 = arith.constant 1 : index
%c0 = arith.constant 0 : index
%c4 = arith.constant 4 : index
%c3 = arith.constant 3 : index
%c2 = arith.constant 2 : index
linalg.matmul ins(%A, %B : memref<?x?xf32, strided<[?, ?], offset: 0>>,
memref<?x?xf32, strided<[?, ?], offset: 0>>)
outs(%C : memref<?x?xf32, strided<[?, ?], offset: 0>>)
linalg.matmul ins(%A, %B : memref<?x?xf32, strided<[?, ?], offset: 0>>,
memref<?x?xf32, strided<[?, ?], offset: 0>>)
outs(%D : memref<?x?xf32, strided<[?, ?], offset: 0>>)
%0 = memref.dim %C, %c0 : memref<?x?xf32, strided<[?, ?], offset: 0>>
%1 = memref.dim %C, %c1 : memref<?x?xf32, strided<[?, ?], offset: 0>>
%2 = memref.dim %D, %c1 : memref<?x?xf32, strided<[?, ?], offset: 0>>
scf.for %arg5 = %c0 to %0 step %c2 {
scf.for %arg6 = %c0 to %2 step %c3 {
scf.for %arg7 = %c0 to %1 step %c4 {
%5 = memref.subview %C[%arg5, %arg7][%c2, %c4][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%7 = memref.subview %D[%arg7, %arg6][%c4, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%8 = memref.subview %E[%arg5, %arg6][%c2, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
linalg.matmul ins(%5, %7 : memref<?x?xf32, strided<[?, ?], offset: ?>>,
memref<?x?xf32, strided<[?, ?], offset: ?>>)
outs(%8 : memref<?x?xf32, strided<[?, ?], offset: ?>>)
}
}
}
return %E : memref<?x?xf32, strided<[?, ?], offset: 0>>
}
// CHECK-LABEL: func @f4
// CHECK: (%[[A:.*]]:{{.*}}, %[[B:.*]]:{{.*}}, %[[C:.*]]:{{.*}}, %[[D:.*]]:{{.*}}, %[[E:.*]]:{{.*}})
// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
// CHECK-DAG: %[[C1:.*]] = arith.constant 1 : index
// CHECK: %[[C_0:.*]] = memref.dim %[[C]], %[[C0:.*]] : memref<?x?xf32, strided<[?, ?]>>
// CHECK: %[[C_1:.*]] = memref.dim %[[C]], %[[C1:.*]] : memref<?x?xf32, strided<[?, ?]>>
// CHECK: %[[D_1:.*]] = memref.dim %[[D]], %[[C1:.*]] : memref<?x?xf32, strided<[?, ?]>>
// CHECK: scf.for %{{.*}} = %{{.*}} to %[[C_0]] step %{{.*}} {
// CHECK: scf.for %{{.*}} = %{{.*}} to %[[D_1]] step %{{.*}} {
// CHECK: scf.for %{{.*}} = %{{.*}} to %[[C_1]] step %{{.*}} {
// Fuse D then fuse C, no false dependence prevent it.
// CHECK: linalg.matmul
// CHECK: linalg.matmul
// CHECK: linalg.matmul
// -----
func.func @f5(%A: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%B: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%C: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%D: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%E: memref<?x?xf32, strided<[?, ?], offset: 0>>
) -> memref<?x?xf32, strided<[?, ?], offset: 0>> {
%c1 = arith.constant 1 : index
%c0 = arith.constant 0 : index
%c4 = arith.constant 4 : index
%c3 = arith.constant 3 : index
%c2 = arith.constant 2 : index
%0 = memref.dim %B, %c1 : memref<?x?xf32, strided<[?, ?], offset: 0>>
%1 = memref.dim %D, %c0 : memref<?x?xf32, strided<[?, ?], offset: 0>>
%2 = memref.dim %D, %c1 : memref<?x?xf32, strided<[?, ?], offset: 0>>
linalg.matmul ins(%A, %B : memref<?x?xf32, strided<[?, ?], offset: 0>>,
memref<?x?xf32, strided<[?, ?], offset: 0>>)
outs(%C : memref<?x?xf32, strided<[?, ?], offset: 0>>)
linalg.matmul ins(%C, %B : memref<?x?xf32, strided<[?, ?], offset: 0>>,
memref<?x?xf32, strided<[?, ?], offset: 0>>)
outs(%D : memref<?x?xf32, strided<[?, ?], offset: 0>>)
scf.for %arg5 = %c0 to %1 step %c2 {
scf.for %arg6 = %c0 to %0 step %c3 {
scf.for %arg7 = %c0 to %2 step %c4 {
%5 = memref.subview %D[%arg5, %arg7][%c2, %c4][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%7 = memref.subview %B[%arg7, %arg6][%c4, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%8 = memref.subview %E[%arg5, %arg6][%c2, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
linalg.matmul ins(%5, %7 : memref<?x?xf32, strided<[?, ?], offset: ?>>,
memref<?x?xf32, strided<[?, ?], offset: ?>>)
outs(%8 : memref<?x?xf32, strided<[?, ?], offset: ?>>)
}
}
}
return %E : memref<?x?xf32, strided<[?, ?], offset: 0>>
}
// CHECK-DAG: #[[BOUND_2_MAP:.+]] = affine_map<(d0)[s0] -> (-d0 + s0, 2)>
// CHECK-DAG: #[[BOUND_2_MAP_2:.+]] = affine_map<(d0)[s0, s1] -> (-d0 + s1, -d0 + s0, 2)>
// CHECK-DAG: #[[BOUND_4_MAP:.+]] = affine_map<(d0)[s0] -> (-d0 + s0, 4)>
// CHECK: func @f5
// CHECK-SAME: (%[[A:.*]]:{{.*}}, %[[B:.*]]:{{.*}}, %[[C:.*]]:{{.*}}, %[[D:.*]]:{{.*}}, %[[E:.*]]:{{.*}})
// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
// CHECK-DAG: %[[C1:.*]] = arith.constant 1 : index
// CHECK-DAG: %[[A_0:.*]] = memref.dim %[[A]], %[[C0]] : memref<?x?xf32, strided<[?, ?]>>
// CHECK-DAG: %[[B_1:.*]] = memref.dim %[[B]], %[[C1]] : memref<?x?xf32, strided<[?, ?]>>
// CHECK-DAG: %[[C_0:.*]] = memref.dim %[[C]], %[[C0]] : memref<?x?xf32, strided<[?, ?]>>
// CHECK-DAG: %[[D_0:.*]] = memref.dim %[[D]], %[[C0]] : memref<?x?xf32, strided<[?, ?]>>
// CHECK-DAG: %[[D_1:.*]] = memref.dim %[[D]], %[[C1]] : memref<?x?xf32, strided<[?, ?]>>
// CHECK-DAG: %[[B_00:.*]] = memref.subview %[[B]][0, 0]{{.*}}
// CHECK: scf.for %[[I:.*]] = %{{.*}} to %[[D_0]] step %{{.*}} {
// CHECK: %[[BOUND_2_C0:.+]] = affine.min #[[BOUND_2_MAP]](%[[I]])[%[[C_0]]]
// CHECK: %[[C_I0:.*]] = memref.subview %[[C]][%[[I]], 0] [%[[BOUND_2_C0]]
// CHECK: %[[BOUND_ID_C0:.+]] = affine.min #[[BOUND_2_MAP_2]](%[[I]])[%[[A_0]], %[[C_0]]]
// CHECK: %[[A_I0:.*]] = memref.subview %[[A]][%[[I]], 0]
// CHECK: %[[C_I0_OUT:.*]] = memref.subview %[[C]][%[[I]], 0] [%[[BOUND_ID_C0]]
// CHECK: scf.for %[[J:.*]] = %{{.*}} to %[[B_1]] step %{{.*}} {
// CHECK: %[[E_IJ:.*]] = memref.subview %[[E]][%[[I]], %[[J]]]
// CHECK: scf.for %[[K:.*]] = %{{.*}} to %[[D_1]] step %{{.*}} {
// CHECK: %[[D_IK:.*]] = memref.subview %[[D]][%[[I]], %[[K]]] [2, 4]
// CHECK: %[[B_KJ:.*]] = memref.subview %[[B]][%[[K]], %[[J]]]
// CHECK: %[[BOUND_4_B1:.*]] = affine.min #[[BOUND_4_MAP]](%[[K]])[%[[B_1]]]
// CHECK: %[[B_0K:.*]] = memref.subview %[[B]][0, %[[K]]]
// CHECK: %[[D_IK_OUT:.+]] = memref.subview %[[D]][%[[I]], %[[K]]] [%[[BOUND_2_C0]], %[[BOUND_4_B1]]]
// CHECK: linalg.matmul ins(%[[A_I0]], %[[B_00]]{{.*}} outs(%[[C_I0_OUT]]
// CHECK: linalg.matmul ins(%[[C_I0]], %[[B_0K]]{{.*}} outs(%[[D_IK_OUT]]
// CHECK: linalg.matmul ins(%[[D_IK]], %[[B_KJ]]{{.*}} outs(%[[E_IJ]]
// -----
#map0 = affine_map<(d0) -> (d0 + 2)>
#map1 = affine_map<(d0) -> (d0 + 4)>
#map2 = affine_map<(d0) -> (d0 + 3)>
func.func @f6(%A: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%B: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%C: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%D: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%E: memref<?x?xf32, strided<[?, ?], offset: 0>>
) -> memref<?x?xf32, strided<[?, ?], offset: 0>> {
%c1 = arith.constant 1 : index
%c0 = arith.constant 0 : index
%c4 = arith.constant 4 : index
%c3 = arith.constant 3 : index
%c2 = arith.constant 2 : index
%0 = memref.dim %C, %c1 : memref<?x?xf32, strided<[?, ?], offset: 0>>
linalg.matmul ins(%A, %B : memref<?x?xf32, strided<[?, ?], offset: 0>>,
memref<?x?xf32, strided<[?, ?], offset: 0>>)
outs(%C : memref<?x?xf32, strided<[?, ?], offset: 0>>)
linalg.matmul ins(%A, %C : memref<?x?xf32, strided<[?, ?], offset: 0>>,
memref<?x?xf32, strided<[?, ?], offset: 0>>)
outs(%E : memref<?x?xf32, strided<[?, ?], offset: 0>>)
%1 = memref.dim %C, %c0 : memref<?x?xf32, strided<[?, ?], offset: 0>>
%2 = memref.dim %D, %c1 : memref<?x?xf32, strided<[?, ?], offset: 0>>
scf.for %arg5 = %c0 to %1 step %c2 {
scf.for %arg6 = %c0 to %2 step %c3 {
scf.for %arg7 = %c0 to %0 step %c4 {
%3 = affine.apply #map0(%arg5)
%4 = affine.apply #map1(%arg7)
%5 = memref.subview %C[%arg5, %arg7][%c2, %c4][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%6 = affine.apply #map2(%arg6)
%7 = memref.subview %D[%arg7, %arg6][%c4, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%8 = memref.subview %E[%arg5, %arg6][%c2, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
linalg.matmul ins(%5, %7 : memref<?x?xf32, strided<[?, ?], offset: ?>>,
memref<?x?xf32, strided<[?, ?], offset: ?>>)
outs(%8 : memref<?x?xf32, strided<[?, ?], offset: ?>>)
}
}
}
return %E : memref<?x?xf32, strided<[?, ?], offset: 0>>
}
// CHECK-LABEL: func @f6
// CHECK: (%[[A:.*]]:{{.*}}, %[[B:.*]]:{{.*}}, %[[C:.*]]:{{.*}}, %[[D:.*]]:{{.*}}, %[[E:.*]]:{{.*}})
// Fuse the producer of E (WAW) then the producer of C (WAR).
// CHECK: scf.for
// CHECK: scf.for
// CHECK: scf.for
// CHECK: linalg.matmul
// CHECK: linalg.matmul
// CHECK: linalg.matmul
// -----
func.func @f7(%A: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%B: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%C: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%D: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%E: memref<?x?xf32, strided<[?, ?], offset: 0>>
) -> memref<?x?xf32, strided<[?, ?], offset: 0>> {
%c1 = arith.constant 1 : index
%c0 = arith.constant 0 : index
%c4 = arith.constant 4 : index
%c3 = arith.constant 3 : index
%c2 = arith.constant 2 : index
%0 = memref.dim %A, %c0 : memref<?x?xf32, strided<[?, ?], offset: 0>>
%1 = memref.dim %A, %c1 : memref<?x?xf32, strided<[?, ?], offset: 0>>
%2 = memref.dim %C, %c1 : memref<?x?xf32, strided<[?, ?], offset: 0>>
%3 = memref.dim %C, %c0 : memref<?x?xf32, strided<[?, ?], offset: 0>>
%4 = memref.dim %D, %c1 : memref<?x?xf32, strided<[?, ?], offset: 0>>
linalg.matmul ins(%A, %C : memref<?x?xf32, strided<[?, ?], offset: 0>>,
memref<?x?xf32, strided<[?, ?], offset: 0>>)
outs(%E : memref<?x?xf32, strided<[?, ?], offset: 0>>)
linalg.matmul ins(%A, %B : memref<?x?xf32, strided<[?, ?], offset: 0>>,
memref<?x?xf32, strided<[?, ?], offset: 0>>)
outs(%C : memref<?x?xf32, strided<[?, ?], offset: 0>>)
scf.for %arg5 = %c0 to %0 step %c2 {
scf.for %arg6 = %c0 to %2 step %c3 {
scf.for %arg7 = %c0 to %1 step %c4 {
%7 = memref.subview %A[%arg5, %arg7][%c2, %c4][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%9 = memref.subview %C[%arg7, %arg6][%c4, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%10 = memref.subview %E[%arg5, %arg6][%c2, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
linalg.matmul ins(%7, %9 : memref<?x?xf32, strided<[?, ?], offset: ?>>,
memref<?x?xf32, strided<[?, ?], offset: ?>>)
outs(%10 : memref<?x?xf32, strided<[?, ?], offset: ?>>)
}
}
}
scf.for %arg5 = %c0 to %3 step %c2 {
scf.for %arg6 = %c0 to %4 step %c3 {
scf.for %arg7 = %c0 to %2 step %c4 {
%7 = memref.subview %C[%arg5, %arg7][%c2, %c4][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%9 = memref.subview %D[%arg7, %arg6][%c4, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%10 = memref.subview %E[%arg5, %arg6][%c2, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
linalg.matmul ins(%7, %9 : memref<?x?xf32, strided<[?, ?], offset: ?>>,
memref<?x?xf32, strided<[?, ?], offset: ?>>)
outs(%10 : memref<?x?xf32, strided<[?, ?], offset: ?>>)
}
}
}
return %E : memref<?x?xf32, strided<[?, ?], offset: 0>>
}
// CHECK-LABEL: func @f7
// CHECK: (%[[A:.*]]:{{.*}}, %[[B:.*]]:{{.*}}, %[[C:.*]]:{{.*}}, %[[D:.*]]:{{.*}}, %[[E:.*]]:{{.*}})
// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
// CHECK-DAG: %[[C1:.*]] = arith.constant 1 : index
// CHECK: %[[A_0:.*]] = memref.dim %[[A]], %[[C0:.*]] : memref<?x?xf32, strided<[?, ?]>>
// CHECK: %[[A_1:.*]] = memref.dim %[[A]], %[[C1:.*]] : memref<?x?xf32, strided<[?, ?]>>
// CHECK: %[[C_1:.*]] = memref.dim %[[C]], %[[C1:.*]] : memref<?x?xf32, strided<[?, ?]>>
// CHECK: %[[C_0:.*]] = memref.dim %[[C]], %[[C0:.*]] : memref<?x?xf32, strided<[?, ?]>>
// CHECK: %[[D_1:.*]] = memref.dim %[[D]], %[[C1:.*]] : memref<?x?xf32, strided<[?, ?]>>
// CHECK: linalg.matmul ins(%[[A]], %[[C]]{{.*}} outs(%[[E]]
// CHECK: scf.for %{{.*}} = %{{.*}} to %[[A_0]] step %{{.*}} {
// CHECK: scf.for %{{.*}} = %{{.*}} to %[[C_1]] step %{{.*}} {
// CHECK: scf.for %{{.*}} = %{{.*}} to %[[A_1]] step %{{.*}} {
// CHECK: linalg.matmul
// CHECK: linalg.matmul
// CHECK: scf.for %{{.*}} = %{{.*}} to %[[C_0]] step %{{.*}} {
// CHECK: scf.for %{{.*}} = %{{.*}} to %[[D_1]] step %{{.*}} {
// CHECK: scf.for %{{.*}} = %{{.*}} to %[[C_1]] step %{{.*}} {
// CHECK: linalg.matmul
// CHECK-NOT: linalg.matmul
// -----
#map0 = affine_map<(d0) -> (d0 + 2)>
#map1 = affine_map<(d0) -> (d0 + 4)>
#map2 = affine_map<(d0) -> (d0 + 3)>
func.func @f8(%A: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%B: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%C: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%D: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%E: memref<?x?xf32, strided<[?, ?], offset: 0>>
) -> memref<?x?xf32, strided<[?, ?], offset: 0>> {
%c1 = arith.constant 1 : index
%c0 = arith.constant 0 : index
%c4 = arith.constant 4 : index
%c3 = arith.constant 3 : index
%c2 = arith.constant 2 : index
%0 = memref.dim %A, %c0 : memref<?x?xf32, strided<[?, ?], offset: 0>>
%1 = memref.dim %A, %c1 : memref<?x?xf32, strided<[?, ?], offset: 0>>
linalg.matmul ins(%A, %C : memref<?x?xf32, strided<[?, ?], offset: 0>>,
memref<?x?xf32, strided<[?, ?], offset: 0>>)
outs(%D : memref<?x?xf32, strided<[?, ?], offset: 0>>)
linalg.matmul ins(%A, %B : memref<?x?xf32, strided<[?, ?], offset: 0>>,
memref<?x?xf32, strided<[?, ?], offset: 0>>)
outs(%C : memref<?x?xf32, strided<[?, ?], offset: 0>>)
%2 = memref.dim %D, %c1 : memref<?x?xf32, strided<[?, ?], offset: 0>>
scf.for %arg5 = %c0 to %0 step %c2 {
scf.for %arg6 = %c0 to %2 step %c3 {
scf.for %arg7 = %c0 to %1 step %c4 {
%3 = affine.apply #map0(%arg5)
%4 = affine.apply #map1(%arg7)
%5 = memref.subview %A[%arg5, %arg7][%c2, %c4][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%6 = affine.apply #map2(%arg6)
%7 = memref.subview %D[%arg7, %arg6][%c4, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%8 = memref.subview %E[%arg5, %arg6][%c2, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
linalg.matmul ins(%5, %7 : memref<?x?xf32, strided<[?, ?], offset: ?>>,
memref<?x?xf32, strided<[?, ?], offset: ?>>)
outs(%8 : memref<?x?xf32, strided<[?, ?], offset: ?>>)
}
}
}
return %E : memref<?x?xf32, strided<[?, ?], offset: 0>>
}
// CHECK-LABEL: func @f8
// CHECK: (%[[A:.*]]: memref{{.*}}, %[[B:.*]]: memref{{.*}}, %[[C:.*]]: memref{{.*}}, %[[D:.*]]: memref{{.*}}, %[[E:.*]]: memref{{.*}})
// CHECK: linalg.matmul
// CHECK: linalg.matmul
// CHECK: scf.for
// CHECK: scf.for
// CHECK: scf.for
// CHECK: linalg.matmul
// CHECK-NOT: linalg.matmul
// -----
#id_2d = affine_map<(i, j) -> (i, j)>
#pointwise_2d_trait = {
indexing_maps = [#id_2d, #id_2d, #id_2d],
iterator_types = ["parallel", "parallel"]
}
func.func @pointwise(%A: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%B: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%C: memref<?x?xf32, strided<[?, ?], offset: 0>>,
%D: memref<?x?xf32, strided<[?, ?], offset: 0>>) {
%c1 = arith.constant 1 : index
%c0 = arith.constant 0 : index
%c3 = arith.constant 3 : index
%c2 = arith.constant 2 : index
linalg.generic #pointwise_2d_trait
ins(%A, %A: memref<?x?xf32, strided<[?, ?], offset: 0>>,
memref<?x?xf32, strided<[?, ?], offset: 0>>)
outs(%B : memref<?x?xf32, strided<[?, ?], offset: 0>>) {
^bb0(%E: f32, %arg5: f32, %arg6: f32):
%2 = arith.addf %E, %arg5 : f32
linalg.yield %2 : f32
}
%0 = memref.dim %B, %c0 : memref<?x?xf32, strided<[?, ?], offset: 0>>
%1 = memref.dim %B, %c1 : memref<?x?xf32, strided<[?, ?], offset: 0>>
scf.for %arg4 = %c0 to %0 step %c2 {
scf.for %arg5 = %c0 to %1 step %c3 {
%4 = memref.subview %B[%arg4, %arg5][%c2, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%5 = memref.subview %C[%arg4, %arg5][%c2, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%6 = memref.subview %D[%arg4, %arg5][%c2, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
linalg.generic #pointwise_2d_trait
ins(%4, %5: memref<?x?xf32, strided<[?, ?], offset: ?>>,
memref<?x?xf32, strided<[?, ?], offset: ?>>)
outs(%6 : memref<?x?xf32, strided<[?, ?], offset: ?>>) {
^bb0(%arg6: f32, %arg7: f32, %arg8: f32):
%7 = arith.mulf %arg6, %arg7 : f32
linalg.yield %7 : f32
}
}
}
return
}
// CHECK-LABEL: func @pointwise
// CHECK: scf.for
// CHECK: scf.for
// CHECK-NOT: scf.for
// CHECK: linalg.generic
// CHECK: arith.addf
// CHECK: linalg.generic
// CHECK: arith.mulf
// -----
#id_2d = affine_map<(i, j) -> (i, j)>
#pointwise_2d_trait = {
indexing_maps = [#id_2d, #id_2d, #id_2d],
iterator_types = ["parallel", "parallel"]
}
func.func @pointwise_no_view(%M: index, %N: index) {
%c1 = arith.constant 1 : index
%c0 = arith.constant 0 : index
%c3 = arith.constant 3 : index
%c2 = arith.constant 2 : index
%A = memref.alloc (%M, %N): memref<?x?xf32>
%B = memref.alloc (%M, %N): memref<?x?xf32>
%C = memref.alloc (%M, %N): memref<?x?xf32>
%D = memref.alloc (%M, %N): memref<?x?xf32>
%E = memref.alloc (%M, %N): memref<?x?xf32>
linalg.generic #pointwise_2d_trait
ins(%A, %A : memref<?x?xf32>, memref<?x?xf32>)
outs(%B : memref<?x?xf32>) {
^bb0(%e: f32, %arg5: f32, %arg6: f32):
%2 = arith.addf %e, %arg5 : f32
linalg.yield %2 : f32
}
%0 = memref.dim %B, %c0 : memref<?x?xf32>
%1 = memref.dim %B, %c1 : memref<?x?xf32>
scf.for %arg4 = %c0 to %0 step %c2 {
scf.for %arg5 = %c0 to %1 step %c3 {
%4 = memref.subview %B[%arg4, %arg5][%c2, %c3][%c1, %c1] :
memref<?x?xf32> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%5 = memref.subview %C[%arg4, %arg5][%c2, %c3][%c1, %c1] :
memref<?x?xf32> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%6 = memref.subview %D[%arg4, %arg5][%c2, %c3][%c1, %c1] :
memref<?x?xf32> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
linalg.generic #pointwise_2d_trait
ins(%4, %5: memref<?x?xf32, strided<[?, ?], offset: ?>>,
memref<?x?xf32, strided<[?, ?], offset: ?>>)
outs(%6 : memref<?x?xf32, strided<[?, ?], offset: ?>>) {
^bb0(%arg6: f32, %arg7: f32, %arg8: f32):
%7 = arith.mulf %arg6, %arg7 : f32
linalg.yield %7 : f32
}
}
}
return
}
// CHECK-LABEL: func @pointwise_no_view
// CHECK: scf.for
// CHECK: scf.for
// CHECK-NOT: scf.for
// CHECK: linalg.generic
// CHECK: arith.addf
// CHECK: linalg.generic
// CHECK: arith.mulf
// -----
#map0 = affine_map<(d0, d1) -> (d0)>
#map1 = affine_map<(d0, d1) -> (d0, d1)>
func.func @fusion_of_three(%arg0: memref<100x10xf32>,
%arg1: memref<100xf32>,
%arg2: memref<100x10xf32>) {
%c0 = arith.constant 0 : index
%c1 = arith.constant 1 : index
%0 = memref.alloc() {temp = true} : memref<100x10xf32>
linalg.generic {
indexing_maps = [#map0, #map1],
iterator_types = ["parallel", "parallel"]}
ins(%arg1 : memref<100xf32>)
outs(%0 : memref<100x10xf32>) {
^bb0(%arg3: f32, %arg4: f32):
linalg.yield %arg3 : f32
}
%1 = memref.alloc() {temp = true} : memref<100x10xf32>
linalg.generic {
indexing_maps = [#map1, #map1, #map1],
iterator_types = ["parallel", "parallel"]}
ins(%arg0, %0: memref<100x10xf32>, memref<100x10xf32>)
outs(%1 : memref<100x10xf32>) {
^bb0(%arg3: f32, %arg4: f32, %arg5: f32):
%2 = arith.subf %arg3, %arg4 : f32
linalg.yield %2 : f32
}
memref.dealloc %0 : memref<100x10xf32>
%2 = memref.dim %1, %c0 : memref<100x10xf32>
%3 = memref.dim %1, %c1 : memref<100x10xf32>
%4 = memref.dim %arg2, %c0 : memref<100x10xf32>
%5 = memref.dim %arg2, %c1 : memref<100x10xf32>
scf.for %i = %c0 to %2 step %c1 {
scf.for %j = %c0 to %3 step %c1 {
%6 = memref.subview %1[%i, %j][%c1, %c1][%c1, %c1] :
memref<100x10xf32> to memref<?x?xf32, strided<[?, ?], offset: ?>>
%7 = memref.subview %arg2[%i, %j][%c1, %c1][%c1, %c1] :
memref<100x10xf32> to memref<?x?xf32, strided<[?, ?], offset: ?>>
linalg.generic {
indexing_maps = [#map1, #map1],
iterator_types = ["parallel", "parallel"]}
ins(%6 : memref<?x?xf32, strided<[?, ?], offset: ?>>)
outs(%7 : memref<?x?xf32, strided<[?, ?], offset: ?>>) {
^bb0(%arg3: f32, %arg4: f32):
%8 = math.exp %arg3 : f32
linalg.yield %8 : f32
}
}
}
memref.dealloc %1 : memref<100x10xf32>
return
}
// CHECK-LABEL: func @fusion
// CHECK-NOT: linalg.generic
// CHECK: scf.for
// CHECK: scf.for
// CHECK-NOT: scf.for
// CHECK: linalg.generic
// CHECK: linalg.yield
// CHECK: linalg.generic
// CHECK: arith.subf
// CHECK: linalg.yield
// CHECK: linalg.generic
// CHECK: exp
// CHECK: linalg.yield
// -----
#map0 = affine_map<(d0)[s0] -> (2, -d0 + s0)>
#map1 = affine_map<(d0)[s0] -> (3, -d0 + s0)>
#map3 = affine_map<(d0)[s0, s1] -> (s0 + 1, -d0 + s0 + s1)>
#map4 = affine_map<(d0)[s0, s1] -> (s0 + 2, -d0 + s0 + s1)>
func.func @fill_and_conv(%arg0: memref<?x?xf32>, %arg1: memref<?x?xf32>, %arg2: memref<?x?xf32>) {
%cst = arith.constant 0.000000e+00 : f32
%c2 = arith.constant 2 : index
%c3 = arith.constant 3 : index
%c0 = arith.constant 0 : index
%c1 = arith.constant 1 : index
linalg.fill ins(%cst : f32) outs(%arg0 : memref<?x?xf32>)
%2 = memref.dim %arg1, %c0 : memref<?x?xf32>
%3 = memref.dim %arg1, %c1 : memref<?x?xf32>
%4 = memref.dim %arg2, %c0 : memref<?x?xf32>
%5 = memref.dim %arg2, %c1 : memref<?x?xf32>
scf.for %arg3 = %c0 to %4 step %c2 {
scf.for %arg4 = %c0 to %5 step %c3 {
%6 = affine.min #map3(%arg3)[%2, %4]
%7 = affine.min #map4(%arg4)[%3, %5]
%8 = memref.subview %arg0[%arg3, %arg4] [%6, %7] [1, 1] : memref<?x?xf32> to memref<?x?xf32, strided<[?, 1], offset: ?>>
%9 = affine.min #map0(%arg3)[%4]
%10 = affine.min #map1(%arg4)[%5]
%11 = memref.subview %arg2[%arg3, %arg4] [%9, %10] [1, 1] : memref<?x?xf32> to memref<?x?xf32, strided<[?, 1], offset: ?>>
linalg.conv_2d ins(%8, %arg1 : memref<?x?xf32, strided<[?, 1], offset: ?>>, memref<?x?xf32>) outs(%11 : memref<?x?xf32, strided<[?, 1], offset: ?>>)
}
}
return
}
// CHECK-LABEL: func @fill_and_conv
// CHECK: scf.for
// CHECK: scf.for
// CHECK: linalg.fill
// CHECK: linalg.conv_2d
// -----
// Test that different allocation-like ops are recognized and properly handled.
func.func @accept_different_alloc_ops(%dim: index, %s0 : index, %s1: index) {
%c0 = arith.constant 0 : index
%c1 = arith.constant 1 : index
%c2 = arith.constant 2 : index
%c3 = arith.constant 3 : index
%c4 = arith.constant 4 : index
%A = memref.alloca(%dim, %dim)[%s0, %s1] : memref<?x?xf32, strided<[?, ?], offset: 0>>
%B = memref.alloca(%dim, %dim)[%s0, %s1] : memref<?x?xf32, strided<[?, ?], offset: 0>>
%C = memref.alloc(%dim, %dim)[%s0, %s1] : memref<?x?xf32, strided<[?, ?], offset: 0>>
linalg.matmul ins(%A, %B : memref<?x?xf32, strided<[?, ?], offset: 0>>,
memref<?x?xf32, strided<[?, ?], offset: 0>>)
outs(%C : memref<?x?xf32, strided<[?, ?], offset: 0>>)
scf.for %i = %c0 to %dim step %c2 {
scf.for %j = %c0 to %dim step %c3 {
scf.for %k = %c0 to %dim step %c4 {
%0 = memref.subview %A[%i, %k][%c2, %c4][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%1 = memref.subview %B[%k, %j][%c4, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
%2 = memref.subview %C[%i, %j][%c2, %c3][%c1, %c1] :
memref<?x?xf32, strided<[?, ?], offset: 0>> to
memref<?x?xf32, strided<[?, ?], offset: ?>>
linalg.matmul ins(%0, %1 : memref<?x?xf32, strided<[?, ?], offset: ?>>,
memref<?x?xf32, strided<[?, ?], offset: ?>>)
outs(%2 : memref<?x?xf32, strided<[?, ?], offset: ?>>)
}
}
}
return
}
// CHECK-LABEL: func @accept_different_alloc_ops
// CHECK-COUNT-3: scf.for
// CHECK-COUNT-2: linalg.matmul
|