Add UnitVector tensor refinement - #9515
Conversation
Merging this PR will improve performance by 15.74%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | take[duplicates/repeated/primitive/nonnull/chunks=16/indices=1000] |
270.2 µs | 228.9 µs | +18.07% |
| ⚡ | WallTime | words_gather_scalar[65536] |
9.4 µs | 8.3 µs | +13.46% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing ct/unit-vector-refinement (b1fb0a4) with ct/norm-compute-mode (4c3a203)2
Footnotes
-
872 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
-
No successful run was found on
ct/norm-compute-mode(76656f1) during the generation of this report, so 1d57c92 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
1ea7761 to
b1fb0a4
Compare
Rationale for this change
Adds a logical refinement for unit-normalized vectors on top of #9513.
NormMode::AssumeNormalizedcan trust the approximate refinement for faster norm and cosine operations, while exact mode continues to measure the physical values.What changes are included in this PR?
Adds the checked
UnitVectordtype, mixed vector operation support, and anL2Normalizescalar function. Zero vectors normalize to null because they do not have a direction.What APIs are changed? Are there any user-facing changes?
Adds
UnitVectorandL2Normalize, and permitsVectorandUnitVectorinputs in the same inner-product and cosine operation. The existingNormalizedphysical encoding and metadata stay unchanged.