Skip to content
Closed
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
23 changes: 16 additions & 7 deletions torch/_inductor/fx_passes/group_batch_fusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,15 +707,24 @@ def fuse(self, graph: torch.fx.GraphModule, subset: List[torch.fx.Node]):
torch.baddbmm,
args=(unsqueeze_biases, stack_inputs, transpose_weight),
)
bmm.meta["example_value"] = torch.baddbmm(
unsqueeze_biases.meta["example_value"],
stack_inputs.meta["example_value"],
transpose_weight.meta["example_value"],
)
bmm_meta = bmm.meta["example_value"]
try:
# it will have runtime error to broadcast when it has dynamic shape included
# in the meta data, so we need to skip the update meta data
bmm.meta["example_value"] = torch.baddbmm(
unsqueeze_biases.meta["example_value"],
stack_inputs.meta["example_value"],
transpose_weight.meta["example_value"],
)
bmm_meta = bmm.meta["example_value"]
except Exception as e:
log.debug(
f" exception when update bmm meta data with stack error tracekey {e}" # noqa: G004
)
bmm_meta = None

bmm = graph.call_function(torch.unbind, args=(bmm,), kwargs={"dim": 0})
bmm.meta["example_value"] = torch.unbind(bmm_meta, dim=0)
if bmm_meta is not None:
bmm.meta["example_value"] = torch.unbind(bmm_meta, dim=0)
for i, linear in enumerate(batch_nodes):
with graph.inserting_after(bmm):
getitem = graph.call_function(operator.getitem, args=(bmm, i))
Expand Down