Skip to content

Commit 7297817

Browse files
committed
use ggml_backend_tensor_copy
1 parent e9cb3b3 commit 7297817

File tree

1 file changed

+2
-6
lines changed
  • examples/control-vector-generator

1 file changed

+2
-6
lines changed

examples/control-vector-generator/pca.hpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,17 +290,13 @@ static void power_iteration(
290290
if (calc_square) {
291291
// copy and store the square matrix if needed
292292
GGML_ASSERT(result.calculated_square != NULL);
293-
std::vector<uint8_t> tmp_buf(ggml_nbytes(model.dev_square));
294-
ggml_backend_tensor_get(result.calculated_square, tmp_buf.data(), 0, tmp_buf.size());
295-
ggml_backend_tensor_set(model.dev_square, tmp_buf.data(), 0, tmp_buf.size());
293+
ggml_backend_tensor_copy(result.calculated_square, model.dev_square);
296294
}
297295

298296
{
299297
// copy last eigen vector and store as input for next iteration
300298
GGML_ASSERT(last_eigenvector != NULL);
301-
std::vector<uint8_t> tmp_buf(ggml_nbytes(last_eigenvector));
302-
ggml_backend_tensor_get(last_eigenvector, tmp_buf.data(), 0, tmp_buf.size());
303-
ggml_backend_tensor_set(model.dev_eigenvector, tmp_buf.data(), 0, tmp_buf.size());
299+
ggml_backend_tensor_copy(last_eigenvector, model.dev_eigenvector);
304300
}
305301

306302
printf("%s: layer %d/%d, iteration: %d / total: %d (batch = %d) ...\n",

0 commit comments

Comments
 (0)