[PATCH] D83477: [Matrix] Tighten LangRef definitions and Verifier checks.

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 10 01:14:59 PDT 2020


SjoerdMeijer marked an inline comment as done.
SjoerdMeijer added inline comments.


================
Comment at: llvm/docs/LangRef.rst:15574
+matrix, using a stride of %Stride between columns. For two consecutive columns
+A and B, %Stride refers to the distance (the number of elements) between the
+start of column A and the start of column B. The result matrix is linearized
----------------
fhahn wrote:
> SjoerdMeijer wrote:
> > I am actually now also interested in defining  `%Stride` better. Using our new definition:
> > 
> > > For a `R x C` matrix, element `i` of column `j` is at index `j * R + i` in its vector, with indices starting at 0.  
> > 
> > From the description of %Stride it follows that:
> > 
> >   %Stride = ( (j+1) * R + 0) - (j * R + 0)
> >   =>
> >   %Stride = R
> > 
> > So double checking: we can simply the description of %Stride just by saying it is equal to the number of rows, is that correct?
> Stride can be > the number of rows. 
> 
> For example, if you want to load a 2x2 sub-matrix from a 4x4 matrix, you would use `llvm.matrix.column.major.load(%start, 4, false, 2, 2), where %start points to the first element of the sub-matrix.
> 
> The function to compute column addresses has an extensive comment about how things work: https://github.com/llvm/llvm-project/blob/master/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp#L92
> 
> It boils down to something like: the start address of column I in memory is computed as  ` getelementptr %Start,  I * Stride`.
Ah yes, thanks, I see now. I will add this, and we have at least one more condition, Stride >= Rows, to add to the verifier.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83477/new/

https://reviews.llvm.org/D83477





More information about the llvm-commits mailing list