Normalize memrefs with affine_map in krnl.memcpy (#322)

* Normalize memrefs with affine_map in krnl.memcpy

Added a trait of `MemRefsNormalizable` in `krnl.memcpy` to have
`krnl.memcpy` normalizable.
Reference: https://reviews.llvm.org/D86236

Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>

* Simplified test case about normalizing memrefs in krnl.memcpy

Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>

* Remove other krnl ops from test case for simplification

Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>

* Fixed test code

Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>

Co-authored-by: Alexandre Eichenberger <alexe@us.ibm.com>
This commit is contained in:
Haruki Imai 2020-09-26 03:36:15 +09:00 committed by GitHub
parent 71b8ca28aa
commit 278f10c3a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -142,7 +142,7 @@ def KrnlEntryPointOp : Op<Krnl_Dialect, "entry_point"> {
let printer = ?;
}
def KrnlMemcpyOp : Op<Krnl_Dialect, "memcpy"> {
def KrnlMemcpyOp : Op<Krnl_Dialect, "memcpy", [MemRefsNormalizable]> {
let summary = "Krnl memcpy operation";
let description = [{
In the KRNL dialect the reshape op

View File

@ -0,0 +1,16 @@
// RUN: onnx-mlir-opt --normalize-memrefs %s -split-input-file | FileCheck %s
#map_tile = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2 floordiv 32, d3 floordiv 32, d2 mod 32, d3 mod 32)>
// CHECK-LABEL: test_krnl_memcpy_norm
// CHECK-SAME: -> memref<1x16x1x1x32x32xf32> {
func @test_krnl_memcpy_norm(%arg0: memref<1x16384xf32>) -> memref<1x16x4x4xf32, #map_tile> {
%0 = alloc() : memref<1x16x4x4xf32, #map_tile>
// CHECK: [[ALLOC:%.+]] = alloc() : memref<1x16x1x1x32x32xf32>
%c16384 = constant 16384 : i64
"krnl.memcpy"(%0, %arg0, %c16384) : (memref<1x16x4x4xf32, #map_tile>, memref<1x16384xf32>, i64) -> ()
// CHECK: "krnl.memcpy"
// CHECK-SAME: : (memref<1x16x1x1x32x32xf32>, memref<1x16384xf32>
return %0 : memref<1x16x4x4xf32, #map_tile>
// CHECK: return [[ALLOC]] : memref<1x16x1x1x32x32xf32>
}