Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make dim2lvl translation for printing more in the style of MatX #832

Merged
merged 1 commit into from
Jan 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions include/matx/core/print.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,11 @@ namespace matx {
{
// A sparse tensor has no strides, so show the level sizes instead.
// These are obtained by translating dims to levels using the format.
index_t dims[Op::Format::DIM];
index_t lvls[Op::Format::LVL];
for (int dimIdx = 0; dimIdx < Op::Format::DIM; dimIdx++) {
dims[dimIdx] = op.Size(dimIdx);
}
Op::Format::dim2lvl(dims, lvls, /*asSize=*/true);
cuda::std::array<index_t, Op::Format::LVL> lvlsz;
Op::Format::dim2lvl(op.Shape().data(), lvlsz.data(), /*asSize=*/true);
fprintf(fp, "], Levels:[");
for (int lvlIdx = 0; lvlIdx < Op::Format::LVL; lvlIdx++) {
fprintf(fp, "%" MATX_INDEX_T_FMT, lvls[lvlIdx]);
fprintf(fp, "%" MATX_INDEX_T_FMT, lvlsz[lvlIdx]);
if (lvlIdx < (Op::Format::LVL - 1)) {
fprintf(fp, ", ");
}
Expand Down