Skip to content

Commit 49bd6bf

Browse files
Aminsedccecka
andauthored
fix print_layout printf format in device code (#2688)
* fix print_layout printf format in device code * Replace %.*s format specifier with explicit loop * Remove unused delim variable The printf format %.*s with dynamic width does not work correctly in CUDA device code, causing literal %.*s to appear in output. Fixes #2496 * Update include/cute/util/print_tensor.hpp Co-authored-by: Cris Cecka <[email protected]> * Update include/cute/util/print_tensor.hpp Co-authored-by: Cris Cecka <[email protected]> --------- Co-authored-by: Cris Cecka <[email protected]>
1 parent c6dfdf8 commit 49bd6bf

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

include/cute/util/print_tensor.hpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ print_layout(Layout const& layout) // (m,n) -> idx
5050
CUTE_STATIC_ASSERT_V(rank(layout) == Int<2>{});
5151

5252
int idx_width = num_digits(cosize(layout)) + 2;
53-
const char* delim = "+-----------------------";
5453

5554
print(layout); print("\n");
5655

@@ -63,7 +62,12 @@ print_layout(Layout const& layout) // (m,n) -> idx
6362
for (int m = 0; m < size<0>(layout); ++m) {
6463
// Header
6564
print(" ");
66-
for (int n = 0; n < size<1>(layout); ++n) { printf("%.*s", idx_width+1, delim); }
65+
for (int n = 0; n < size<1>(layout); ++n) {
66+
printf("+");
67+
for (int i = 0; i < idx_width; ++i) {
68+
printf("-");
69+
}
70+
}
6771
printf("+\n");
6872
// Values
6973
printf("%2d ", m); // Row indices
@@ -72,7 +76,12 @@ print_layout(Layout const& layout) // (m,n) -> idx
7276
}
7377
// Footer
7478
print(" ");
75-
for (int n = 0; n < size<1>(layout); ++n) { printf("%.*s", idx_width+1, delim); }
79+
for (int n = 0; n < size<1>(layout); ++n) {
80+
printf("+");
81+
for (int i = 0; i < idx_width; ++i) {
82+
printf("-");
83+
}
84+
}
7685
printf("+\n");
7786
}
7887

0 commit comments

Comments
 (0)