Skip to content

Commit 1e24ed6

Browse files
author
Daniel Flores
committed
use cpu accessor
1 parent 9fe5d58 commit 1e24ed6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/torchcodec/_core/SingleStreamDecoder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,10 @@ void SingleStreamDecoder::readCustomFrameMappingsUpdateMetadataAndIndex(
336336
int64_t numFrames = all_frames.size(0);
337337
streamInfos_[streamIndex].allFrames.reserve(numFrames);
338338
streamInfos_[streamIndex].keyFrames.reserve(numFrames);
339-
// Access tensor data directly rather than element wise to speed up loop below
340-
auto* pts_data = all_frames.data_ptr<int64_t>();
341-
auto* is_key_frame_data = is_key_frame.data_ptr<bool>();
342-
auto* duration_data = duration.data_ptr<int64_t>();
339+
// Use accessor to efficiently access tensor elements
340+
auto pts_data = all_frames.accessor<int64_t, 1>();
341+
auto is_key_frame_data = is_key_frame.accessor<bool, 1>();
342+
auto duration_data = duration.accessor<int64_t, 1>();
343343

344344
auto& streamMetadata = containerMetadata_.allStreamMetadata[streamIndex];
345345

0 commit comments

Comments
 (0)