Skip to content
This repository was archived by the owner on Apr 23, 2021. It is now read-only.
This repository was archived by the owner on Apr 23, 2021. It is now read-only.

The semantics of AffineMap in MemRef #27

Closed

Description

@QiJune

Here is an example:

#imapA = (d0, d1) [s0] -> (d0 + s0, d1)
%o = 1
%i = 0
%j = 0
%A = alloc()[%o] : memref<16x32xf32, #imapA, memspace0>
%v = load %A[%i, %j] : memref<16x32xf32, #imapA, memspace0>

It allocates a two dimension array, A[16][32].
The index of load is set to (0, 0).
Since there is an affinemap, %o is set to 1, the load operation will return A[1][0] actually.

Is my understanding correct? Thanks!

Activity

  1. joker-eph commented on Apr 24, 2019

    @joker-eph
    Contributor

    Unless we should track fixing the documentation with this bug, I think the best place to ask question and/or discuss such things is the mailing: https://groups.google.com/a/tensorflow.org/forum/#!forum/mlir

    To answer your question, imapA is more exactly a semi-affine map and used here as a layout-map according to https://github.com/tensorflow/mlir/blob/master/g3doc/LangRef.md#layout-map
    (your understanding of the indexing seems correct to me otherwise).

    Your example in a form that would parse today would be:

    #imapA = (d0, d1) [s0] -> (d0 + s0, d1)
    func @test() {
      %o = constant 1 : index
      %i = constant 0 : index
      %j = constant 0 : index
      %A = alloc()[%o] : memref<16x32xf32, #imapA, 0>
      %v = load %A[%i, %j] : memref<16x32xf32, #imapA, 0>
      return
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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