Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Relax][PyTorch] Cleanup Tensor Manipulation and Creation op converters #17376

Merged
merged 29 commits into from
Sep 16, 2024
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
cleanup _repeat()
  • Loading branch information
mshr-h committed Sep 15, 2024
commit 6cbd8aa5ba975daa00393bacfc5412cc4ae9186d
16 changes: 8 additions & 8 deletions python/tvm/relax/frontend/torch/fx_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,14 @@ def _permute(self, node: fx.Node) -> relax.Var:
dims = args[1] if isinstance(args[1], (torch.Size, tuple, list)) else args[1:]
return self.block_builder.emit(relax.op.permute_dims(x, dims))

def _repeat(self, node: fx.Node) -> relax.Var:
import torch # type: ignore

args = self.retrieve_args(node)
x = args[0]
dims = args[1] if isinstance(args[1], (torch.Size, tuple, list)) else args[1:]
return self.block_builder.emit(relax.op.tile(x, dims))

########## DataType ##########

def _float(self, node: fx.Node) -> relax.Var:
Expand Down Expand Up @@ -1196,14 +1204,6 @@ def _squeeze(self, node: fx.Node) -> relax.Var:
dim = None
return self.block_builder.emit(relax.op.squeeze(x, dim))

def _repeat(self, node: fx.Node) -> relax.Var:
import torch # type: ignore

args = self.retrieve_args(node)
if isinstance(args[1], (torch.Size, tuple, list)):
return self.block_builder.emit(relax.op.tile(args[0], tuple(args[1])))
return self.block_builder.emit(relax.op.tile(args[0], args[1:]))

def _tile(self, node: fx.Node) -> relax.Var:
import torch # type: ignore

Expand Down