Skip to content

Commit 97a95d7

Browse files
eigen-kfacebook-github-bot
authored andcommitted
Use GraphBuilder in reorder unit tests. (#11103)
Summary: Pull Request resolved: #11103 Use GraphBuilder in reorder unit tests. Reviewed By: zonglinpeng Differential Revision: D75257222
1 parent 4014cc6 commit 97a95d7

File tree

3 files changed

+390
-189
lines changed

3 files changed

+390
-189
lines changed

backends/cadence/aot/TARGETS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ python_unittest(
388388
"//caffe2:torch",
389389
"//executorch/backends/cadence/aot:compiler",
390390
"//executorch/backends/cadence/aot:fuse_ops",
391+
"//executorch/backends/cadence/aot:graph_builder",
391392
"//executorch/backends/cadence/aot:ops_registrations",
392393
"//executorch/backends/cadence/aot:pass_utils",
393394
"//executorch/backends/cadence/aot:reorder_ops",

backends/cadence/aot/pass_utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,19 @@ def nodes_not_connected_in_gm(
144144
return True
145145

146146

147+
# Returns the position of the first entry of a node of a given kind in the graph.
148+
def get_node_pos(
149+
graph_module: torch.fx.GraphModule,
150+
target: torch.fx.Node,
151+
) -> int:
152+
pos = 0
153+
for node in graph_module.graph.nodes:
154+
if node.target == target:
155+
return pos
156+
pos += 1
157+
return -1
158+
159+
147160
# Returns true if there is no instance of a node with target succ_target
148161
# positioned immediately after a node with target pred_target in the graph
149162
def nodes_not_adjacent_in_gm(

0 commit comments

Comments
 (0)