Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions backends/cadence/aot/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ def _lower_ep_to_edge(
"""
Lower an ExportedProgram to an EdgeProgramManager (in edge IR).
"""
# Apply passes which transform the ExportedProgram before it gets lowered to edge.
expo_program = apply_torch_ops_passes(expo_program)

# Call to_edge to convert the graph to edge IR.
# Note: dim_order is skipped (https://github.com/pytorch/executorch/issues/3704)
edge_prog_manager = to_edge(
Expand Down Expand Up @@ -263,9 +266,6 @@ def export_to_edge(
# Export the model into an ExportedProgram.
expo_program = trace(model, inputs)

# Apply passes which transform the ExportedProgram before it gets lowered to edge.
expo_program = apply_torch_ops_passes(expo_program)

# Lower the model to edge IR.
edge_prog_manager = _lower_ep_to_edge(
expo_program, dump_graphs, constant_methods, core_aten_exceptions
Expand Down
7 changes: 5 additions & 2 deletions backends/cadence/aot/replace_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -2328,12 +2328,15 @@ def call(self, graph_module: torch.fx.GraphModule) -> PassResult:

# Extract an argument to a separate full op.
with graph_module.graph.inserting_before(mul_node):
full_tensor = graph_module.graph.call_function(
full_node = graph_module.graph.call_function(
torch.ops.aten.full.default, args=([1], full_arg)
)
full_node.meta = mul_node.meta
full_node.meta["val"] = [1]
new_mul_node = graph_module.graph.call_function(
torch.ops.aten.mul.Tensor, args=(x_arg, full_tensor)
torch.ops.aten.mul.Tensor, args=(x_arg, full_node)
)
new_mul_node.meta = mul_node.meta
# Replace the old mul with a newly created mul.
mul_node.replace_all_uses_with(new_mul_node)
graph_module.graph.erase_node(mul_node)
Expand Down
Loading