Skip to content

Commit d0d5258

Browse files
authored
[matrix] Fix the the row\col indexing (#491)
Two is the row max size.
1 parent e939efa commit d0d5258

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

test/Basic/matrix_scalar_arithmetic.test

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ void main(uint GI : SV_GroupIndex) {
1111
int2x3 A = int2x3(In[0], In[1], In[2],
1212
In[3], In[4], In[5]);
1313

14-
int row = GI / 2;
15-
int col = GI % 2;
16-
DivOut[GI] = A[col][row] / 2;
17-
MulOut[GI] = A[col][row] * 2;
18-
AddOut[GI] = A[col][row] + 1;
19-
SubOut[GI] = A[col][row] - 1;
14+
const uint COLS = 3; // int2x3 => 2 rows, 3 columns
15+
uint row = GI / COLS; // 0..1
16+
uint col = GI % COLS; // 0..2
17+
DivOut[GI] = A[row][col] / 2;
18+
MulOut[GI] = A[row][col] * 2;
19+
AddOut[GI] = A[row][col] + 1;
20+
SubOut[GI] = A[row][col] - 1;
2021
}
2122

2223
//--- pipeline.yaml
@@ -92,13 +93,13 @@ DescriptorSets:
9293
# CHECK: Data: [ 2, 4, 6, 8, 10, 12 ]
9394
# CHECK: Name: DivOut
9495
# CHECK: Format: Int32
95-
# CHECK: Data: [ 1, 4, 2, 5, 3, 6 ]
96+
# CHECK: Data: [ 1, 2, 3, 4, 5, 6 ]
9697
# CHECK: Name: MulOut
9798
# CHECK: Format: Int32
98-
# CHECK: Data: [ 4, 16, 8, 20, 12, 24 ]
99+
# CHECK: Data: [ 4, 8, 12, 16, 20, 24 ]
99100
# CHECK: Name: AddOut
100101
# CHECK: Format: Int32
101-
# CHECK: Data: [ 3, 9, 5, 11, 7, 13 ]
102+
# CHECK: Data: [ 3, 5, 7, 9, 11, 13 ]
102103
# CHECK: Name: SubOut
103104
# CHECK: Format: Int32
104-
# CHECK: Data: [ 1, 7, 3, 9, 5, 11 ]
105+
# CHECK: Data: [ 1, 3, 5, 7, 9, 11 ]

test/Basic/matrix_scalar_constructor.test

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ void main(uint GI : SV_GroupIndex) {
88
int2x3 A = int2x3(In[0], In[1], In[2],
99
In[3], In[4], In[5]);
1010

11-
int row = GI / 2;
12-
int col = GI % 2;
13-
Out[GI] = A[col][row];
11+
const uint COLS = 3; // int2x3 => 2 rows, 3 columns
12+
uint row = GI / COLS; // 0..1
13+
uint col = GI % COLS; // 0..2
14+
15+
Out[GI] = A[row][col];
1416
}
1517

1618
//--- pipeline.yaml
@@ -29,7 +31,7 @@ Buffers:
2931
FillSize: 24
3032
- Name: ExpectedOut
3133
Format: Int32
32-
Data: [ 1, 4, 2, 5, 3, 6 ]
34+
Data: [ 1, 2, 3, 4, 5, 6 ]
3335
Results:
3436
- Result: Out
3537
Rule: BufferExact

0 commit comments

Comments
 (0)