Skip to content

Commit b2f46c0

Browse files
qukhanxnnpack-bot
authored andcommitted
Add a matcher to to check whether two graph are isomorphic.
The goal of this matcher is to indicate whether a rewrite actually does what we think it does. We check for graph isomorphism, i.e. that two `xnn_subgraph_t` represent the same graph, even though the in-memory representation may be different (the `nodes` order for instance). We take advantage of the fact that our graphs are directed and acyclic to define a strict order on nodes and sort them. PiperOrigin-RevId: 908083693
1 parent 5aa5d64 commit b2f46c0

4 files changed

Lines changed: 814 additions & 0 deletions

File tree

test/subgraph/rewrites/BUILD

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# This source code is licensed under the BSD-style license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
load(
7+
"//:build_defs.bzl",
8+
"xnnpack_cxx_library",
9+
"xnnpack_unit_test",
10+
)
11+
12+
package(default_visibility = ["//:__subpackages__"])
13+
14+
xnnpack_cxx_library(
15+
name = "subgraph_matcher",
16+
testonly = True,
17+
srcs = ["subgraph_matcher.cc"],
18+
hdrs = ["subgraph_matcher.h"],
19+
deps = [
20+
"//:cache",
21+
"//:logging",
22+
"//:node_type",
23+
"//:operator_utils",
24+
"//:subgraph",
25+
"//:xnnpack_h",
26+
"@com_google_googletest//:gtest", # no g3
27+
],
28+
)
29+
30+
xnnpack_unit_test(
31+
name = "subgraph_matcher_test",
32+
srcs = ["subgraph_matcher_test.cc"],
33+
deps = [
34+
":subgraph_matcher",
35+
"//litert/tensor",
36+
"//litert/tensor:arithmetic",
37+
"//litert/tensor:datatypes",
38+
"//litert/tensor/backends/xnnpack:conversion",
39+
"//litert/tensor/utils:matchers_no_g3",
40+
],
41+
)

0 commit comments

Comments
 (0)