Add unit tests for template optimization helpers#3610
Closed
tenpercent wants to merge 8 commits intompodkory/build-time-docsfrom
Closed
Add unit tests for template optimization helpers#3610tenpercent wants to merge 8 commits intompodkory/build-time-docsfrom
tenpercent wants to merge 8 commits intompodkory/build-time-docsfrom
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
reviewed
Jan 20, 2026
shumway
reviewed
Jan 20, 2026
shumway
reviewed
Jan 20, 2026
shumway
reviewed
Jan 20, 2026
shumway
reviewed
Jan 20, 2026
shumway
reviewed
Jan 20, 2026
Collaborator
shumway
left a comment
There was a problem hiding this comment.
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)
shumway
reviewed
Jan 20, 2026
shumway
reviewed
Jan 20, 2026
- 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
e814786 to
ad15f55
Compare
Contributor
Author
|
Closing this PR as all unit tests have been distributed to their respective PRs:
All PRs now include their own tests and target develop independently. |
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
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.
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