use ggml_backend_tensor_copy

This commit is contained in:
ngxson 2024-06-12 11:41:37 +02:00
parent e9cb3b336d
commit 7297817d13

View file

@ -290,17 +290,13 @@ static void power_iteration(
if (calc_square) { if (calc_square) {
// copy and store the square matrix if needed // copy and store the square matrix if needed
GGML_ASSERT(result.calculated_square != NULL); GGML_ASSERT(result.calculated_square != NULL);
std::vector<uint8_t> tmp_buf(ggml_nbytes(model.dev_square)); ggml_backend_tensor_copy(result.calculated_square, model.dev_square);
ggml_backend_tensor_get(result.calculated_square, tmp_buf.data(), 0, tmp_buf.size());
ggml_backend_tensor_set(model.dev_square, tmp_buf.data(), 0, tmp_buf.size());
} }
{ {
// copy last eigen vector and store as input for next iteration // copy last eigen vector and store as input for next iteration
GGML_ASSERT(last_eigenvector != NULL); GGML_ASSERT(last_eigenvector != NULL);
std::vector<uint8_t> tmp_buf(ggml_nbytes(last_eigenvector)); ggml_backend_tensor_copy(last_eigenvector, model.dev_eigenvector);
ggml_backend_tensor_get(last_eigenvector, tmp_buf.data(), 0, tmp_buf.size());
ggml_backend_tensor_set(model.dev_eigenvector, tmp_buf.data(), 0, tmp_buf.size());
} }
printf("%s: layer %d/%d, iteration: %d / total: %d (batch = %d) ...\n", printf("%s: layer %d/%d, iteration: %d / total: %d (batch = %d) ...\n",