| 71 | |
| 72 | template<typename T> |
| 73 | static void print(const char *exp, af_array arr, const int precision, |
| 74 | std::ostream &os = std::cout, bool transpose = true) { |
| 75 | if (exp == NULL) { |
| 76 | os << "No Name Array" << std::endl; |
| 77 | } else { |
| 78 | os << exp << std::endl; |
| 79 | } |
| 80 | |
| 81 | const ArrayInfo &info = getInfo(arr); |
| 82 | |
| 83 | std::ios_base::fmtflags backup = os.flags(); |
| 84 | |
| 85 | os << "[" << info.dims() << "]\n"; |
| 86 | #ifndef NDEBUG |
| 87 | os << " Offset: " << info.getOffset() << std::endl; |
| 88 | os << " Strides: [" << info.strides() << "]" << std::endl; |
| 89 | #endif |
| 90 | |
| 91 | // Handle empty array |
| 92 | if (info.elements() == 0) { |
| 93 | os << "<empty>" << std::endl; |
| 94 | os.flags(backup); |
| 95 | return; |
| 96 | } |
| 97 | |
| 98 | vector<T> data(info.elements()); |
| 99 | |
| 100 | af_array arrT; |
| 101 | if (transpose) { |
| 102 | AF_CHECK(af_reorder(&arrT, arr, 1, 0, 2, 3)); |
| 103 | } else { |
| 104 | arrT = arr; |
| 105 | } |
| 106 | |
| 107 | // FIXME: Use alternative function to avoid copies if possible |
| 108 | AF_CHECK(af_get_data_ptr(&data.front(), arrT)); |
| 109 | const ArrayInfo &infoT = getInfo(arrT); |
| 110 | |
| 111 | printer(os, &data.front(), infoT, infoT.ndims() - 1, precision); |
| 112 | |
| 113 | if (transpose) { AF_CHECK(af_release_array(arrT)); } |
| 114 | |
| 115 | os.flags(backup); |
| 116 | } |
| 117 | |
| 118 | template<typename T> |
| 119 | static void printSparse(const char *exp, af_array arr, const int precision, |
nothing calls this directly
no test coverage detected