Skip to content

why allocation scope is introduced ? #430

@FullZing

Description

@FullZing

Hi,
I looked into https://github.com/intel/graph-compiler/blob/ef3d150ad591dc9ff3c86686341c2e7ce007695d/docs/memref_schedule.md and understood how allocator works.

But i don't understand why allocation scope is introduced.
Here is dupmed IR,

func.func @nested_forall(%arg0: memref<2xf32>) attributes {__mergealloc_scope = 94435173533712 : i64} {
  %c0 = arith.constant 0 : index
  %c2 = arith.constant 2 : index
  %c4 = arith.constant 4 : index
  %c16 = arith.constant 16 : index
  %alloc = memref.alloc() {__mergealloc_lifetime = array<i64: 94435173533712, 7, 19>} : memref<2xf32>
  memref.copy %arg0, %alloc : memref<2xf32> to memref<2xf32>
  scf.forall (%arg1) = (%c0) to (%c16) step (%c2) {
    %alloc_0 = memref.alloc() {__mergealloc_lifetime = array<i64: 94435173478560, 18, 18>} : memref<4xf32>
    %alloc_1 = memref.alloc() {__mergealloc_lifetime = array<i64: 94435173533712, 11, 16>} : memref<8xf32>
    scf.forall (%arg2) in (%c4) {
      "test.source"(%alloc) : (memref<2xf32>) -> ()
      "test.source"(%alloc_1) : (memref<8xf32>) -> ()
      %alloc_2 = memref.alloc() {__mergealloc_lifetime = array<i64: 94435173605248, 15, 15>} : memref<16xf32>
      "test.source"(%alloc_2) : (memref<16xf32>) -> ()
    } {__mergealloc_scope = 94435173605248 : i64}
    "test.source"(%alloc) : (memref<2xf32>) -> ()
    "test.source"(%alloc_0) : (memref<4xf32>) -> ()
  } {__mergealloc_scope = 94435173478560 : i64}
  return
}

there are 3 allocation scopes.

However, there is only 1 physical memory.
so i expect there is only 1 memref.alloc op in the whole IR.
is it reasonable?

Hope some one can help me out.
Thank you very Much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions