Table of Contents
Shortcuts

# torch.map

## dynamic_shape_map

Note

Tags: torch.dynamic-shape, torch.map

Support Level: SUPPORTED

Original source code:

    import torch

    from functorch.experimental.control_flow import map

    def dynamic_shape_map(xs, y):
        """
        functorch map() maps a function over the first tensor dimension.
        """

        def body(x, y):
            return x + y

        return map(body, xs, y)

Result:

    ExportedProgram:
        class GraphModule(torch.nn.Module):
            def forward(self, arg0_1: f32[3, 2], arg1_1: f32[2]):
                #
                submodule_0 = self.submodule_0
                map_impl = torch.ops.map_impl(submodule_0, 1, arg0_1, arg1_1);  submodule_0 = arg0_1 = arg1_1 = None
                getitem: f32[3, 2] = map_impl[0];  map_impl = None
                return (getitem,)

            class GraphModule(torch.nn.Module):
                def forward(self, arg0_1: f32[2], arg1_1: f32[2]):
                            add: f32[2] = torch.ops.aten.add.Tensor(arg0_1, arg1_1);  arg0_1 = arg1_1 = None
                    return [add]

    Graph Signature: ExportGraphSignature(parameters=[], buffers=[], user_inputs=['arg0_1', 'arg1_1'], user_outputs=['getitem'], inputs_to_parameters={}, inputs_to_buffers={}, buffers_to_mutate={}, backward_signature=None, assertion_dep_token=None)
    Symbol to range: {}

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.