-
Notifications
You must be signed in to change notification settings - Fork 12.6k
test-backend-ops: enables perf/eval testing of composite ops #14833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for testing computation graphs "composite ops" in test-backend-ops, enabling performance and correctness evaluation of fused operations compared to indirect implementations. This is useful for op development when the direct implementation doesn't exist on CPU but can be tested via equivalent computation graphs.
- Introduces
test_case_compare
class for comparing outputs between different operation implementations - Adds support for composite operation performance testing with proper node duplication logic
- Implements example comparison between direct CONV_2D and im2col-based CONV_2D implementations
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
File | Description |
---|---|
tests/test-backend-ops.cpp | Main implementation adding composite op testing infrastructure and CONV_2D comparison examples |
ggml/src/ggml-backend.cpp | Adds new function for comparing outputs between two different computation graphs |
ggml/include/ggml-backend.h | Declares the new graph comparison function in the public API |
This patch adds support for testing computation graphs "composite ops" in
test-backend-ops
.This is useful
Currently out of the tree code is used to test the correctness (#14316 or #14316) or non-standardized out-of-tree vibe coded standalone gists added to test the performance in #14388 (comment).
In particular, this PR enables
An example is when we compare the output of
CONV_2D
(direct conv implementation) with theggml_conv_2d
(indirect conv implementation as the latter contains im2col followed by a mul_mat in the resulting graph).To test output of an op against a graph, the user needs to add a test case for the graph and the actual op, then they need to subclass a
test_case_compare : public test_case
that accepts the two test cases in the constructor. The tensor name assignment should be defined intest_case_compare
to let theeval()
function know how to copy the inputs between the two graphs before execution. The output nodes will then be compared after execution.When testing the perf of a graph, the
get_input_names
oftest_case
should be overwritten to return the name of the input tensors that will be used byeval_perf
to know which nodes should be duplicated. The default implementation returns an empty list andeval_perf
assumes that the graph tests a regular op containing only the input nodes connected to a single output node doing the actual calculation, so only the output will be duplicated in this case.