From e7c7f1e6b3c97d1e12e6772139d453b650030d04 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 13 Mar 2024 18:27:24 -0700 Subject: [PATCH] Pass by const reference --- ext/torch/torch.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/torch/torch.cpp b/ext/torch/torch.cpp index 1aa1e8e..c56bd14 100644 --- a/ext/torch/torch.cpp +++ b/ext/torch/torch.cpp @@ -9,7 +9,7 @@ #include "utils.h" template -torch::Tensor make_tensor(Rice::Array a, std::vector size, const torch::TensorOptions &options) { +torch::Tensor make_tensor(Rice::Array a, const std::vector &size, const torch::TensorOptions &options) { std::vector vec; for (long i = 0; i < a.size(); i++) { vec.push_back(Rice::detail::From_Ruby().convert(a[i].value())); @@ -74,13 +74,13 @@ void init_torch(Rice::Module& m) { }) .define_singleton_function( "_from_blob", - [](Rice::String s, std::vector size, const torch::TensorOptions &options) { + [](Rice::String s, const std::vector &size, const torch::TensorOptions &options) { void *data = const_cast(s.c_str()); return torch::from_blob(data, size, options); }) .define_singleton_function( "_tensor", - [](Rice::Array a, std::vector size, const torch::TensorOptions &options) { + [](Rice::Array a, const std::vector &size, const torch::TensorOptions &options) { auto dtype = options.dtype(); if (dtype == torch::kByte) { return make_tensor(a, size, options);