-
Notifications
You must be signed in to change notification settings - Fork 267
Add unit tests for template optimization helpers #3610
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
base: mpodkory/build-time-docs
Are you sure you want to change the base?
Add unit tests for template optimization helpers #3610
Conversation
1e1fac9 to
8d2b954
Compare
9b5a7fa to
867fae3
Compare
69144aa to
0b35651
Compare
Add Google Tests for optimized template utilities: - sequence_gen: Tests with custom functors (4 tests) - generate_identity_sequences: Tuple of identity sequences (4 tests) - find_in_tuple_of_sequences: O(1) sequence search (6 tests) - sequence_find_value: Value lookup in sequences (5 tests) - container_concat: Tuple/array concatenation (5 tests) - make_uniform_tuple: Repeated value tuples (4 tests) - compute_element_space_size: Fold expression (8 tests) - unpack_and_merge_sequences: Sequence merging (2 tests) Total: 43 new tests across 4 test files.
0b35651 to
0c81883
Compare
97983c9 to
ecef7c8
Compare
80c4f97 to
71413bd
Compare
shumway
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.
This looks good, thanks! It looks like CI failed, so we'll have to recheck. My only feedback is for the element space size:
1.Don't test implementation details (avoid namespace detail::)
2. Avoid square shapes, or at least favor rectangular cases.
3. Prime number or relatives primes can help catch more edge cases (avoid accidentally getting the right answer from a bad example
(using primes or relative primes can lead to big numbers, so you may want a simpler test case, too)
- Remove tests of implementation details (detail::compute_element_space_size) - Use public API (make_naive_tensor_descriptor) for all tests - Avoid square/cube shapes that could hide row/column major bugs - Use prime numbers for padding tests to catch index calculation errors - Add two padding test cases: arbitrary offsets and stride slice
- Add tests for make_naive_tensor_descriptor_packed (1D, 2D, 3D) - Add tests for make_naive_tensor_descriptor_aligned (2D, 3D) - Add 1D tensor tests with explicit strides - Ensure all shapes use distinct, coprime dimensions
- Vary sequence values across all tests to avoid repetition - Use prime numbers for distinct, coprime test data - Add TwoSequences test for unpack_and_merge_sequences
- Replace repeated 1,2,3,4 values with unique primes - Each test now uses distinct input values
Test high-dimensional tensors to verify no integer overflow in element space size calculations. Includes: - 8D packed test with prime dimensions (180180 elements) - 8D permuted layout test with non-monotonous strides (memory order differs from logical order)
Tests element space size calculation when two non-adjacent middle dimensions (dims 2 and 4) have stride 0 (broadcast).
b65bf17 to
af1f05e
Compare
Summary
Add Google Tests for the optimized template utilities from the PR stack to ensure correctness and prevent regressions.
Tests Added
unit_sequence.cppsequence_genwith custom functorsunit_sequence_helper.cppgenerate_identity_sequences,find_in_tuple_of_sequences,sequence_find_value,unpack_and_merge_sequencesunit_container_helper.cppcontainer_concat,make_uniform_tupleunit_tensor_descriptor_helper.cppmake_naive_tensor_descriptor,make_naive_tensor_descriptor_packed,make_naive_tensor_descriptor_alignedTotal: 52 new tests
Test Coverage by PR
sequence_genwith__make_integer_seqgenerate_identity_sequenceshelpercontainer_concat,make_uniform_tuplemake_naive_tensor_descriptorpublic APIfind_in_tuple_of_sequences,sequence_find_value,unpack_and_merge_sequencesPR Stack
__make_integer_seqTracking issue: #3575