From 829d59035eb39387655550a3fdd7ea89e8286674 Mon Sep 17 00:00:00 2001 From: Hugo Latendresse Date: Sun, 9 Mar 2025 16:53:11 -0400 Subject: [PATCH 1/4] ingest contiguous from torch export --- .../torch/exported_program_translator.py | 1 + .../test_frontend_from_exported_program.py | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/python/tvm/relax/frontend/torch/exported_program_translator.py b/python/tvm/relax/frontend/torch/exported_program_translator.py index c8d9d12505c6..04c62591c518 100644 --- a/python/tvm/relax/frontend/torch/exported_program_translator.py +++ b/python/tvm/relax/frontend/torch/exported_program_translator.py @@ -285,6 +285,7 @@ def create_convert_map( # tensor creation "_to_copy.default": self._to_copy, "arange.start": self._arange, + "contiguous.default": lambda node: self.env[node.args[0]], # no-op "clone.default": lambda node: self.env[node.args[0]], "empty.memory_format": self._empty, "fill.Scalar": self._fill, diff --git a/tests/python/relax/test_frontend_from_exported_program.py b/tests/python/relax/test_frontend_from_exported_program.py index 8ca335c2fe7a..a9488054ba54 100644 --- a/tests/python/relax/test_frontend_from_exported_program.py +++ b/tests/python/relax/test_frontend_from_exported_program.py @@ -2930,6 +2930,26 @@ def main( verify_model(Arange(), example_args, {}, Expected) +def test_contiguous(): + class Contiguous(Module): + def forward(self, input): + return input.contiguous() + + @tvm.script.ir_module + class Expected: + @R.function + def main( + input: R.Tensor((10, 10), dtype="float32") + ) -> R.Tuple(R.Tensor((10, 10), dtype="float32")): + with R.dataflow(): + gv: R.Tuple(R.Tensor((10, 10), dtype="float32")) = (input,) + R.output(gv) + return gv + + example_args = (torch.randn(10, 10, dtype=torch.float32),) + verify_model(Contiguous(), example_args, {}, Expected) + + def test_clone(): class Clone(Module): def forward(self, input): From 1d6aa0b1add5194df5ec01e17ec7a712682fb0d5 Mon Sep 17 00:00:00 2001 From: Hugo Latendresse Date: Sun, 9 Mar 2025 17:46:21 -0400 Subject: [PATCH 2/4] Black formatter --- .../torch/base_fx_graph_translator.py | 6 +- .../torch/exported_program_translator.py | 2 +- .../test_frontend_from_exported_program.py | 138 ++++++++---------- 3 files changed, 68 insertions(+), 78 deletions(-) diff --git a/python/tvm/relax/frontend/torch/base_fx_graph_translator.py b/python/tvm/relax/frontend/torch/base_fx_graph_translator.py index 003ceebec6ff..d4885c8b4875 100644 --- a/python/tvm/relax/frontend/torch/base_fx_graph_translator.py +++ b/python/tvm/relax/frontend/torch/base_fx_graph_translator.py @@ -37,9 +37,9 @@ def __init__(self) -> None: self.env: Dict[fx.Node, relax.Expr] = {} self.params: Dict[torch.Tensor, relax.Expr] = {} self.block_builder: relax.BlockBuilder = None - self.convert_map: Dict[ - Union[torch.nn.Module, str], Callable[[fx.Node], relax.Var] - ] = self.create_convert_map() + self.convert_map: Dict[Union[torch.nn.Module, str], Callable[[fx.Node], relax.Var]] = ( + self.create_convert_map() + ) ########## Utilities ########## diff --git a/python/tvm/relax/frontend/torch/exported_program_translator.py b/python/tvm/relax/frontend/torch/exported_program_translator.py index 04c62591c518..335de7a24016 100644 --- a/python/tvm/relax/frontend/torch/exported_program_translator.py +++ b/python/tvm/relax/frontend/torch/exported_program_translator.py @@ -285,7 +285,7 @@ def create_convert_map( # tensor creation "_to_copy.default": self._to_copy, "arange.start": self._arange, - "contiguous.default": lambda node: self.env[node.args[0]], # no-op + "contiguous.default": lambda node: self.env[node.args[0]], # no-op "clone.default": lambda node: self.env[node.args[0]], "empty.memory_format": self._empty, "fill.Scalar": self._fill, diff --git a/tests/python/relax/test_frontend_from_exported_program.py b/tests/python/relax/test_frontend_from_exported_program.py index a9488054ba54..eba9d8741ac9 100644 --- a/tests/python/relax/test_frontend_from_exported_program.py +++ b/tests/python/relax/test_frontend_from_exported_program.py @@ -82,7 +82,7 @@ def forward(self, input): class expected: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): with R.dataflow(): lv: R.Tensor((1, 3, 10, 10), dtype="float32") = relax_op(input_1) @@ -112,7 +112,7 @@ def forward(self, input): class expected: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="bool")): with R.dataflow(): lv: R.Tensor((1, 3, 10, 10), dtype="bool") = relax_op(input_1) @@ -135,7 +135,7 @@ def forward(self, input): class expected_clamp: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -163,7 +163,7 @@ def forward(self, input): class expected_dropout: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -191,7 +191,7 @@ def forward(self, input): class expected_gelu: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -220,7 +220,7 @@ def forward(self, input): class expected_hardsigmoid: @R.function def main( - inp_0: R.Tensor((1, 3, 10, 10), dtype="float32") + inp_0: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): with R.dataflow(): lv: R.Tensor((1, 3, 10, 10), dtype="float32") = R.add(inp_0, R.const(3, "float32")) @@ -252,7 +252,7 @@ def forward(self, input): class expected1: @R.function def main( - inp_0: R.Tensor((1, 3, 10, 10), dtype="float32") + inp_0: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): with R.dataflow(): lv: R.Tensor((1, 3, 10, 10), dtype="float32") = R.add(inp_0, R.const(3, "float32")) @@ -294,7 +294,7 @@ def forward(self, input): class expected_relu: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -323,7 +323,7 @@ def forward(self, input): class expected_sigmoid: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -352,7 +352,7 @@ def forward(self, input): class expected_silu: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -388,7 +388,7 @@ def forward(self, input): class expected1: @R.function def main( - inp_0: R.Tensor((1, 3, 10, 10), dtype="float32") + inp_0: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): with R.dataflow(): lv: R.Tensor((1, 3, 10, 10), dtype="float32") = R.clip( @@ -425,7 +425,7 @@ def forward(self, input): class expected: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -456,7 +456,7 @@ def forward(self, input): class expected1: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -487,7 +487,7 @@ def forward(self, input): class expected1: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -512,7 +512,7 @@ def forward(self, input): class expected_tril: @R.function def main( - input_1: R.Tensor((10, 10), dtype="float32") + input_1: R.Tensor((10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -531,7 +531,7 @@ def forward(self, input): class expected_triu: @R.function def main( - input_1: R.Tensor((10, 10), dtype="float32") + input_1: R.Tensor((10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -795,7 +795,7 @@ def forward(self, input): class expected1: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -883,7 +883,7 @@ def forward(self, input): class expected1: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -1580,7 +1580,7 @@ def forward(self, x, y): class Expected1: @R.function def main( - inp_0: R.Tensor((4, 4), dtype="float32") + inp_0: R.Tensor((4, 4), dtype="float32"), ) -> R.Tuple(R.Tensor((), dtype="float32")): with R.dataflow(): lv: R.Tensor((), dtype="float32") = R.einsum((inp_0,), subscripts="ii") @@ -1827,7 +1827,7 @@ def forward(self, input): class expected1: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -1856,7 +1856,7 @@ def forward(self, input): class expected2: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 4, 4), dtype="float32")): # block 0 with R.dataflow(): @@ -1885,7 +1885,7 @@ def forward(self, input): class expected3: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 6, 6), dtype="float32")): # block 0 with R.dataflow(): @@ -2007,9 +2007,7 @@ def forward(self, data): @tvm.script.ir_module class expected1: @R.function - def main( - input_1: R.Tensor((3, 3, 10, 10), dtype="float32") - ) -> R.Tuple( + def main(input_1: R.Tensor((3, 3, 10, 10), dtype="float32")) -> R.Tuple( R.Tensor((3, 10, 10), dtype="float32"), R.Tensor((3, 10, 10), dtype="float32"), R.Tensor((3, 10, 10), dtype="float32"), @@ -2051,9 +2049,7 @@ def forward(self, data): @tvm.script.ir_module class expected2: @R.function - def main( - input_1: R.Tensor((3, 3, 10, 10), dtype="float32") - ) -> R.Tuple( + def main(input_1: R.Tensor((3, 3, 10, 10), dtype="float32")) -> R.Tuple( R.Tensor((3, 10, 10), dtype="float32"), R.Tensor((3, 10, 10), dtype="float32"), R.Tensor((3, 10, 10), dtype="float32"), @@ -2102,7 +2098,7 @@ def forward(self, input): class expected_bilinear: @R.function def main( - input: R.Tensor((1, 3, 112, 112), dtype="float32") + input: R.Tensor((1, 3, 112, 112), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 224, 224), dtype="float32")): # block 0 with R.dataflow(): @@ -2131,7 +2127,7 @@ def forward(self, input): class expected_nearest: @R.function def main( - input: R.Tensor((1, 3, 112, 112), dtype="float32") + input: R.Tensor((1, 3, 112, 112), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 224, 224), dtype="float32")): # block 0 with R.dataflow(): @@ -2170,7 +2166,7 @@ def forward(self, input: torch.Tensor): class Expected1: @R.function def main( - inp_0: R.Tensor((256, 256), dtype="float32") + inp_0: R.Tensor((256, 256), dtype="float32"), ) -> R.Tuple(R.Tensor((256,), dtype="float32")): with R.dataflow(): lv: R.Tensor((256,), dtype="float32") = R.mean(inp_0, axis=[-1], keepdims=False) @@ -2182,7 +2178,7 @@ def main( class Expected2: @R.function def main( - inp_0: R.Tensor((256, 256), dtype="float32") + inp_0: R.Tensor((256, 256), dtype="float32"), ) -> R.Tuple(R.Tensor((256, 1), dtype="float32")): with R.dataflow(): lv: R.Tensor((256, 1), dtype="float32") = R.mean(inp_0, axis=[-1], keepdims=True) @@ -2204,7 +2200,7 @@ def forward(self, x): class expected1: @R.function def main( - inp_0: R.Tensor((1, 2, 3, 4), dtype="float32") + inp_0: R.Tensor((1, 2, 3, 4), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 4), dtype="float32")): # block 0 with R.dataflow(): @@ -2238,7 +2234,7 @@ def forward(self, input): class expected_argmax1: @R.function def main( - inp_0: R.Tensor((256, 256), dtype="float32") + inp_0: R.Tensor((256, 256), dtype="float32"), ) -> R.Tuple(R.Tensor((256,), dtype="int64")): with R.dataflow(): lv: R.Tensor((256,), dtype="int64") = R.argmax(inp_0, axis=-1, keepdims=False) @@ -2250,7 +2246,7 @@ def main( class expected_argmax2: @R.function def main( - inp_0: R.Tensor((256, 256), dtype="float32") + inp_0: R.Tensor((256, 256), dtype="float32"), ) -> R.Tuple(R.Tensor((256, 1), dtype="int64")): with R.dataflow(): lv: R.Tensor((256, 1), dtype="int64") = R.argmax(inp_0, axis=-1, keepdims=True) @@ -2279,7 +2275,7 @@ def forward(self, input): class expected_argmin1: @R.function def main( - inp_0: R.Tensor((256, 256), dtype="float32") + inp_0: R.Tensor((256, 256), dtype="float32"), ) -> R.Tuple(R.Tensor((), dtype="int64")): with R.dataflow(): lv: R.Tensor((), dtype="int64") = R.argmin(inp_0, axis=None, keepdims=False) @@ -2291,7 +2287,7 @@ def main( class expected_argmin2: @R.function def main( - inp_0: R.Tensor((256, 256), dtype="float32") + inp_0: R.Tensor((256, 256), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 1), dtype="int64")): with R.dataflow(): lv: R.Tensor((1, 1), dtype="int64") = R.argmin(inp_0, axis=None, keepdims=True) @@ -2362,7 +2358,7 @@ def forward(self, input): class expected1: @R.function def main( - input_1: R.Tensor((1, 2, 3, 4), dtype="float32") + input_1: R.Tensor((1, 2, 3, 4), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 2, 3, 4), dtype="int32")): # block 0 with R.dataflow(): @@ -2388,7 +2384,7 @@ def forward(self, x): class expected1: @R.function def main( - x: R.Tensor((1, 2, 3, 4), dtype="float32") + x: R.Tensor((1, 2, 3, 4), dtype="float32"), ) -> R.Tuple(R.Tensor((4, 2, 3, 4), dtype="float32")): # block 0 with R.dataflow(): @@ -2419,7 +2415,7 @@ def forward(self, input): class expected1: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 100), dtype="float32")): # block 0 with R.dataflow(): @@ -2445,7 +2441,7 @@ def forward(self, x): class expected1: @R.function def main( - x: R.Tensor((1, 2, 3, 4), dtype="float32") + x: R.Tensor((1, 2, 3, 4), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 4, 3, 2), dtype="float32")): # block 0 with R.dataflow(): @@ -2483,7 +2479,7 @@ def main(x: R.Tensor((3,), dtype="float32")) -> R.Tuple(R.Tensor((6,), dtype="fl class expected2: @R.function def main( - x: R.Tensor((1, 3), dtype="float32") + x: R.Tensor((1, 3), dtype="float32"), ) -> R.Tuple(R.Tensor((4, 6), dtype="float32")): # block 0 with R.dataflow(): @@ -2511,7 +2507,7 @@ def forward(self, x): class expected1: @R.function def main( - x: R.Tensor((1, 2, 3, 4), dtype="float32") + x: R.Tensor((1, 2, 3, 4), dtype="float32"), ) -> R.Tuple(R.Tensor((2, 12), dtype="float32")): # block 0 with R.dataflow(): @@ -2533,7 +2529,7 @@ def forward(self, x): class expected1: @R.function def main( - x: R.Tensor((1, 3, 10, 10), dtype="float32") + x: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 10, 3), dtype="float32")): # block 0 with R.dataflow(): @@ -2574,7 +2570,7 @@ def forward(self, x): class expected2: @R.function def main( - x: R.Tensor((8, 16), dtype="float32") + x: R.Tensor((8, 16), dtype="float32"), ) -> R.Tuple(R.Tensor((8, 1, 1, 16, 1), dtype="float32")): with R.dataflow(): lv: R.Tensor((8, 16), dtype="float32") = R.strided_slice( @@ -2619,9 +2615,7 @@ def forward(self, input): @tvm.script.ir_module class Expected: @R.function - def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") - ) -> R.Tuple( + def main(input_1: R.Tensor((1, 3, 10, 10), dtype="float32")) -> R.Tuple( R.Tensor((1, 1, 10, 10), dtype="float32"), R.Tensor((1, 1, 10, 10), dtype="float32"), R.Tensor((1, 1, 10, 10), dtype="float32"), @@ -2651,9 +2645,7 @@ def forward(self, data): @tvm.script.ir_module class expected1: @R.function - def main( - input_1: R.Tensor((3, 3, 10, 10), dtype="float32") - ) -> R.Tuple( + def main(input_1: R.Tensor((3, 3, 10, 10), dtype="float32")) -> R.Tuple( R.Tensor((3, 10, 10), dtype="float32"), R.Tensor((3, 10, 10), dtype="float32"), R.Tensor((3, 10, 10), dtype="float32"), @@ -2695,9 +2687,7 @@ def forward(self, data): @tvm.script.ir_module class expected2: @R.function - def main( - input_1: R.Tensor((3, 3, 10, 10), dtype="float32") - ) -> R.Tuple( + def main(input_1: R.Tensor((3, 3, 10, 10), dtype="float32")) -> R.Tuple( R.Tensor((3, 10, 10), dtype="float32"), R.Tensor((3, 10, 10), dtype="float32"), R.Tensor((3, 10, 10), dtype="float32"), @@ -2749,7 +2739,7 @@ def forward(self, input): class Expected1: @R.function def main( - inp_0: R.Tensor((3, 1, 4, 1), dtype="float32") + inp_0: R.Tensor((3, 1, 4, 1), dtype="float32"), ) -> R.Tuple(R.Tensor((3, 4, 1), dtype="float32")): with R.dataflow(): lv: R.Tensor((3, 4, 1), dtype="float32") = R.squeeze(inp_0, axis=[1]) @@ -2765,7 +2755,7 @@ def forward(self, input): class Expected2: @R.function def main( - inp_0: R.Tensor((3, 1, 4, 1), dtype="float32") + inp_0: R.Tensor((3, 1, 4, 1), dtype="float32"), ) -> R.Tuple(R.Tensor((3, 4), dtype="float32")): with R.dataflow(): lv: R.Tensor((3, 4), dtype="float32") = R.squeeze(inp_0, axis=None) @@ -2796,7 +2786,7 @@ def forward(self, x): class expected1: @R.function def main( - x: R.Tensor((1, 3), dtype="float32") + x: R.Tensor((1, 3), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 6), dtype="float32")): # block 0 with R.dataflow(): @@ -2809,7 +2799,7 @@ def main( class expected2: @R.function def main( - x: R.Tensor((1, 3), dtype="float32") + x: R.Tensor((1, 3), dtype="float32"), ) -> R.Tuple(R.Tensor((4, 6), dtype="float32")): # block 0 with R.dataflow(): @@ -2833,7 +2823,7 @@ def forward(self, x): class expected1: @R.function def main( - x: R.Tensor((1, 2, 3, 4), dtype="float32") + x: R.Tensor((1, 2, 3, 4), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 4, 3, 2), dtype="float32")): # block 0 with R.dataflow(): @@ -2855,7 +2845,7 @@ def forward(self, input): class expected1: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -2872,7 +2862,7 @@ def forward(self, input): class expected2: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 3, 10, 10, 1), dtype="float32")): # block 0 with R.dataflow(): @@ -2896,7 +2886,7 @@ def forward(self, x): class expected1: @R.function def main( - x: R.Tensor((1, 2, 3, 4), dtype="float32") + x: R.Tensor((1, 2, 3, 4), dtype="float32"), ) -> R.Tuple(R.Tensor((2, 12), dtype="float32")): # block 0 with R.dataflow(): @@ -2918,7 +2908,7 @@ def forward(self, input): class Expected: @R.function def main( - input: R.Tensor((10, 10), dtype="float32") + input: R.Tensor((10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((20,), dtype="int32")): with R.dataflow(): lv: R.Tensor((20,), dtype="int32") = R.arange(0, 20, 1, dtype="int32") @@ -2939,7 +2929,7 @@ def forward(self, input): class Expected: @R.function def main( - input: R.Tensor((10, 10), dtype="float32") + input: R.Tensor((10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((10, 10), dtype="float32")): with R.dataflow(): gv: R.Tuple(R.Tensor((10, 10), dtype="float32")) = (input,) @@ -2959,7 +2949,7 @@ def forward(self, input): class Expected: @R.function def main( - input: R.Tensor((10, 10), dtype="float32") + input: R.Tensor((10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((10, 10), dtype="float32")): with R.dataflow(): gv: R.Tuple(R.Tensor((10, 10), dtype="float32")) = (input,) @@ -2979,7 +2969,7 @@ def forward(self, input): class Expected: @R.function def main( - inp_0: R.Tensor((10, 10), dtype="float32") + inp_0: R.Tensor((10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((10, 10), dtype="float32")): with R.dataflow(): lv: R.Tensor((10, 10), dtype="float32") = R.zeros( @@ -3002,7 +2992,7 @@ def forward(self, input: torch.Tensor): class Expected: @R.function def main( - inp_0: R.Tensor((10, 10), dtype="float32") + inp_0: R.Tensor((10, 10), dtype="float32"), ) -> R.Tuple(R.Tensor((10, 10), dtype="float32")): with R.dataflow(): lv: R.Tensor((10, 10), dtype="float32") = R.full( @@ -3025,7 +3015,7 @@ def forward(self, x): class expected1: @R.function def main( - x: R.Tensor((1, 2, 3), dtype="float32") + x: R.Tensor((1, 2, 3), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 2, 3), dtype="float32")): # block 0 with R.dataflow(): @@ -3054,7 +3044,7 @@ def forward(self, x): class expected_float: @R.function def main( - x: R.Tensor((1, 2, 3, 4), dtype="float32") + x: R.Tensor((1, 2, 3, 4), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 2, 3, 4), dtype="float32")): # block 0 with R.dataflow(): @@ -3072,7 +3062,7 @@ def forward(self, x): class expected_half: @R.function def main( - x: R.Tensor((1, 2, 3, 4), dtype="float32") + x: R.Tensor((1, 2, 3, 4), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 2, 3, 4), dtype="float16")): # block 0 with R.dataflow(): @@ -3090,7 +3080,7 @@ def forward(self, x): class expected_type: @R.function def main( - x: R.Tensor((1, 2, 3, 4), dtype="float32") + x: R.Tensor((1, 2, 3, 4), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 2, 3, 4), dtype="float32")): # block 0 with R.dataflow(): @@ -3106,7 +3096,7 @@ def forward(self, input): class expected_to1: @R.function def main( - inp_0: R.Tensor((1, 2, 3, 4), dtype="float32") + inp_0: R.Tensor((1, 2, 3, 4), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 2, 3, 4), dtype="float16")): with R.dataflow(): lv: R.Tensor((1, 2, 3, 4), dtype="float16") = R.astype(inp_0, dtype="float16") @@ -3122,7 +3112,7 @@ def forward(self, input): class expected_to2: @R.function def main( - inp_0: R.Tensor((1, 2, 3, 4), dtype="float32") + inp_0: R.Tensor((1, 2, 3, 4), dtype="float32"), ) -> R.Tuple(R.Tensor((1, 2, 3, 4), dtype="float32")): with R.dataflow(): lv: R.Tensor((1, 2, 3, 4), dtype="float32") = R.astype(inp_0, dtype="float32") @@ -3207,7 +3197,7 @@ def forward(self, x): class Expected: @R.function def main( - inp_0: R.Tensor((256, 256), dtype="float32") + inp_0: R.Tensor((256, 256), dtype="float32"), ) -> R.Tensor((256, 256), dtype="float32"): with R.dataflow(): gv: R.Tensor((256, 256), dtype="float32") = inp_0 From 92bcdb393d08c0cc4b7d11e27b897fba5d43d304 Mon Sep 17 00:00:00 2001 From: Hugo Latendresse Date: Mon, 10 Mar 2025 03:45:14 -0400 Subject: [PATCH 3/4] ran Black Python formatter with version 22 --- .../torch/base_fx_graph_translator.py | 6 +++--- .../test_frontend_from_exported_program.py | 20 ++++++++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/python/tvm/relax/frontend/torch/base_fx_graph_translator.py b/python/tvm/relax/frontend/torch/base_fx_graph_translator.py index d4885c8b4875..003ceebec6ff 100644 --- a/python/tvm/relax/frontend/torch/base_fx_graph_translator.py +++ b/python/tvm/relax/frontend/torch/base_fx_graph_translator.py @@ -37,9 +37,9 @@ def __init__(self) -> None: self.env: Dict[fx.Node, relax.Expr] = {} self.params: Dict[torch.Tensor, relax.Expr] = {} self.block_builder: relax.BlockBuilder = None - self.convert_map: Dict[Union[torch.nn.Module, str], Callable[[fx.Node], relax.Var]] = ( - self.create_convert_map() - ) + self.convert_map: Dict[ + Union[torch.nn.Module, str], Callable[[fx.Node], relax.Var] + ] = self.create_convert_map() ########## Utilities ########## diff --git a/tests/python/relax/test_frontend_from_exported_program.py b/tests/python/relax/test_frontend_from_exported_program.py index eba9d8741ac9..3486f37feb01 100644 --- a/tests/python/relax/test_frontend_from_exported_program.py +++ b/tests/python/relax/test_frontend_from_exported_program.py @@ -2007,7 +2007,9 @@ def forward(self, data): @tvm.script.ir_module class expected1: @R.function - def main(input_1: R.Tensor((3, 3, 10, 10), dtype="float32")) -> R.Tuple( + def main( + input_1: R.Tensor((3, 3, 10, 10), dtype="float32") + ) -> R.Tuple( R.Tensor((3, 10, 10), dtype="float32"), R.Tensor((3, 10, 10), dtype="float32"), R.Tensor((3, 10, 10), dtype="float32"), @@ -2049,7 +2051,9 @@ def forward(self, data): @tvm.script.ir_module class expected2: @R.function - def main(input_1: R.Tensor((3, 3, 10, 10), dtype="float32")) -> R.Tuple( + def main( + input_1: R.Tensor((3, 3, 10, 10), dtype="float32") + ) -> R.Tuple( R.Tensor((3, 10, 10), dtype="float32"), R.Tensor((3, 10, 10), dtype="float32"), R.Tensor((3, 10, 10), dtype="float32"), @@ -2615,7 +2619,9 @@ def forward(self, input): @tvm.script.ir_module class Expected: @R.function - def main(input_1: R.Tensor((1, 3, 10, 10), dtype="float32")) -> R.Tuple( + def main( + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") + ) -> R.Tuple( R.Tensor((1, 1, 10, 10), dtype="float32"), R.Tensor((1, 1, 10, 10), dtype="float32"), R.Tensor((1, 1, 10, 10), dtype="float32"), @@ -2645,7 +2651,9 @@ def forward(self, data): @tvm.script.ir_module class expected1: @R.function - def main(input_1: R.Tensor((3, 3, 10, 10), dtype="float32")) -> R.Tuple( + def main( + input_1: R.Tensor((3, 3, 10, 10), dtype="float32") + ) -> R.Tuple( R.Tensor((3, 10, 10), dtype="float32"), R.Tensor((3, 10, 10), dtype="float32"), R.Tensor((3, 10, 10), dtype="float32"), @@ -2687,7 +2695,9 @@ def forward(self, data): @tvm.script.ir_module class expected2: @R.function - def main(input_1: R.Tensor((3, 3, 10, 10), dtype="float32")) -> R.Tuple( + def main( + input_1: R.Tensor((3, 3, 10, 10), dtype="float32") + ) -> R.Tuple( R.Tensor((3, 10, 10), dtype="float32"), R.Tensor((3, 10, 10), dtype="float32"), R.Tensor((3, 10, 10), dtype="float32"), From f294dd205f9be74551e6ba16415a80e32316a618 Mon Sep 17 00:00:00 2001 From: Hugo Latendresse Date: Mon, 10 Mar 2025 03:50:42 -0400 Subject: [PATCH 4/4] simplified diff by removing unnecessary linting changes --- .../test_frontend_from_exported_program.py | 116 +++++++++--------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/tests/python/relax/test_frontend_from_exported_program.py b/tests/python/relax/test_frontend_from_exported_program.py index 3486f37feb01..6406610bf53e 100644 --- a/tests/python/relax/test_frontend_from_exported_program.py +++ b/tests/python/relax/test_frontend_from_exported_program.py @@ -82,7 +82,7 @@ def forward(self, input): class expected: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): with R.dataflow(): lv: R.Tensor((1, 3, 10, 10), dtype="float32") = relax_op(input_1) @@ -112,7 +112,7 @@ def forward(self, input): class expected: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="bool")): with R.dataflow(): lv: R.Tensor((1, 3, 10, 10), dtype="bool") = relax_op(input_1) @@ -135,7 +135,7 @@ def forward(self, input): class expected_clamp: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -163,7 +163,7 @@ def forward(self, input): class expected_dropout: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -191,7 +191,7 @@ def forward(self, input): class expected_gelu: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -220,7 +220,7 @@ def forward(self, input): class expected_hardsigmoid: @R.function def main( - inp_0: R.Tensor((1, 3, 10, 10), dtype="float32"), + inp_0: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): with R.dataflow(): lv: R.Tensor((1, 3, 10, 10), dtype="float32") = R.add(inp_0, R.const(3, "float32")) @@ -252,7 +252,7 @@ def forward(self, input): class expected1: @R.function def main( - inp_0: R.Tensor((1, 3, 10, 10), dtype="float32"), + inp_0: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): with R.dataflow(): lv: R.Tensor((1, 3, 10, 10), dtype="float32") = R.add(inp_0, R.const(3, "float32")) @@ -294,7 +294,7 @@ def forward(self, input): class expected_relu: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -323,7 +323,7 @@ def forward(self, input): class expected_sigmoid: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -352,7 +352,7 @@ def forward(self, input): class expected_silu: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -388,7 +388,7 @@ def forward(self, input): class expected1: @R.function def main( - inp_0: R.Tensor((1, 3, 10, 10), dtype="float32"), + inp_0: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): with R.dataflow(): lv: R.Tensor((1, 3, 10, 10), dtype="float32") = R.clip( @@ -425,7 +425,7 @@ def forward(self, input): class expected: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -456,7 +456,7 @@ def forward(self, input): class expected1: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -487,7 +487,7 @@ def forward(self, input): class expected1: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -512,7 +512,7 @@ def forward(self, input): class expected_tril: @R.function def main( - input_1: R.Tensor((10, 10), dtype="float32"), + input_1: R.Tensor((10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -531,7 +531,7 @@ def forward(self, input): class expected_triu: @R.function def main( - input_1: R.Tensor((10, 10), dtype="float32"), + input_1: R.Tensor((10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -795,7 +795,7 @@ def forward(self, input): class expected1: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -883,7 +883,7 @@ def forward(self, input): class expected1: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -1580,7 +1580,7 @@ def forward(self, x, y): class Expected1: @R.function def main( - inp_0: R.Tensor((4, 4), dtype="float32"), + inp_0: R.Tensor((4, 4), dtype="float32") ) -> R.Tuple(R.Tensor((), dtype="float32")): with R.dataflow(): lv: R.Tensor((), dtype="float32") = R.einsum((inp_0,), subscripts="ii") @@ -1827,7 +1827,7 @@ def forward(self, input): class expected1: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -1856,7 +1856,7 @@ def forward(self, input): class expected2: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 4, 4), dtype="float32")): # block 0 with R.dataflow(): @@ -1885,7 +1885,7 @@ def forward(self, input): class expected3: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 6, 6), dtype="float32")): # block 0 with R.dataflow(): @@ -2102,7 +2102,7 @@ def forward(self, input): class expected_bilinear: @R.function def main( - input: R.Tensor((1, 3, 112, 112), dtype="float32"), + input: R.Tensor((1, 3, 112, 112), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 224, 224), dtype="float32")): # block 0 with R.dataflow(): @@ -2131,7 +2131,7 @@ def forward(self, input): class expected_nearest: @R.function def main( - input: R.Tensor((1, 3, 112, 112), dtype="float32"), + input: R.Tensor((1, 3, 112, 112), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 224, 224), dtype="float32")): # block 0 with R.dataflow(): @@ -2170,7 +2170,7 @@ def forward(self, input: torch.Tensor): class Expected1: @R.function def main( - inp_0: R.Tensor((256, 256), dtype="float32"), + inp_0: R.Tensor((256, 256), dtype="float32") ) -> R.Tuple(R.Tensor((256,), dtype="float32")): with R.dataflow(): lv: R.Tensor((256,), dtype="float32") = R.mean(inp_0, axis=[-1], keepdims=False) @@ -2182,7 +2182,7 @@ def main( class Expected2: @R.function def main( - inp_0: R.Tensor((256, 256), dtype="float32"), + inp_0: R.Tensor((256, 256), dtype="float32") ) -> R.Tuple(R.Tensor((256, 1), dtype="float32")): with R.dataflow(): lv: R.Tensor((256, 1), dtype="float32") = R.mean(inp_0, axis=[-1], keepdims=True) @@ -2204,7 +2204,7 @@ def forward(self, x): class expected1: @R.function def main( - inp_0: R.Tensor((1, 2, 3, 4), dtype="float32"), + inp_0: R.Tensor((1, 2, 3, 4), dtype="float32") ) -> R.Tuple(R.Tensor((1, 4), dtype="float32")): # block 0 with R.dataflow(): @@ -2238,7 +2238,7 @@ def forward(self, input): class expected_argmax1: @R.function def main( - inp_0: R.Tensor((256, 256), dtype="float32"), + inp_0: R.Tensor((256, 256), dtype="float32") ) -> R.Tuple(R.Tensor((256,), dtype="int64")): with R.dataflow(): lv: R.Tensor((256,), dtype="int64") = R.argmax(inp_0, axis=-1, keepdims=False) @@ -2250,7 +2250,7 @@ def main( class expected_argmax2: @R.function def main( - inp_0: R.Tensor((256, 256), dtype="float32"), + inp_0: R.Tensor((256, 256), dtype="float32") ) -> R.Tuple(R.Tensor((256, 1), dtype="int64")): with R.dataflow(): lv: R.Tensor((256, 1), dtype="int64") = R.argmax(inp_0, axis=-1, keepdims=True) @@ -2279,7 +2279,7 @@ def forward(self, input): class expected_argmin1: @R.function def main( - inp_0: R.Tensor((256, 256), dtype="float32"), + inp_0: R.Tensor((256, 256), dtype="float32") ) -> R.Tuple(R.Tensor((), dtype="int64")): with R.dataflow(): lv: R.Tensor((), dtype="int64") = R.argmin(inp_0, axis=None, keepdims=False) @@ -2291,7 +2291,7 @@ def main( class expected_argmin2: @R.function def main( - inp_0: R.Tensor((256, 256), dtype="float32"), + inp_0: R.Tensor((256, 256), dtype="float32") ) -> R.Tuple(R.Tensor((1, 1), dtype="int64")): with R.dataflow(): lv: R.Tensor((1, 1), dtype="int64") = R.argmin(inp_0, axis=None, keepdims=True) @@ -2362,7 +2362,7 @@ def forward(self, input): class expected1: @R.function def main( - input_1: R.Tensor((1, 2, 3, 4), dtype="float32"), + input_1: R.Tensor((1, 2, 3, 4), dtype="float32") ) -> R.Tuple(R.Tensor((1, 2, 3, 4), dtype="int32")): # block 0 with R.dataflow(): @@ -2388,7 +2388,7 @@ def forward(self, x): class expected1: @R.function def main( - x: R.Tensor((1, 2, 3, 4), dtype="float32"), + x: R.Tensor((1, 2, 3, 4), dtype="float32") ) -> R.Tuple(R.Tensor((4, 2, 3, 4), dtype="float32")): # block 0 with R.dataflow(): @@ -2419,7 +2419,7 @@ def forward(self, input): class expected1: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 100), dtype="float32")): # block 0 with R.dataflow(): @@ -2445,7 +2445,7 @@ def forward(self, x): class expected1: @R.function def main( - x: R.Tensor((1, 2, 3, 4), dtype="float32"), + x: R.Tensor((1, 2, 3, 4), dtype="float32") ) -> R.Tuple(R.Tensor((1, 4, 3, 2), dtype="float32")): # block 0 with R.dataflow(): @@ -2483,7 +2483,7 @@ def main(x: R.Tensor((3,), dtype="float32")) -> R.Tuple(R.Tensor((6,), dtype="fl class expected2: @R.function def main( - x: R.Tensor((1, 3), dtype="float32"), + x: R.Tensor((1, 3), dtype="float32") ) -> R.Tuple(R.Tensor((4, 6), dtype="float32")): # block 0 with R.dataflow(): @@ -2511,7 +2511,7 @@ def forward(self, x): class expected1: @R.function def main( - x: R.Tensor((1, 2, 3, 4), dtype="float32"), + x: R.Tensor((1, 2, 3, 4), dtype="float32") ) -> R.Tuple(R.Tensor((2, 12), dtype="float32")): # block 0 with R.dataflow(): @@ -2533,7 +2533,7 @@ def forward(self, x): class expected1: @R.function def main( - x: R.Tensor((1, 3, 10, 10), dtype="float32"), + x: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 10, 3), dtype="float32")): # block 0 with R.dataflow(): @@ -2574,7 +2574,7 @@ def forward(self, x): class expected2: @R.function def main( - x: R.Tensor((8, 16), dtype="float32"), + x: R.Tensor((8, 16), dtype="float32") ) -> R.Tuple(R.Tensor((8, 1, 1, 16, 1), dtype="float32")): with R.dataflow(): lv: R.Tensor((8, 16), dtype="float32") = R.strided_slice( @@ -2749,7 +2749,7 @@ def forward(self, input): class Expected1: @R.function def main( - inp_0: R.Tensor((3, 1, 4, 1), dtype="float32"), + inp_0: R.Tensor((3, 1, 4, 1), dtype="float32") ) -> R.Tuple(R.Tensor((3, 4, 1), dtype="float32")): with R.dataflow(): lv: R.Tensor((3, 4, 1), dtype="float32") = R.squeeze(inp_0, axis=[1]) @@ -2765,7 +2765,7 @@ def forward(self, input): class Expected2: @R.function def main( - inp_0: R.Tensor((3, 1, 4, 1), dtype="float32"), + inp_0: R.Tensor((3, 1, 4, 1), dtype="float32") ) -> R.Tuple(R.Tensor((3, 4), dtype="float32")): with R.dataflow(): lv: R.Tensor((3, 4), dtype="float32") = R.squeeze(inp_0, axis=None) @@ -2796,7 +2796,7 @@ def forward(self, x): class expected1: @R.function def main( - x: R.Tensor((1, 3), dtype="float32"), + x: R.Tensor((1, 3), dtype="float32") ) -> R.Tuple(R.Tensor((1, 6), dtype="float32")): # block 0 with R.dataflow(): @@ -2809,7 +2809,7 @@ def main( class expected2: @R.function def main( - x: R.Tensor((1, 3), dtype="float32"), + x: R.Tensor((1, 3), dtype="float32") ) -> R.Tuple(R.Tensor((4, 6), dtype="float32")): # block 0 with R.dataflow(): @@ -2833,7 +2833,7 @@ def forward(self, x): class expected1: @R.function def main( - x: R.Tensor((1, 2, 3, 4), dtype="float32"), + x: R.Tensor((1, 2, 3, 4), dtype="float32") ) -> R.Tuple(R.Tensor((1, 4, 3, 2), dtype="float32")): # block 0 with R.dataflow(): @@ -2855,7 +2855,7 @@ def forward(self, input): class expected1: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 1, 3, 10, 10), dtype="float32")): # block 0 with R.dataflow(): @@ -2872,7 +2872,7 @@ def forward(self, input): class expected2: @R.function def main( - input_1: R.Tensor((1, 3, 10, 10), dtype="float32"), + input_1: R.Tensor((1, 3, 10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((1, 3, 10, 10, 1), dtype="float32")): # block 0 with R.dataflow(): @@ -2896,7 +2896,7 @@ def forward(self, x): class expected1: @R.function def main( - x: R.Tensor((1, 2, 3, 4), dtype="float32"), + x: R.Tensor((1, 2, 3, 4), dtype="float32") ) -> R.Tuple(R.Tensor((2, 12), dtype="float32")): # block 0 with R.dataflow(): @@ -2918,7 +2918,7 @@ def forward(self, input): class Expected: @R.function def main( - input: R.Tensor((10, 10), dtype="float32"), + input: R.Tensor((10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((20,), dtype="int32")): with R.dataflow(): lv: R.Tensor((20,), dtype="int32") = R.arange(0, 20, 1, dtype="int32") @@ -2959,7 +2959,7 @@ def forward(self, input): class Expected: @R.function def main( - input: R.Tensor((10, 10), dtype="float32"), + input: R.Tensor((10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((10, 10), dtype="float32")): with R.dataflow(): gv: R.Tuple(R.Tensor((10, 10), dtype="float32")) = (input,) @@ -2979,7 +2979,7 @@ def forward(self, input): class Expected: @R.function def main( - inp_0: R.Tensor((10, 10), dtype="float32"), + inp_0: R.Tensor((10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((10, 10), dtype="float32")): with R.dataflow(): lv: R.Tensor((10, 10), dtype="float32") = R.zeros( @@ -3002,7 +3002,7 @@ def forward(self, input: torch.Tensor): class Expected: @R.function def main( - inp_0: R.Tensor((10, 10), dtype="float32"), + inp_0: R.Tensor((10, 10), dtype="float32") ) -> R.Tuple(R.Tensor((10, 10), dtype="float32")): with R.dataflow(): lv: R.Tensor((10, 10), dtype="float32") = R.full( @@ -3025,7 +3025,7 @@ def forward(self, x): class expected1: @R.function def main( - x: R.Tensor((1, 2, 3), dtype="float32"), + x: R.Tensor((1, 2, 3), dtype="float32") ) -> R.Tuple(R.Tensor((1, 2, 3), dtype="float32")): # block 0 with R.dataflow(): @@ -3054,7 +3054,7 @@ def forward(self, x): class expected_float: @R.function def main( - x: R.Tensor((1, 2, 3, 4), dtype="float32"), + x: R.Tensor((1, 2, 3, 4), dtype="float32") ) -> R.Tuple(R.Tensor((1, 2, 3, 4), dtype="float32")): # block 0 with R.dataflow(): @@ -3072,7 +3072,7 @@ def forward(self, x): class expected_half: @R.function def main( - x: R.Tensor((1, 2, 3, 4), dtype="float32"), + x: R.Tensor((1, 2, 3, 4), dtype="float32") ) -> R.Tuple(R.Tensor((1, 2, 3, 4), dtype="float16")): # block 0 with R.dataflow(): @@ -3090,7 +3090,7 @@ def forward(self, x): class expected_type: @R.function def main( - x: R.Tensor((1, 2, 3, 4), dtype="float32"), + x: R.Tensor((1, 2, 3, 4), dtype="float32") ) -> R.Tuple(R.Tensor((1, 2, 3, 4), dtype="float32")): # block 0 with R.dataflow(): @@ -3106,7 +3106,7 @@ def forward(self, input): class expected_to1: @R.function def main( - inp_0: R.Tensor((1, 2, 3, 4), dtype="float32"), + inp_0: R.Tensor((1, 2, 3, 4), dtype="float32") ) -> R.Tuple(R.Tensor((1, 2, 3, 4), dtype="float16")): with R.dataflow(): lv: R.Tensor((1, 2, 3, 4), dtype="float16") = R.astype(inp_0, dtype="float16") @@ -3122,7 +3122,7 @@ def forward(self, input): class expected_to2: @R.function def main( - inp_0: R.Tensor((1, 2, 3, 4), dtype="float32"), + inp_0: R.Tensor((1, 2, 3, 4), dtype="float32") ) -> R.Tuple(R.Tensor((1, 2, 3, 4), dtype="float32")): with R.dataflow(): lv: R.Tensor((1, 2, 3, 4), dtype="float32") = R.astype(inp_0, dtype="float32") @@ -3207,7 +3207,7 @@ def forward(self, x): class Expected: @R.function def main( - inp_0: R.Tensor((256, 256), dtype="float32"), + inp_0: R.Tensor((256, 256), dtype="float32") ) -> R.Tensor((256, 256), dtype="float32"): with R.dataflow(): gv: R.Tensor((256, 256), dtype="float32") = inp_0