-
Notifications
You must be signed in to change notification settings - Fork 66
Let getFramesAtIndices rely on getFrameAtIndex #278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
NicolasHug
merged 22 commits into
meta-pytorch:main
from
NicolasHug:getFramesAtIndices_cleanup
Oct 18, 2024
Merged
Let getFramesAtIndices rely on getFrameAtIndex #278
NicolasHug
merged 22 commits into
meta-pytorch:main
from
NicolasHug:getFramesAtIndices_cleanup
Oct 18, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This reverts commit 8e06aa6.
…rchcodec into pass_preallocated_tensors
ahmadsharif1
approved these changes
Oct 18, 2024
Contributor
ahmadsharif1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you run the benchmark just to be paranoid?
Contributor
Author
|
On main: This PR: import torch
from time import perf_counter_ns
from torchcodec.decoders._core import (
_add_video_stream,
create_from_file,
get_frames_at_indices,
scan_all_streams_to_update_metadata,
)
import torch
from time import perf_counter_ns
def bench(f, color_conversion_library, num_exp=100):
times = []
for _ in range(num_exp):
VIDEO_PATH = "./test/resources/nasa_13013.mp4"
decoder = create_from_file(VIDEO_PATH)
_add_video_stream(
decoder,
color_conversion_library=color_conversion_library,
)
scan_all_streams_to_update_metadata(decoder)
start = perf_counter_ns()
f(decoder)
end = perf_counter_ns()
times.append(end - start)
return torch.tensor(times).float()
def report_stats(times, unit="ms"):
mul = {
"ns": 1,
"µs": 1e-3,
"ms": 1e-6,
"s": 1e-9,
}[unit]
times = times * mul
std = times.std().item()
med = times.median().item()
print(f"{med = :.2f}{unit} +- {std:.2f}")
return med
NUM_EXP = 100
stream_index=3
frame_indices = list(range(100))
def _get_frames_at_indices(decoder):
get_frames_at_indices(decoder=decoder, stream_index=stream_index, frame_indices=frame_indices)
for color_conversion_library in ("swscale", "filtergraph"):
print(color_conversion_library)
times = bench(_get_frames_at_indices, color_conversion_library=color_conversion_library, num_exp=NUM_EXP)
report_stats(times) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Small refactor discussed in #260