Skip to content

Conversation

@tenpercent
Copy link
Contributor

@tenpercent tenpercent commented Jan 19, 2026

Summary

Add Google Tests for the optimized template utilities from the PR stack to ensure correctness and prevent regressions.

Tests Added

Test File Tests Coverage
unit_sequence.cpp 4 new sequence_gen with custom functors
unit_sequence_helper.cpp 18 new generate_identity_sequences, find_in_tuple_of_sequences, sequence_find_value, unpack_and_merge_sequences
unit_container_helper.cpp 12 new container_concat, make_uniform_tuple
unit_tensor_descriptor_helper.cpp 18 new make_naive_tensor_descriptor, make_naive_tensor_descriptor_packed, make_naive_tensor_descriptor_aligned

Total: 52 new tests

Test Coverage by PR

PR Stack

# PR Description
1 #3585 sequence_gen with __make_integer_seq
2 #3588 generate_identity_sequences helper
3 #3589 Named functors in transform_tensor_descriptor
4 #3590 container_concat optimization
5 #3596 O(1) pack expansion rewrites
6 #3600 TensorDescriptor/TensorAdaptor lambda elimination
7 #3608 Build time optimization documentation
8 This PR Unit tests for optimization helpers

Tracking issue: #3575

@tenpercent tenpercent force-pushed the mpodkory/template-optimization-tests branch from 1e1fac9 to 8d2b954 Compare January 19, 2026 22:40
@tenpercent tenpercent force-pushed the mpodkory/build-time-docs branch 2 times, most recently from 9b5a7fa to 867fae3 Compare January 20, 2026 00:15
@tenpercent tenpercent force-pushed the mpodkory/template-optimization-tests branch 2 times, most recently from 69144aa to 0b35651 Compare January 20, 2026 00:31
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.
@tenpercent tenpercent force-pushed the mpodkory/template-optimization-tests branch from 0b35651 to 0c81883 Compare January 20, 2026 00:35
@tenpercent tenpercent force-pushed the mpodkory/build-time-docs branch 6 times, most recently from 97983c9 to ecef7c8 Compare January 20, 2026 01:04
@tenpercent tenpercent force-pushed the mpodkory/build-time-docs branch 2 times, most recently from 80c4f97 to 71413bd Compare January 20, 2026 01:14
Copy link
Collaborator

@shumway shumway left a 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).
@tenpercent tenpercent force-pushed the mpodkory/template-optimization-tests branch from b65bf17 to af1f05e Compare January 20, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants