Skip to content

Instantly share code, notes, and snippets.

@shunting314
Created March 29, 2022 21:52
Show Gist options
  • Save shunting314/8d5e2d9348a3258959d3954186c48814 to your computer and use it in GitHub Desktop.
Save shunting314/8d5e2d9348a3258959d3954186c48814 to your computer and use it in GitHub Desktop.
One of the Fx graph generated by dynamo for hf_Bart: the graph create tensors without specifying device
graph():
%full : [#users=2] = call_function[target=torch.full](args = ((512, 512), -inf), kwargs = {})
%arange : [#users=2] = call_function[target=torch.arange](args = (512,), kwargs = {})
%add : [#users=1] = call_function[target=operator.add](args = (%arange, 1), kwargs = {})
%view : [#users=1] = call_method[target=view](args = (%add, 512, 1), kwargs = {})
%lt : [#users=1] = call_function[target=operator.lt](args = (%arange, %view), kwargs = {})
%masked_fill_ : [#users=0] = call_method[target=masked_fill_](args = (%full, %lt, 0), kwargs = {})
%to : [#users=1] = call_method[target=to](args = (%full, torch.float32), kwargs = {})
%getitem : [#users=1] = call_function[target=operator.getitem](args = (%to, (None, None, slice(None, None, None), slice(None, None, None))), kwargs = {})
%expand : [#users=1] = call_method[target=expand](args = (%getitem, 1, 1, 512, 512), kwargs = {})
return (expand,)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment