| 29 | } |
| 30 | |
| 31 | void print_tensor(const std::string & name, const struct ggml_tensor * tensor) { |
| 32 | const auto values = read_tensor(tensor); |
| 33 | const int64_t cols = tensor->ne[0]; |
| 34 | const int64_t rows = tensor->ne[1]; |
| 35 | |
| 36 | std::cout << name << " (" << rows << "x" << cols << ")\n"; |
| 37 | for (int64_t row = 0; row < rows; ++row) { |
| 38 | std::cout << " ["; |
| 39 | for (int64_t col = 0; col < cols; ++col) { |
| 40 | const auto index = static_cast<size_t>(row * cols + col); |
| 41 | std::cout << std::fixed << std::setprecision(4) << values[index]; |
| 42 | if (col + 1 < cols) { |
| 43 | std::cout << ", "; |
| 44 | } |
| 45 | } |
| 46 | std::cout << "]\n"; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | } // namespace |
| 51 | |