Skip to content

Commit de517c5

Browse files
Dan-FloresDaniel Flores
andauthored
Avoid copies of frame mappings (#785)
Co-authored-by: Daniel Flores <[email protected]>
1 parent a98c032 commit de517c5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/torchcodec/_core/custom_ops.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ OpsFrameOutput makeOpsFrameOutput(FrameOutput& frame) {
108108
SingleStreamDecoder::FrameMappings makeFrameMappings(
109109
std::tuple<at::Tensor, at::Tensor, at::Tensor> custom_frame_mappings) {
110110
return SingleStreamDecoder::FrameMappings{
111-
std::get<0>(custom_frame_mappings),
112-
std::get<1>(custom_frame_mappings),
113-
std::get<2>(custom_frame_mappings)};
111+
std::move(std::get<0>(custom_frame_mappings)),
112+
std::move(std::get<1>(custom_frame_mappings)),
113+
std::move(std::get<2>(custom_frame_mappings))};
114114
}
115115

116116
// All elements of this tuple are tensors of the same leading dimension. The
@@ -281,7 +281,7 @@ void add_video_stream(
281281
std::optional<std::string_view> dimension_order = std::nullopt,
282282
std::optional<int64_t> stream_index = std::nullopt,
283283
std::optional<std::string_view> device = std::nullopt,
284-
std::optional<std::tuple<at::Tensor, at::Tensor, at::Tensor>>
284+
const std::optional<std::tuple<at::Tensor, at::Tensor, at::Tensor>>&
285285
custom_frame_mappings = std::nullopt) {
286286
_add_video_stream(
287287
decoder,

0 commit comments

Comments
 (0)