src.tests.spconv_dense_neighbor_tables_test
Classes
- class src.tests.spconv_dense_neighbor_tables_test.SpConvDenseNeighborTablesTest
- Author:
Alberto M. Esmoris Pena
Validates the dense submanifold / downsampling / upsampling neighbor tables (\(\pmb{S}\), \(\pmb{D}\), \(\pmb{U}\)) emitted by the C++ hierarchical sparse grid pre-processor when
return_neighbor_tables=Trueis requested.Each subtest builds a small synthetic point cloud, calls
vl3dpp.rf_dl_hsg_preproc_*directly, and asserts that:Shapes match the contract: \(\pmb{S}_t\) has shape \((R_t + 1) \times (2 w_t + 1)^3\), \(\pmb{D}_t\) has shape \((R_{t+1} + 1) \times (w^D_t)^3\), and \(\pmb{U}_t\) has shape \((R_t + 1) \times (w^U_t)^3\).
Row 0 (ground row) of every table is entirely zero.
For every active cell \(v\) and every kernel position \(p\), the entry \(\pmb{S}_t(v, p)\) matches an independent lookup against the hash map \(h_t\) using the same Morton-style offset arithmetic that the Python convolution layer applies — guaranteeing the
tf.gather(F, S_t)-based layers produce identical results to a per-rowsiml.lookup(omega)reference.The supported feature reduce strategies (
"mean","max","min","mode") all run without error and produce tables of the expected shape (only the encoded Fout differs between them — the neighbor tables are strategy-independent).An invalid reduce strategy raises an exception at construction time (fast-fail contract).
- __init__()
Basic configuration for any VL3D test.
- Parameters:
name (str) – Test name
- run()
Run every representative and extreme subtest. Return True if all subtests pass, False otherwise.
- subtest_representative_depth1()
Single sparse grid (max_depth=1) — only S is meaningful.
- subtest_representative_depth2()
Two-level hierarchy with the typical (w=1, wD=wU=2) config.
- subtest_representative_depth3()
Three-level hierarchy.
- subtest_representative_larger_window()
Larger submanifold window (w=2 -> 5^3=125 neighbors).
- subtest_extreme_single_depth()
Single-depth degenerate case — D and U must be empty per RF.
- subtest_extreme_minimal_rf()
Very few support points — exercises the small-RF path.
- subtest_extreme_asymmetric_windows()
Larger downsampling / upsampling window (wD=wU=3).
- subtest_reduce_strategy(strategy)
Every supported reduce strategy must run and produce S/D/U.
- subtest_reduce_strategy_parity()
Reduce strategies must actually change Fout. Run the pre-processor twice with identical inputs but two different strategies and confirm the encoded features differ on at least one cell. Without this assertion, the strategy argument could be silently ignored and the test would still pass on every other subtest.
- subtest_invalid_reduce_strategy()
An unsupported reduce strategy must raise an exception.
- run_validation(cell_size, w, wD, wU, sD, sU, num_points, cube_extent, seed, return_tables, reduce_strategy)
End-to-end subtest: build inputs, call the C++ pre-processor with return_neighbor_tables enabled, and validate the produced tables against independent hash-map lookups.
- build_and_extract(cell_size, w, wD, wU, sD, sU, num_points, cube_extent, seed, return_tables, reduce_strategy)
Build a synthetic point cloud, call the C++ pre-processor, and package each receptive field’s outputs into a single dict for downstream validation.
- validate_submanifold_table(rf, depth)
Verify every entry of S_t against an independent h_t lookup.
- validate_downsampling_table(rf, depth)
Verify every entry of D_t against an independent h_t lookup.
- validate_upsampling_table(rf, depth)
Verify every entry of U_t against an independent h_{t+1} lookup.