Skip to content

Commit f822151

Browse files
V-FEXrtgithub-actions[bot]tex3d
authored
[SM6.10][Exec] Don't used signed types for unsigned values (#8364)
Comparing `int32_t` for M/N to `size_t` caused failures on internal pipelines ala #8336 Since M/N don't make sense as negative values remove the entire class of errors by changing them to unsigned types. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Tex Riddell <[email protected]>
1 parent a5877b6 commit f822151

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

tools/clang/unittests/HLSLExec/LinAlgTests.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ using HLSLTestDataTypes::ValidationType;
4444

4545
using VariantCompType = std::variant<std::vector<float>, std::vector<int32_t>,
4646
std::vector<HLSLHalf_t>>;
47+
using MatrixDim = uint32_t;
4748

4849
/// Return the byte size of a single element for the given component type.
49-
static int elementSize(ComponentType CT) {
50+
static uint8_t elementSize(ComponentType CT) {
5051
switch (CT) {
5152
case ComponentType::F16:
5253
case ComponentType::I16:
@@ -63,23 +64,23 @@ static int elementSize(ComponentType CT) {
6364

6465
struct MatrixParams {
6566
ComponentType CompType;
66-
int M;
67-
int N;
67+
MatrixDim M;
68+
MatrixDim N;
6869
MatrixUse Use;
6970
MatrixScope Scope;
7071
LinalgMatrixLayout Layout;
7172
int NumThreads;
7273
bool Enable16Bit;
7374
bool EmulateTest;
7475

75-
int strideBytes() const {
76-
int ES = elementSize(CompType);
76+
size_t strideBytes() const {
77+
uint32_t ES = elementSize(CompType);
7778
if (Layout == LinalgMatrixLayout::RowMajor)
7879
return N * ES;
7980
return M * ES;
8081
}
8182

82-
size_t totalElements() const { return static_cast<size_t>(M) * N; }
83+
size_t totalElements() const { return M * N; }
8384

8485
size_t totalBytes() const { return totalElements() * elementSize(CompType); }
8586
};
@@ -95,7 +96,7 @@ static std::string buildCompilerArgs(const MatrixParams &Params,
9596
SS << " -DSCOPE=" << static_cast<int>(Params.Scope);
9697
SS << " -DSTRIDE=" << Params.strideBytes();
9798
SS << " -DLAYOUT=" << static_cast<int>(Params.Layout);
98-
SS << " -DELEM_SIZE=" << elementSize(Params.CompType);
99+
SS << " -DELEM_SIZE=" << static_cast<int>(elementSize(Params.CompType));
99100
SS << " -DNUMTHREADS=" << Params.NumThreads;
100101
switch (Params.CompType) {
101102
case ComponentType::F16:
@@ -228,8 +229,8 @@ static bool fillInputBuffer(LPCSTR Name, std::vector<BYTE> &Data,
228229
return false;
229230
}
230231

231-
static VariantCompType makeExpected(ComponentType CompType, int32_t M,
232-
int32_t N, float StartingVal,
232+
static VariantCompType makeExpected(ComponentType CompType, MatrixDim M,
233+
MatrixDim N, float StartingVal,
233234
bool Increment = true,
234235
bool Transpose = false) {
235236
const size_t NumElements = M * N;

0 commit comments

Comments
 (0)