Skip to content

Questions about layout calculation #919

Answered by mhoemmen
zhujj2008 asked this question in Q&A
Discussion options

You must be logged in to vote

@zhujj2008 Specifically regarding the layout (20,2):(16:4) o (4,5):(1,4), it's helpful to notice that (4,5):(1,4) is the compact column-major layout for the shape (4,5). Thus, it's equivalent to 20:1.

  • (20,2):(16:4) o (4,5):(1,4)
  • (20,2):(16:4) o 20:1

20:1 means "take the first 20 consecutive elements of the layout." ("Consecutive" comes from the stride 1.) That's just the first column of (20,2):(16:4), that is, 20:16 (20 elements, with stride 16).

The shape of a composition A o B is the shape of B. Thus, we need to reshape 20:16 to have the required shape (4,5). The stride between consecutive elements in a column is 16, and the stride between consecutive elements in a row is 4 * 16 = 64.…

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
8 replies
@mhoemmen
Comment options

@eatingtomatoes
Comment options

@jayhshah
Comment options

@eatingtomatoes
Comment options

@mhoemmen
Comment options

Answer selected by zhujj2008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants