Skip to content

Commit d783d9f

Browse files
eigen-kfacebook-github-bot
authored andcommitted
Use GraphBuilder in reorder unit tests.
Summary: Use GraphBuilder in reorder unit tests. Differential Revision: D75257323
1 parent 49805bd commit d783d9f

File tree

4 files changed

+361
-190
lines changed

4 files changed

+361
-190
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/compiler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ def quantize_and_export_to_cadence(
343343
"""
344344
quantized_model = quantize_pt2(model, inputs)
345345

346+
import fbvscode
347+
fbvscode.set_trace()
348+
346349
return _lower_ep_to_cadence(
347350
quantized_model,
348351
opt_level=opt_level,

backends/cadence/aot/pass_utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,18 @@ def nodes_not_connected_in_gm(
143143
return False
144144
return True
145145

146+
# Returns the position of the first entry of a node of a given kind in the graph.
147+
def get_node_pos(
148+
graph_module: torch.fx.GraphModule,
149+
target: torch.fx.Node,
150+
) -> int:
151+
pos = 0
152+
for node in graph_module.graph.nodes:
153+
if node.target == target:
154+
return pos
155+
pos += 1
156+
return -1
157+
146158

147159
# Returns true if there is no instance of a node with target succ_target
148160
# positioned immediately after a node with target pred_target in the graph

0 commit comments

Comments
 (0)