@@ -7,51 +7,51 @@ short).
77
88## Terminology, notation, and conventions
99
10- * The rank of an array is equal to the number of dimensions. The * true rank*
11- of an array is the number of dimensions which have a size greater than 1.
10+ * The rank of an array is equal to the number of dimensions. The * true rank*
11+ of an array is the number of dimensions which have a size greater than 1.
1212
13- * Dimensions are numbered from ` 0 ` up to ` N-1 ` for an ` N ` dimensional array.
14- The dimension numbers are arbitrary labels for convenience. The order of
15- these dimension numbers does not imply a particular minor/major ordering in
16- the layout of the shape. The layout is determined by the ` Layout ` proto.
13+ * Dimensions are numbered from ` 0 ` up to ` N-1 ` for an ` N ` dimensional array.
14+ The dimension numbers are arbitrary labels for convenience. The order of
15+ these dimension numbers does not imply a particular minor/major ordering in
16+ the layout of the shape. The layout is determined by the ` Layout ` proto.
1717
18- * By convention, dimensions are listed in increasing order of dimension
19- number. For example, for a 3-dimensional array of size ` [A x B x C] ` ,
20- dimension 0 has size ` A ` , dimension 1 has size ` B ` and dimension 2 has size
21- ` C ` .
18+ * By convention, dimensions are listed in increasing order of dimension
19+ number. For example, for a 3-dimensional array of size ` [A x B x C] ` ,
20+ dimension 0 has size ` A ` , dimension 1 has size ` B ` , and dimension 2 has size
21+ ` C ` .
2222
23- Some utilities in XLA also support negative indexing, similarly to Python;
24- dimension -1 is the last dimension (equivalent to ` N-1 ` for an ` N `
25- dimensional array). For example, for the 3-dimensional array described
26- above, dimension -1 has size ` C ` , dimension -2 has size ` B ` and so on.
23+ Some utilities in XLA also support Python-like negative indexing: Dimension
24+ -1 is the last dimension (equivalent to ` N-1 ` for an ` N ` dimensional array).
25+ For example, for the 3-dimensional array described above, dimension -1 has
26+ size ` C ` , dimension -2 has size ` B ` , and so on.
2727
28- * Two, three, and four dimensional arrays often have specific letters
29- associated with dimensions. For example, for a 2D array:
28+ * Two, three, and four dimensional arrays often have specific letters
29+ associated with dimensions. For example, for a 2D array:
3030
31- * dimension 0: ` y `
32- * dimension 1: ` x `
31+ * dimension 0: ` y `
32+ * dimension 1: ` x `
3333
34- For a 3D array:
34+ For a 3D array:
3535
36- * dimension 0: ` z `
37- * dimension 1: ` y `
38- * dimension 2: ` x `
36+ * dimension 0: ` z `
37+ * dimension 1: ` y `
38+ * dimension 2: ` x `
3939
40- For a 4D array:
40+ For a 4D array:
4141
42- * dimension 0: ` p `
43- * dimension 1: ` z `
44- * dimension 2: ` y `
45- * dimension 3: ` x `
42+ * dimension 0: ` p `
43+ * dimension 1: ` z `
44+ * dimension 2: ` y `
45+ * dimension 3: ` x `
4646
47- * Functions in the XLA API which take dimensions do so in increasing order of
48- dimension number. This matches the ordering used when passing dimensions as
49- an ` initializer_list ` ; e.g.
47+ * Functions in the XLA API which take dimensions do so in increasing order of
48+ dimension number. This matches the ordering used when passing dimensions as
49+ an ` initializer_list ` ; e.g.
5050
51- ` ShapeUtil::MakeShape(F32, {A, B, C, D}) `
51+ ` ShapeUtil::MakeShape(F32, {A, B, C, D}) `
5252
53- Will create a shape whose dimension size array consists of the sequence
54- ` [A, B, C, D]` .
53+ will create a shape whose dimension size array consists of the sequence ` [ A,
54+ B, C, D] `.
5555
5656## Layout
5757
@@ -93,8 +93,8 @@ a d b e c f
9393```
9494
9595This minor-to-major dimension order of ` 0 ` up to ` N-1 ` is akin to * column-major*
96- (at rank 2). Assuming a monotonic ordering of dimensions, another name we may
97- use to refer to this layout in the code is simply "dim 0 is minor".
96+ (at rank 2). Assuming a monotonic ordering of dimensions, another way we may
97+ refer to this layout in the code is simply "dim 0 is minor".
9898
9999On the other hand, if the ` minor_to_major ` field in the layout is ` [1, 0] ` then
100100the layout in linear memory is:
@@ -105,8 +105,8 @@ a b c d e f
105105
106106A minor-to-major dimension order of ` N-1 ` down to ` 0 ` for an ` N ` dimensional
107107array is akin to * row-major* (at rank 2). Assuming a monotonic ordering of
108- dimensions, another name we may use to refer to this layout in the code is
109- simply "dim 0 is major".
108+ dimensions, another way we may refer to this layout in the code is simply "dim 0
109+ is major".
110110
111111#### Default minor-to-major ordering
112112
@@ -143,7 +143,7 @@ d e f 0 0
143143The class ` IndexUtil ` in
144144[ index_util.h] ( https://github.com/openxla/xla/tree/main/xla/index_util.h )
145145provides utilities for converting between multidimensional indices and linear
146- indices given a shape and layout. Multidimensional indices include a ` int64 `
146+ indices given a shape and layout. Multidimensional indices include an ` int64 `
147147index for each dimension. Linear indices are a single ` int64 ` value which
148148indexes into the buffer holding the array. See ` shape_util.h ` and
149149` layout_util.h ` in the same directory for utilities that simplify creation and
0 commit comments