static void print(af_array arr) { const ArrayInfo info = getInfo(arr); T *data = new T[info.elements()]; af_array arrT; AF_CHECK(af_reorder(&arrT, arr, 1, 0, 2, 3)); //FIXME: Use alternative function to avoid copies if possible AF_CHECK(af_get_data_ptr(data, arrT)); const ArrayInfo infoT = getInfo(arrT); AF_CHECK(af_destroy_array(arrT)); std::ios_base::fmtflags backup = std::cout.flags(); std::cout << "[" << info.dims() << "]\n"; #ifndef NDEBUG std::cout <<" Offsets: ["<<info.offsets()<<"]"<<std::endl; std::cout <<" Strides: ["<<info.strides()<<"]"<<std::endl; #endif printer(std::cout, data, infoT, infoT.ndims() - 1); delete[] data; std::cout.flags(backup); }
static void print(const char *exp, af_array arr, const int precision, std::ostream &os = std::cout, bool transpose = true) { if(exp == NULL) { os << "No Name Array" << std::endl; } else { os << exp << std::endl; } const ArrayInfo info = getInfo(arr); vector<T> data(info.elements()); af_array arrT; if(transpose) { AF_CHECK(af_reorder(&arrT, arr, 1, 0, 2, 3)); } else { arrT = arr; } //FIXME: Use alternative function to avoid copies if possible AF_CHECK(af_get_data_ptr(&data.front(), arrT)); const ArrayInfo infoT = getInfo(arrT); if(transpose) { AF_CHECK(af_release_array(arrT)); } std::ios_base::fmtflags backup = os.flags(); os << "[" << info.dims() << "]\n"; #ifndef NDEBUG os <<" Offsets: [" << info.offsets() << "]" << std::endl; os <<" Strides: [" << info.strides() << "]" << std::endl; #endif printer(os, &data.front(), infoT, infoT.ndims() - 1, precision); os.flags(backup); }