@@ -565,31 +565,34 @@ namespace matx {
565
565
cudaDeviceSynchronize ();
566
566
if constexpr (is_sparse_tensor_v<Op>) {
567
567
using Format = typename Op::Format;
568
- index_t nse = op.Nse ();
569
- fprintf (fp, " nse = %" MATX_INDEX_T_FMT " \n " , nse);
570
568
fprintf (fp, " format = " );
571
- Format::print ();
572
- for (int lvlIdx = 0 ; lvlIdx < Format::LVL; lvlIdx++) {
573
- if (const index_t pend = op.posSize (lvlIdx)) {
574
- fprintf (fp, " pos[%d] = (" , lvlIdx);
575
- for (index_t i = 0 ; i < pend; i++) {
576
- PrintVal (fp, op.POSData (lvlIdx)[i]);
569
+ Format::print ();
570
+ const auto kind = GetPointerKind (op.Data ());
571
+ fprintf (fp, " )\n space = %s\n " , SpaceString (kind).c_str ());
572
+ const auto nse = op.Nse ();
573
+ fprintf (fp, " nse = %" MATX_INDEX_T_FMT " \n " , nse);
574
+ if (HostPrintable (kind)) {
575
+ for (int lvlIdx = 0 ; lvlIdx < Format::LVL; lvlIdx++) {
576
+ if (const index_t pend = op.posSize (lvlIdx)) {
577
+ fprintf (fp, " pos[%d] = (" , lvlIdx);
578
+ for (index_t i = 0 ; i < pend; i++) {
579
+ PrintVal (fp, op.POSData (lvlIdx)[i]);
580
+ }
581
+ fprintf (fp, " )\n " );
577
582
}
578
- fprintf (fp, " ) \n " );
579
- }
580
- if ( const index_t cend = op. crdSize (lvlIdx) ) {
581
- fprintf (fp, " crd[%d] = ( " , lvlIdx);
582
- for ( index_t i = 0 ; i < cend; i++) {
583
- PrintVal (fp, op. CRDData (lvlIdx)[i] );
583
+ if ( const index_t cend = op. crdSize (lvlIdx)) {
584
+ fprintf (fp, " crd[%d] = ( " , lvlIdx);
585
+ for ( index_t i = 0 ; i < cend; i++ ) {
586
+ PrintVal (fp, op. CRDData ( lvlIdx)[i] );
587
+ }
588
+ fprintf (fp, " ) \n " );
584
589
}
585
- fprintf (fp, " )\n " );
590
+ }
591
+ fprintf (fp, " values = (" );
592
+ for (index_t i = 0 ; i < nse; i++) {
593
+ PrintVal (fp, op.Data ()[i]);
586
594
}
587
595
}
588
- fprintf (fp, " values = (" );
589
- for (index_t i = 0 ; i < nse; i++) {
590
- PrintVal (fp, op.Data ()[i]);
591
- }
592
- fprintf (fp, " )\n space = %s\n " , SpaceString (GetPointerKind (op.Data ())).c_str ());
593
596
}
594
597
else if constexpr (is_tensor_view_v<Op>) {
595
598
// If the user is printing a tensor with a const pointer underlying the data, we need to do the lookup
0 commit comments