diff --git a/examples/print_styles.cu b/examples/print_styles.cu index 19cf10078..d2c4c97b7 100644 --- a/examples/print_styles.cu +++ b/examples/print_styles.cu @@ -62,12 +62,14 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv) auto A2 = reshape(A1, {4,4}); auto A3 = reshape(A1, {2,2,4}); auto A4 = reshape(A1, {2,2,2,2}); + auto A5 = reshape(A1, {2,2,1,2,2}); printf("MATX_PRINT_FORMAT_DEFAULT:\n"); print(A1); print(A2); print(A3); print(A4); + print(A5); set_print_format_type(MATX_PRINT_FORMAT_MLAB); printf("MATX_PRINT_FORMAT_MLAB:\n"); @@ -75,6 +77,7 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv) print(A2); print(A3); print(A4); + print(A5); set_print_format_type(MATX_PRINT_FORMAT_PYTHON); printf("MATX_PRINT_FORMAT_PYTHON:\n"); @@ -82,6 +85,7 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv) print(A2); print(A3); print(A4); + print(A5); // example-end print-example-1 MATX_CUDA_CHECK_LAST_ERROR(); diff --git a/include/matx/core/print.h b/include/matx/core/print.h index d296ce9b3..9c7d19173 100644 --- a/include/matx/core/print.h +++ b/include/matx/core/print.h @@ -30,7 +30,9 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ///////////////////////////////////////////////////////////////////////////////// +#include #include +#include #include namespace matx { @@ -38,8 +40,9 @@ namespace matx { /** * Print a value * - * Type-agnostic function to print a value to stdout + * Type-agnostic function to print a value * + * @param fp * @param val */ template @@ -190,10 +193,177 @@ namespace matx { } + + template + using PrintIndexArray = std::array(Op::Rank())>; + + inline void PrintSpaces(FILE* fp, int count) + { + for (int i = 0; i < count; i++) { + fprintf(fp, " "); + } + } + + template + __MATX_HOST__ void PrintValAtImpl(FILE* fp, const Op &op, const PrintIndexArray &idx, + std::index_sequence) + { + PrintVal(fp, op.operator()(idx[Is]...)); + } + + template + __MATX_HOST__ void PrintValAt(FILE* fp, const Op &op, const PrintIndexArray &idx) + { + PrintValAtImpl(fp, op, idx, std::make_index_sequence(Op::Rank())>{}); + } + + template + __MATX_HOST__ PrintIndexArray GetPrintExtents(const Op &op, Args... dims) + { + PrintIndexArray extents{static_cast(dims)...}; + for (int dim = 0; dim < Op::Rank(); dim++) { + if (extents[static_cast(dim)] == 0) { + extents[static_cast(dim)] = op.Size(dim); + } + } + return extents; + } + + template + __MATX_HOST__ void PrintDefaultMatrix(FILE* fp, const Op &op, const PrintIndexArray &extents, + PrintIndexArray &idx) + { + constexpr int rank = Op::Rank(); + for (index_t row = 0; row < extents[rank - 2]; row++) { + idx[rank - 2] = row; + fprintf(fp, "%06" MATX_INDEX_T_FMT ": ", row); + for (index_t col = 0; col < extents[rank - 1]; col++) { + idx[rank - 1] = col; + PrintValAt(fp, op, idx); + } + fprintf(fp, "\n"); + } + } + + template + __MATX_HOST__ void PrintDefaultSliceHeader(FILE* fp, const PrintIndexArray &idx) + { + constexpr int rank = Op::Rank(); + fprintf(fp, "["); + for (int dim = 0; dim < rank - 2; dim++) { + fprintf(fp, "%06" MATX_INDEX_T_FMT ",", idx[static_cast(dim)]); + } + fprintf(fp, ":,:]\n"); + } + + template + __MATX_HOST__ void PrintDefaultSlices(FILE* fp, const Op &op, const PrintIndexArray &extents, + PrintIndexArray &idx) + { + constexpr int rank = Op::Rank(); + if constexpr (Dim == rank - 2) { + PrintDefaultSliceHeader(fp, idx); + PrintDefaultMatrix(fp, op, extents, idx); + fprintf(fp, "\n"); + } + else { + for (index_t i = 0; i < extents[Dim]; i++) { + idx[Dim] = i; + PrintDefaultSlices(fp, op, extents, idx); + } + } + } + + template + __MATX_HOST__ void PrintMlabMatrix(FILE* fp, const Op &op, const PrintIndexArray &extents, + PrintIndexArray &idx, int indent) + { + constexpr int rank = Op::Rank(); + for (index_t row = 0; row < extents[rank - 2]; row++) { + idx[rank - 2] = row; + PrintSpaces(fp, indent); + if (row == 0) { + fprintf(fp, "["); + } + else { + fprintf(fp, " "); + } + + for (index_t col = 0; col < extents[rank - 1]; col++) { + idx[rank - 1] = col; + PrintValAt(fp, op, idx); + if (col != extents[rank - 1] - 1) { + fprintf(fp, ", "); + } + } + + if (row == extents[rank - 2] - 1) { + fprintf(fp, "]"); + } + else { + fprintf(fp, "; ...\n"); + } + } + } + + template + __MATX_HOST__ void PrintMlabCat(FILE* fp, const Op &op, const PrintIndexArray &extents, + PrintIndexArray &idx) + { + constexpr int rank = Op::Rank(); + constexpr int indent = Dim * 7; + PrintSpaces(fp, indent); + fprintf(fp, "cat(%d, ...\n", rank - Dim); + for (index_t i = 0; i < extents[Dim]; i++) { + idx[Dim] = i; + if constexpr (Dim == rank - 3) { + PrintMlabMatrix(fp, op, extents, idx, indent + 7); + } + else { + PrintMlabCat(fp, op, extents, idx); + } + + if (i == extents[Dim] - 1) { + fprintf(fp, ")"); + } + else { + fprintf(fp, ", ...\n"); + } + } + } + + template + __MATX_HOST__ void PrintPythonRecursive(FILE* fp, const Op &op, const PrintIndexArray &extents, + PrintIndexArray &idx) + { + constexpr int rank = Op::Rank(); + fprintf(fp, "["); + if constexpr (Dim == rank - 1) { + for (index_t i = 0; i < extents[Dim]; i++) { + idx[Dim] = i; + PrintValAt(fp, op, idx); + if (i != extents[Dim] - 1) { + fprintf(fp, ", "); + } + } + } + else { + for (index_t i = 0; i < extents[Dim]; i++) { + idx[Dim] = i; + if (i != 0) { + fprintf(fp, ",\n"); + PrintSpaces(fp, Dim + 1); + } + PrintPythonRecursive(fp, op, extents, idx); + } + } + fprintf(fp, "]"); + } + /** * Print a tensor * - * Type-agnostic function to print a tensor to stdout + * Type-agnostic function to print a tensor * */ template @@ -202,15 +372,15 @@ namespace matx { MATX_NVTX_START("", matx::MATX_NVTX_LOG_INTERNAL) MATX_STATIC_ASSERT(Op::Rank() == sizeof...(Args), "Number of dimensions to print must match tensor rank"); - MATX_STATIC_ASSERT(Op::Rank() <= 4, "Printing is only supported on tensors of rank 4 or lower currently"); if constexpr (sizeof...(Args) == 0) { PrintVal(fp, op.operator()()); fprintf(fp, "\n"); } else if constexpr (sizeof...(Args) == 1) { - auto& k =detail:: pp_get<0>(dims...); - for (index_t _k = 0; _k < ((k == 0) ? op.Size(0) : k); _k++) { + auto& k = detail::pp_get<0>(dims...); + const index_t k_extent = (k == 0) ? op.Size(0) : static_cast(k); + for (index_t _k = 0; _k < k_extent; _k++) { if ((PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) || (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON)) { if (_k == 0) { fprintf(fp, "["); @@ -224,7 +394,7 @@ namespace matx { } PrintVal(fp, op.operator()(_k)); - if (_k == (op.Size(0)-1)) { + if (_k == (k_extent - 1)) { if ((PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) || (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON)) { fprintf(fp, "]"); } @@ -240,13 +410,15 @@ namespace matx { else if constexpr (sizeof...(Args) == 2) { auto& k = detail::pp_get<0>(dims...); auto& l = detail::pp_get<1>(dims...); - for (index_t _k = 0; _k < ((k == 0) ? op.Size(0) : k); _k++) { + const index_t k_extent = (k == 0) ? op.Size(0) : static_cast(k); + const index_t l_extent = (l == 0) ? op.Size(1) : static_cast(l); + for (index_t _k = 0; _k < k_extent; _k++) { if (_k == 0) { if ((PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) || (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON)) { fprintf(fp, "["); } } - for (index_t _l = 0; _l < ((l == 0) ? op.Size(1) : l); _l++) { + for (index_t _l = 0; _l < l_extent; _l++) { if (_l == 0) { if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_DEFAULT) { fprintf(fp, "%06" MATX_INDEX_T_FMT ": ", _k); @@ -268,8 +440,8 @@ namespace matx { PrintVal(fp, op.operator()(_k, _l)); - if (_l == (op.Size(1)-1)) { - if (_k == (op.Size(0)-1)) { + if (_l == (l_extent - 1)) { + if (_k == (k_extent - 1)) { if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) { fprintf(fp, "]"); } @@ -296,222 +468,19 @@ namespace matx { fprintf(fp, "\n"); } } - else if constexpr (sizeof...(Args) == 3) { - auto& j = detail::pp_get<0>(dims...); - auto& k = detail::pp_get<1>(dims...); - auto& l = detail::pp_get<2>(dims...); - for (index_t _j = 0; _j < ((j == 0) ? op.Size(0) : j); _j++) { - if (_j == 0) { - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) { - fprintf(fp, "cat(3, ...\n"); - } - else if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON) { - fprintf(fp, "["); - } - } - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_DEFAULT) { - fprintf(fp, "[%06" MATX_INDEX_T_FMT ",:,:]\n", _j); - } - for (index_t _k = 0; _k < ((k == 0) ? op.Size(1) : k); _k++) { - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) { - fprintf(fp, " "); - } - if (_k == 0) { - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) { - fprintf(fp, "["); - } - else if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON) { - if (_j == 0) { - fprintf(fp, "["); - } - else { - fprintf(fp, " ["); - } - } - } - else { - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) { - fprintf(fp, " "); - } - } - for (index_t _l = 0; _l < ((l == 0) ? op.Size(2) : l); _l++) { - if (_l == 0) { - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_DEFAULT) { - fprintf(fp, "%06" MATX_INDEX_T_FMT ": ", _k); - } - else if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON) { - if (_k == 0) { - fprintf(fp, "["); - } - else { - fprintf(fp, " ["); - } - } - } - - PrintVal(fp, op.operator()(_j, _k, _l)); - - if (_l == (op.Size(2)-1)) { - if (_k == (op.Size(1)-1)) { - if (_j == (op.Size(0)-1)) { - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) { - fprintf(fp, "])\n"); - } - else if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON) { - fprintf(fp, "]]]"); - } - } - else { - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) { - fprintf(fp, "], ..."); - } - else if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON) { - fprintf(fp, "]],"); - } - } - } - else { - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) { - fprintf(fp, "; ..."); - } - else if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON) { - fprintf(fp, "],"); - } - } - } - else { - if ((PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) || (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON)) { - fprintf(fp, ", "); - } - } - } - fprintf(fp, "\n"); - } - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_DEFAULT) { - fprintf(fp, "\n"); - } + else { + auto extents = GetPrintExtents(op, dims...); + PrintIndexArray idx{}; + if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_DEFAULT) { + PrintDefaultSlices<0>(fp, op, extents, idx); } - } - else if constexpr (sizeof...(Args) == 4) { - auto& i = detail::pp_get<0>(dims...); - auto& j = detail::pp_get<1>(dims...); - auto& k = detail::pp_get<2>(dims...); - auto& l = detail::pp_get<3>(dims...); - for (index_t _i = 0; _i < ((i == 0) ? op.Size(0) : i); _i++) { - if (_i == 0) { - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) { - fprintf(fp, "cat(4, ...\n"); - } - else if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON) { - fprintf(fp, "["); - } - } - for (index_t _j = 0; _j < ((j == 0) ? op.Size(1) : j); _j++) { - if (_j == 0) { - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) { - fprintf(fp, " cat(3, ...\n"); - } - else if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON) { - if (_i == 0) { - fprintf(fp, "["); - } - else { - fprintf(fp, " ["); - } - } - } - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_DEFAULT) { - fprintf(fp, "[%06" MATX_INDEX_T_FMT ",%06" MATX_INDEX_T_FMT ",:,:]\n", _i, _j); - } - for (index_t _k = 0; _k < ((k == 0) ? op.Size(2) : k); _k++) { - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) { - fprintf(fp, " "); - } - if (_k == 0) { - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) { - fprintf(fp, "["); - } - else if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON) { - if (_j == 0) { - fprintf(fp, "["); - } - else { - fprintf(fp, " ["); - } - } - } - else { - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) { - fprintf(fp, " "); - } - } - for (index_t _l = 0; _l < ((l == 0) ? op.Size(3) : l); _l++) { - if (_l == 0) { - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_DEFAULT) { - fprintf(fp, "%06" MATX_INDEX_T_FMT ": ", _k); - } - else if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON) { - if (_k == 0) { - fprintf(fp, "["); - } - else { - fprintf(fp, " ["); - } - } - } - - PrintVal(fp, op.operator()(_i, _j, _k, _l)); - - if (_l == (op.Size(3)-1)) { - if (_k == (op.Size(2)-1)) { - if (_j == (op.Size(1)-1)) { - if (_i == (op.Size(0)-1)) { - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) { - fprintf(fp, "]))\n"); - } - else if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON) { - fprintf(fp, "]]]]"); - } - } - else { - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) { - fprintf(fp, "]), ..."); - } - else if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON) { - fprintf(fp, "]]],"); - } - } - } - else { - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) { - fprintf(fp, "], ..."); - } - else if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON) { - fprintf(fp, "]],"); - } - } - } - else { - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) { - fprintf(fp, "; ..."); - } - else if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON) { - fprintf(fp, "],"); - } - } - } - else { - if ((PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) || (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON)) { - fprintf(fp, ", "); - } - } - } - fprintf(fp, "\n"); - } - if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_DEFAULT) { - fprintf(fp, "\n"); - } - } + else if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_MLAB) { + PrintMlabCat<0>(fp, op, extents, idx); + fprintf(fp, "\n\n"); + } + else if (PRINT_FORMAT_TYPE == MATX_PRINT_FORMAT_PYTHON) { + PrintPythonRecursive<0>(fp, op, extents, idx); + fprintf(fp, "\n"); } } } diff --git a/test/00_io/PrintTests.cu b/test/00_io/PrintTests.cu index b07bb8e63..7662c98ea 100644 --- a/test/00_io/PrintTests.cu +++ b/test/00_io/PrintTests.cu @@ -188,6 +188,35 @@ TEST_F(PrintTest, DefaultTest4) MATX_EXIT_HANDLER(); } +TEST_F(PrintTest, DefaultTest5D) +{ + MATX_ENTER_HANDLER(); + auto pft = get_print_format_type(); + ASSERT_EQ(MATX_PRINT_FORMAT_DEFAULT, pft); + + auto A5 = reshape(A1, {2,2,1,2,2}); + + print_checker(A5, + "Operator{complex} Rank: 5, Sizes:[2, 2, 1, 2, 2]\n" + "[000000,000000,000000,:,:]\n" + "000000: -9.2466e-01+9.9114e-01j -4.2534e-01+1.0676e+00j \n" + "000001: -2.6438e+00-6.2723e-01j 1.4518e-01+3.2016e-01j \n" + "\n" + "[000000,000001,000000,:,:]\n" + "000000: -1.2087e-01-3.1101e-01j -5.7973e-01-3.4408e-01j \n" + "000001: -6.2285e-01-1.1709e+00j -3.2839e-01-5.3706e-01j \n" + "\n" + "[000001,000000,000000,:,:]\n" + "000000: -1.0745e+00+1.3390e+00j -3.6314e-01-2.4011e-01j \n" + "000001: -1.6711e+00+1.2149e+00j 2.2655e+00-2.0518e-01j \n" + "\n" + "[000001,000001,000000,:,:]\n" + "000000: 3.1168e-01+1.2999e+00j -1.8419e-01+2.1812e-01j \n" + "000001: 1.2866e+00-1.2135e+00j 1.1820e+00-1.3723e+00j \n\n"); + + MATX_EXIT_HANDLER(); +} + TEST_F(PrintTest, DefaultTest5) { MATX_ENTER_HANDLER(); @@ -297,6 +326,37 @@ TEST_F(PrintTest, MlabTest4) MATX_EXIT_HANDLER(); } + +TEST_F(PrintTest, MlabTest5D) +{ + MATX_ENTER_HANDLER(); + set_print_format_type(MATX_PRINT_FORMAT_MLAB); + auto pft = get_print_format_type(); + ASSERT_EQ(MATX_PRINT_FORMAT_MLAB, pft); + + auto A5 = reshape(A1, {2,2,1,2,2}); + + print_checker(A5, + "Operator{complex} Rank: 5, Sizes:[2, 2, 1, 2, 2]\n" + "cat(5, ...\n" + " cat(4, ...\n" + " cat(3, ...\n" + " [-9.2466e-01+9.9114e-01j , -4.2534e-01+1.0676e+00j ; ...\n" + " -2.6438e+00-6.2723e-01j , 1.4518e-01+3.2016e-01j ]), ...\n" + " cat(3, ...\n" + " [-1.2087e-01-3.1101e-01j , -5.7973e-01-3.4408e-01j ; ...\n" + " -6.2285e-01-1.1709e+00j , -3.2839e-01-5.3706e-01j ])), ...\n" + " cat(4, ...\n" + " cat(3, ...\n" + " [-1.0745e+00+1.3390e+00j , -3.6314e-01-2.4011e-01j ; ...\n" + " -1.6711e+00+1.2149e+00j , 2.2655e+00-2.0518e-01j ]), ...\n" + " cat(3, ...\n" + " [ 3.1168e-01+1.2999e+00j , -1.8419e-01+2.1812e-01j ; ...\n" + " 1.2866e+00-1.2135e+00j , 1.1820e+00-1.3723e+00j ])))\n\n"); + + MATX_EXIT_HANDLER(); +} + TEST_F(PrintTest, MlabTest5) { MATX_ENTER_HANDLER(); @@ -403,6 +463,30 @@ TEST_F(PrintTest, PythonTest4) MATX_EXIT_HANDLER(); } + +TEST_F(PrintTest, PythonTest5D) +{ + MATX_ENTER_HANDLER(); + set_print_format_type(MATX_PRINT_FORMAT_PYTHON); + auto pft = get_print_format_type(); + ASSERT_EQ(MATX_PRINT_FORMAT_PYTHON, pft); + + auto A5 = reshape(A1, {2,2,1,2,2}); + + print_checker(A5, + "Operator{complex} Rank: 5, Sizes:[2, 2, 1, 2, 2]\n" + "[[[[[-9.2466e-01+9.9114e-01j , -4.2534e-01+1.0676e+00j ],\n" + " [-2.6438e+00-6.2723e-01j , 1.4518e-01+3.2016e-01j ]]],\n" + " [[[-1.2087e-01-3.1101e-01j , -5.7973e-01-3.4408e-01j ],\n" + " [-6.2285e-01-1.1709e+00j , -3.2839e-01-5.3706e-01j ]]]],\n" + " [[[[-1.0745e+00+1.3390e+00j , -3.6314e-01-2.4011e-01j ],\n" + " [-1.6711e+00+1.2149e+00j , 2.2655e+00-2.0518e-01j ]]],\n" + " [[[ 3.1168e-01+1.2999e+00j , -1.8419e-01+2.1812e-01j ],\n" + " [ 1.2866e+00-1.2135e+00j , 1.1820e+00-1.3723e+00j ]]]]]\n"); + + MATX_EXIT_HANDLER(); +} + TEST_F(PrintTest, PythonTest5) { MATX_ENTER_HANDLER(); diff --git a/test/00_operators/print_test.cu b/test/00_operators/print_test.cu index 57140071d..7538e3c39 100644 --- a/test/00_operators/print_test.cu +++ b/test/00_operators/print_test.cu @@ -18,5 +18,17 @@ TYPED_TEST(OperatorTestsFloatAllExecs, Print) auto t3 = matx::make_tensor({3, 2, 20}); print(matx::ones(t3.Shape()), 1, 0, 2); + auto t5 = matx::make_tensor({2, 2, 2, 2, 2}); + auto r5 = matx::ones(t5.Shape()); + print(r5, 1, 0, 0, 0, 2); + + set_print_format_type(MATX_PRINT_FORMAT_MLAB); + print(r5, 1, 0, 0, 0, 2); + + set_print_format_type(MATX_PRINT_FORMAT_PYTHON); + print(r5, 1, 0, 0, 0, 2); + + set_print_format_type(MATX_PRINT_FORMAT_DEFAULT); + MATX_EXIT_HANDLER(); -} \ No newline at end of file +}