Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces secure join operations (join_uu_ss, join_uu_vv, and join_un) to the HAL layer, supported by new MPC kernels and extensive unit tests. Key improvements include an O(1) lookup optimization for permutation solving in the MPC utility layer. Feedback identifies a potential shape mismatch bug in the associative_reduce utility, significant code duplication between join variants that warrants refactoring, and several instances of dead or commented-out code that should be addressed for better maintainability.
|
|
||
| // Edge case: if the last dimension has <= 1 element or tensor is empty | ||
| if (N < 2 || shape.numel() == 0) { | ||
| return in; |
There was a problem hiding this comment.
The early return here can lead to a shape mismatch. The function is expected to return a tensor with the last dimension reduced, but when N < 2, it returns the input tensor in unmodified. For example, if in has a shape of (M, 1), the expected output shape is (M), but this will return a tensor of shape (M, 1). This can be fixed by reshaping the output before returning.
| return in; | |
| return hal::reshape(ctx, in, out_shape); |
|
|
||
| // Secure _join_uu_ss | ||
| // Ref: https://dl.acm.org/doi/10.1145/3372297.3423358 (figure 6) | ||
| std::vector<spu::Value> join_uu_ss(SPUContext* ctx, |
There was a problem hiding this comment.
There is significant code duplication between join_uu_ss and join_uu_vv. For example, steps 3 through 7 (permuting tables, comparison, handling payload, and final result aggregation) are nearly identical. This duplication makes the code harder to maintain.
Consider refactoring the common logic into a helper function to reduce duplication and improve maintainability. This helper could be parameterized (e.g., with lambdas) to handle the minor differences between the two functions, such as how values are created (hal::seal vs hal::_p2v).
Pull Request
What problem does this PR solve?
Issue Number: Fixed #
Possible side effects?
Performance:
Backward compatibility: