-
Notifications
You must be signed in to change notification settings - Fork 64
Add more cuda tests #326
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
Add more cuda tests #326
Conversation
test/utils.py
Outdated
|
||
# Asserts that at least `percentage`% of the values are within the absolute tolerance. | ||
def assert_tensor_close_on_at_least(frame1, frame2, percentage=99.7, abs_tolerance=20): | ||
def assert_tensor_close_on_at_least(frame1, frame2, percentage=90, abs_tolerance=20): |
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.
Since the default tolerance has changed, did that implicitly changed the tolerance of the existing calls as well? E.g. the ones introduced in https://github.com/pytorch/torchcodec/pull/319/files has a stricter tolerance IIUC - we may need to update those?
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.
I am fine using higher tolerances for those too -- as they may have different values for different GPU models anyway
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.
Thanks @ahmadsharif1
IIUC this PR mostly tests get_frames_at_indices
, get_frames_displayed_at
and get_frames_in_range
.
But for coverage we probably want to also parametrize the existing tests for get_frame_at
, get_frame_displayed_at
, get_next_frame()
, etc.
And we'll also want to add tests to the public decoder class.
I can address those in a follow-up if you'd like
def test_get_frames_at_indices(self): | ||
@pytest.mark.parametrize("device", cpu_and_cuda()) | ||
def test_get_frames_at_indices(self, device): | ||
tensor_compare_function = get_frame_compare_function(device) |
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.
Nit: here and everywhere below, call this frame_compare_function
Thanks. Actually I just realized that in doing all the test refactors I missed a very important check -- we don't actually check that the frame is on the correct device. @NicolasHug do you have any opinions on how it should be done. I think we can even have a function like Within that function we can 1) assert frame is on device and 2) use the correct comparison function -- i.e. approximately equal for cuda and exactly equal for CPU Thoughts? As far as more tests are concerned, you (or I) can address those later. But let's align on the overall testing flow for cuda tests including testing the device and tensor values both. |
This addresses comments:
#319 (comment)
#319 (comment)
I was not able to reuse the logic in the
needs_cuda()
decorator so I just duplicated that logic. If someone has better ideas let me know and I can incorporate them.