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
3 changes: 1 addition & 2 deletions python/tvm/relax/frontend/torch/base_fx_graph_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1269,8 +1269,7 @@ def _unbind(self, node: fx.Node) -> relax.Var:
dim = node.args[1] if len(node.args) > 1 else node.kwargs.get("dim", 0)
assert isinstance(dim, int), "Expected 2nd argument of unbind as int"
selections = self.shape_of(x)[dim].value
n_section = list(range(1, selections + 1))
ret, split = [], self.block_builder.emit(relax.op.split(x, n_section, dim))
ret, split = [], self.block_builder.emit(relax.op.split(x, selections, dim))
for i in range(selections):
ret.append(self.block_builder.emit(relax.op.squeeze(split[i], axis=dim)))
return self.block_builder.emit(relax.Tuple(ret))
Expand Down
12 changes: 4 additions & 8 deletions tests/python/relax/test_frontend_from_exported_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -3108,8 +3108,7 @@ def main(
R.Tensor((1, 3, 10, 10), dtype="float32"),
R.Tensor((1, 3, 10, 10), dtype="float32"),
R.Tensor((1, 3, 10, 10), dtype="float32"),
R.Tensor((0, 3, 10, 10), dtype="float32"),
) = R.split(input_1, indices_or_sections=[1, 2, 3], axis=0)
) = R.split(input_1, indices_or_sections=3, axis=0)
lv1: R.Tensor((1, 3, 10, 10), dtype="float32") = lv[0]
lv2: R.Tensor((3, 10, 10), dtype="float32") = R.squeeze(lv1, axis=[0])
lv3: R.Tensor((1, 3, 10, 10), dtype="float32") = lv[1]
Expand Down Expand Up @@ -3152,8 +3151,7 @@ def main(
R.Tensor((3, 1, 10, 10), dtype="float32"),
R.Tensor((3, 1, 10, 10), dtype="float32"),
R.Tensor((3, 1, 10, 10), dtype="float32"),
R.Tensor((3, 0, 10, 10), dtype="float32"),
) = R.split(input_1, indices_or_sections=[1, 2, 3], axis=1)
) = R.split(input_1, indices_or_sections=3, axis=1)
lv1: R.Tensor((3, 1, 10, 10), dtype="float32") = lv[0]
lv2: R.Tensor((3, 10, 10), dtype="float32") = R.squeeze(lv1, axis=[1])
lv3: R.Tensor((3, 1, 10, 10), dtype="float32") = lv[1]
Expand Down Expand Up @@ -3978,8 +3976,7 @@ def main(
R.Tensor((1, 3, 10, 10), dtype="float32"),
R.Tensor((1, 3, 10, 10), dtype="float32"),
R.Tensor((1, 3, 10, 10), dtype="float32"),
R.Tensor((0, 3, 10, 10), dtype="float32"),
) = R.split(input_1, indices_or_sections=[1, 2, 3], axis=0)
) = R.split(input_1, indices_or_sections=3, axis=0)
lv1: R.Tensor((1, 3, 10, 10), dtype="float32") = lv[0]
lv2: R.Tensor((3, 10, 10), dtype="float32") = R.squeeze(lv1, axis=[0])
lv3: R.Tensor((1, 3, 10, 10), dtype="float32") = lv[1]
Expand Down Expand Up @@ -4022,8 +4019,7 @@ def main(
R.Tensor((3, 1, 10, 10), dtype="float32"),
R.Tensor((3, 1, 10, 10), dtype="float32"),
R.Tensor((3, 1, 10, 10), dtype="float32"),
R.Tensor((3, 0, 10, 10), dtype="float32"),
) = R.split(input_1, indices_or_sections=[1, 2, 3], axis=1)
) = R.split(input_1, indices_or_sections=3, axis=1)
lv1: R.Tensor((3, 1, 10, 10), dtype="float32") = lv[0]
lv2: R.Tensor((3, 10, 10), dtype="float32") = R.squeeze(lv1, axis=[1])
lv3: R.Tensor((3, 1, 10, 10), dtype="float32") = lv[1]
Expand Down
6 changes: 2 additions & 4 deletions tests/python/relax/test_frontend_from_fx.py
Original file line number Diff line number Diff line change
Expand Up @@ -3746,8 +3746,7 @@ def main(
R.Tensor((1, 3, 10, 10), dtype="float32"),
R.Tensor((1, 3, 10, 10), dtype="float32"),
R.Tensor((1, 3, 10, 10), dtype="float32"),
R.Tensor((0, 3, 10, 10), dtype="float32"),
) = R.split(input_1, indices_or_sections=[1, 2, 3], axis=0)
) = R.split(input_1, indices_or_sections=3, axis=0)
lv1: R.Tensor((1, 3, 10, 10), dtype="float32") = lv[0]
lv2: R.Tensor((3, 10, 10), dtype="float32") = R.squeeze(lv1, axis=[0])
lv3: R.Tensor((1, 3, 10, 10), dtype="float32") = lv[1]
Expand Down Expand Up @@ -3783,8 +3782,7 @@ def main(
R.Tensor((3, 1, 10, 10), dtype="float32"),
R.Tensor((3, 1, 10, 10), dtype="float32"),
R.Tensor((3, 1, 10, 10), dtype="float32"),
R.Tensor((3, 0, 10, 10), dtype="float32"),
) = R.split(input_1, indices_or_sections=[1, 2, 3], axis=1)
) = R.split(input_1, indices_or_sections=3, axis=1)
lv1: R.Tensor((3, 1, 10, 10), dtype="float32") = lv[0]
lv2: R.Tensor((3, 10, 10), dtype="float32") = R.squeeze(lv1, axis=[1])
lv3: R.Tensor((3, 1, 10, 10), dtype="float32") = lv[1]
Expand Down