Commit Graph

180 Commits

Author SHA1 Message Date
Wang Xu
6000481473 add a unit test for large node error (#48938)
Summary:
add a unit test to test the situation where a node is too large to fit into any device

Pull Request resolved: https://github.com/pytorch/pytorch/pull/48938

Reviewed By: zhangguanheng66

Differential Revision: D25402967

Pulled By: scottxu0730

fbshipit-source-id: a2e2a3dc70d139fa678865ef03e67fa57eff4a1d
2020-12-08 14:45:44 -08:00
Wang Xu
799b700ada add a unit test for lack of devices (#48858)
Summary:
add a unit test for the situation where devices have no enough memory

Pull Request resolved: https://github.com/pytorch/pytorch/pull/48858

Reviewed By: malfet, gcatron

Differential Revision: D25341254

Pulled By: scottxu0730

fbshipit-source-id: c0524c22717b6c8afd67f5b0ad0f1851b973e4b7
2020-12-05 06:09:04 -08:00
Horace He
092e52a4da [fx]added prototype of to_folder (#47544)
Summary:
What this does is that given a `FxModule foo`, you can call `foo.to_folder('foo_folder', 'Foo')` and dump the current FX module into runnable Python code.

That is
```
foo = <fxModule>
foo = foo.to_folder('bar', 'Foo')
from bar import Foo
foo2 = Foo()

forall x, foo2(x) == Foo(x)
```

This has several use cases, largely lifted from jamesr66a's doc here: https://fb.quip.com/U6KHAFaP2cWa (FB-internal).

1. As we apply more heavy-weight function transformations with FX, figuring out what's going on can be quite a difficult experience. In particular, things that can typically be used for debugging (like `print` or `import pdb; pdb.set_trace()`) no longer work. This is particularly necessary if you're using a FX transform like `grad` or `vmap. With this, you simply open up the dumped file, and add `print`/`pdb` statements wherever you'd like.

2. This also provides an immense amount of user control. Some potential use-cases:
-  Let's say an existing FX transform has some bug, or generates suboptimal code. Instead of needing to modify that FX transform, writing another FX pass that fixes the suboptimal code, or simply giving up on FX, they can workaround it by simply modifying the resulting code themselves.
- This allows users to check in their FX modules into source control.
- You could even imagine using this as part of some code-gen type workflow, where you write a function, `vmap` it to get the function you actually want, and then simply copy the output of the `vmap` function without needing FX at all in the final code.

An example:
```python
class Test(nn.Module):
    def __init__(self):
        super(Test, self).__init__()
        self.W = torch.nn.Parameter(torch.randn(2))
        self.linear = nn.Linear(2, 2)
        self.attr = torch.randn(2)
        self.attr2 = torch.randn(2)

    def forward(self, x):
        return self.linear(self.W + (self.attr + self.attr2) + x)

mod = fx.symbolic_trace(Test())
mod.to_folder('foo', 'Foo')
```
results in
```python
import torch
class Foo(torch.nn.Module):
    def __init__(self):
        super().__init__()
        state_dict = torch.load('foo/state_dict.pt')
        self.linear = torch.load('foo/linear.pt') # Linear(in_features=2, out_features=2, bias=True)
        self.__tensor_constant0 = state_dict['__tensor_constant0']
        self.W = torch.nn.Parameter(state_dict['W'])

    def forward(self, x):
        w = self.W
        tensor_constant0 = self.__tensor_constant0
        add_1 = w + tensor_constant0
        add_2 = add_1 + x
        linear_1 = self.linear(add_2)
        return linear_1
```
Some current issues:
1. How do you actually ... save things like modules or parameters? I don't think FX is in the business of tracking initializations and such. Thus, the only way I see to do it is to dump the parameters/modules as blobs, and then load them in the generated initialization. This is a somewhat subpar user experience, and perhaps prevents it from being in some use cases (ie: you would need to check in the blobs into source control to save the model).

2. Currently, the only "atomic" modules we have are those in `torch.nn`. However, if we want to allow flexibility in this, and for example, allow "atomic" modules that are user-defined, then it's not clear how to allow those to be dumped in a way that we can then load elsewhere.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/47544

Reviewed By: jamesr66a

Differential Revision: D25232917

Pulled By: Chillee

fbshipit-source-id: fd2b61a5f40e614fc94256a2957ed1d57fcf5492
2020-12-04 18:33:27 -08:00
Wang Xu
9af627fda1 fix some typos in the fx ir test_fx_experiemntal (#48847)
Summary:
fix some typos in test_fx_experimental.py

Pull Request resolved: https://github.com/pytorch/pytorch/pull/48847

Reviewed By: malfet, gcatron

Differential Revision: D25339391

Pulled By: scottxu0730

fbshipit-source-id: 388d9da94259d2b306d59f3f4a167e486ac06d60
2020-12-04 12:18:36 -08:00
Wang Xu
7a59a1b574 add aot_based_partition (#48336)
Summary:
This PR add supports on AOT based partition. Given each node and its corresponding partition id, generate the partition, submodules and dag

Pull Request resolved: https://github.com/pytorch/pytorch/pull/48336

Reviewed By: gcatron

Differential Revision: D25226899

Pulled By: scottxu0730

fbshipit-source-id: 8afab234afae67c6fd48e958a42b614f730a61d9
2020-11-30 19:11:02 -08:00
Horace He
0a3db1d460 [FX] Prototype Conv/BN fuser in FX (#47657)
Summary:
Some interesting stuff going on. All benchmarks are tested with both my implementation as well as the current quantized fuser.

For these benchmarks, things like using MKLDNN/FBGEMM make a big differene.

## Manual compilation (everything turned off)
In the small case, things look good
```
non-fused:  1.174886703491211
fused:  0.7494957447052002
```

However, for `torchvision.resnet18`, we see
```
non-fused:  1.2272708415985107
fused:  3.7183213233947754
```

This is because Conv (no bias) -> Batch Norm is actually faster than Conv (bias) if you don't have any libraries...

## Nightly (CPU)
```
Toy
non-fused:  0.45807552337646484
fused:  0.34779977798461914

resnet18
non-fused:  0.14216232299804688
fused:  0.13438796997070312

resnet50
non-fused:  0.2999534606933594
fused:  0.29364800453186035

densenet161
non-fused:  0.6558926105499268
fused:  0.6190280914306641

inception_v3
non-fused:  1.2804391384124756
fused:  1.181272029876709
```
with MKLDNN.

We see a small performance gain across the board, with more significant performance gains for smaller models.

## Nightly (CUDA)

```
M
non-fused:  1.2220964431762695
fused:  1.0833759307861328

resnet18
non-fused:  0.09721899032592773
fused:  0.09089207649230957

resnet50
non-fused:  0.2053072452545166
fused:  0.19138741493225098

densenet161
non-fused:  0.6830024719238281
fused:  0.660109281539917
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/47657

Reviewed By: eellison

Differential Revision: D25127546

Pulled By: Chillee

fbshipit-source-id: ecdf682038def046045fcc09faf9aeb6c459b5e3
2020-11-20 18:51:32 -08:00
Wang Xu
4b56aef05d add kl_based_partition (#48197)
Summary:
This is a partition search based on Kernighan-Lin algorithm. First, the graph is partitioned using size_based_partition, then nodes from different partitions are swapped until the cost reaches minimum.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/48197

Reviewed By: gcatron

Differential Revision: D25097065

Pulled By: scottxu0730

fbshipit-source-id: 3a11286bf4e5a712ab2848b92d0b98cd3d6a89be
2020-11-19 17:38:25 -08:00
James Reed
4316bf98f5 [FX] Refactor unique name handling (#48205)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/48205

Test Plan: Imported from OSS

Reviewed By: zdevito

Differential Revision: D25068934

Pulled By: jamesr66a

fbshipit-source-id: 04e02bbfd2cc9a8c3b963d9afdf40bac065c319b
2020-11-18 21:56:52 -08:00
Wang Xu
fa0acb73bd fix node manipulation in partition class (#48016)
Summary:
This PR fixes the add_node and remove_node in partition class and also add a unit test for node manipulation in partition

Pull Request resolved: https://github.com/pytorch/pytorch/pull/48016

Reviewed By: gcatron

Differential Revision: D24996368

Pulled By: scottxu0730

fbshipit-source-id: 0ddffd5ed3f95e5285fffcaee8c4b671929b4df3
2020-11-16 15:33:11 -08:00
Vasiliy Kuznetsov
ee995d33bd rename torch.Assert to torch._assert (#47763) (#47972)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/47972

Changing the name due to the discussion in
https://github.com/pytorch/pytorch/pull/47399.

Test Plan:
```
python test/test_utils.py TestAssert.test_assert_true
python test/test_fx.py TestFX.test_symbolic_trace_assert
python test/test_fx_experimental.py
```

Reviewed By: supriyar

Differential Revision: D24974298

Pulled By: vkuzo

fbshipit-source-id: 24ded93a7243ec79a0375f4eae8a3db9b787f857
2020-11-16 11:43:27 -08:00
Wang Xu
0dbff184e9 change file name to snake style (#47914)
Summary:
Change Partitioner.py file name to partitioner.py
Change GraphManipulation.py file name to graph_manipulation.py
Move test_replace_target_nodes_with() to test_fx_experimental.py
Remove the unnecessary argument in size_based_partition() in Partitioner class

Pull Request resolved: https://github.com/pytorch/pytorch/pull/47914

Reviewed By: gcatron

Differential Revision: D24956653

Pulled By: scottxu0730

fbshipit-source-id: 25b65be7dc7d64e90ffdc59cf394446fee83c3e6
2020-11-14 01:29:25 -08:00
Richard Zou
e5da3b6097 Revert D24891767: rename torch.Assert to torch._assert
Test Plan: revert-hammer

Differential Revision:
D24891767 (a8ca042ec0)

Original commit changeset: 01c7a5acd83b

fbshipit-source-id: cd2271467151b578185758723fcd23f69051d3a3
2020-11-13 08:35:05 -08:00
Wang Xu
759a548d6e add dependency check in cost_aware_partition (#47856)
Summary:
In the cost_aware_partition, check the circular dependency in try_combining_partitions. Also fix the calculate of communication time between partitions.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/47856

Reviewed By: gcatron

Differential Revision: D24926591

Pulled By: scottxu0730

fbshipit-source-id: c634608675ac14b13b2370a727e4fb05e1bb94f0
2020-11-13 02:49:39 -08:00
Vasiliy Kuznetsov
a8ca042ec0 rename torch.Assert to torch._assert (#47763)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/47763

Changing the name due to the discussion in
https://github.com/pytorch/pytorch/pull/47399.

Test Plan:
```
python test/test_utils.py TestAssert.test_assert_true
python test/test_fx.py TestFX.test_symbolic_trace_assert
python test/test_fx_experimental.py
```

Imported from OSS

Reviewed By: ezyang

Differential Revision: D24891767

fbshipit-source-id: 01c7a5acd83bf9c962751552780930c242134dd2
2020-11-12 23:59:34 -08:00
James Reed
9734c042b8 [FX] Fix submodule naming for subgraph split (#47869)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/47869

Test Plan: Imported from OSS

Reviewed By: scottxu0730

Differential Revision: D24925283

Pulled By: jamesr66a

fbshipit-source-id: a33bff20667405a3bbfc81e1e640c2649c0db03b
2020-11-12 15:58:45 -08:00
Garret Catron
21f447ee2c Added serialization of parameters for leaf modules (#47729)
Summary:
This adds the serialization of parameters of leaf nodes to the json serialization.
Specifically __constants__ of the leaf module is serialized as parameters in the JSON.
It also adds type/shape to leaf modules as well.
```
{
            "shape": "[3, 3, 1, 1]",
            "dtype": "torch.float32",
            "parameters": {
                "name": "Conv2d",
                "stride": [
                    1,
                    1
                ],
                "padding": [
                    0,
                    0
                ],
                "dilation": [
                    1,
                    1
                ],
                "groups": 1,
                "padding_mode": "zeros",
                "output_padding": [
                    0,
                    0
                ],
                "in_channels": 3,
                "out_channels": 3,
                "kernel_size": [
                    2,
                    2
                ]
            },
            "target": "conv",
            "op_code": "call_module",
            "name": "conv",
            "args": [
                {
                    "is_node": true,
                    "name": "c"
                }
            ],
            "kwargs": {}
        },
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/47729

Reviewed By: ailzhang

Differential Revision: D24901632

Pulled By: gcatron

fbshipit-source-id: 7f2d923937042b60819c58fd180b426a3733ff5f
2020-11-12 14:28:31 -08:00
Wang Xu
b46787d6d7 add cost_aware_partition (#47673)
Summary:
[WIP]This PR adds cost_aware_partition method in Partitioner class. The method partitions the fx graph module based on the latency of the whole graph.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/47673

Reviewed By: gcatron

Differential Revision: D24896685

Pulled By: scottxu0730

fbshipit-source-id: 1b1651fe82ce56554f99d68da116e585c74099ed
2020-11-11 19:31:37 -08:00
Garret Catron
497cd2506f Add serialize GraphModule to JSON support (#47612)
Summary:
re-opening PR, missed mypy issues, they are now addressed.
Example:

class TestModule(torch.nn.Module):
            def __init__(self):
                super().__init__()
                self.linear = torch.nn.Linear(4, 4)
                self.e = torch.rand(4)

            def forward(self, a, b):
                add_1 = a + b
                linear = self.linear(add_1)
                add_2 = linear + self.e
                return add_2
JSON:

{
    "modules": {},
    "weights": {
        "linear.weight": {
            "dtype": "torch.float32",
            "is_quantized": false,
            "shape": "[4, 4]"
        },
        "linear.bias": {
            "dtype": "torch.float32",
            "is_quantized": false,
            "shape": "[4]"
        },
        "e": {
            "dtype": "torch.float32",
            "is_quantized": false,
            "shape": "[4]"
        }
    },
    "nodes": [
        {
            "shape": "[4]",
            "dtype": "torch.float32",
            "target": "a",
            "op_code": "placeholder",
            "name": "a",
            "args": [],
            "kwargs": {}
        },
        {
            "shape": "[4]",
            "dtype": "torch.float32",
            "target": "b",
            "op_code": "placeholder",
            "name": "b",
            "args": [],
            "kwargs": {}
        },
        {
            "shape": "[4]",
            "dtype": "torch.float32",
            "target": "_operator.add",
            "op_code": "call_function",
            "name": "add_1",
            "args": [
                {
                    "is_node": true,
                    "name": "a"
                },
                {
                    "is_node": true,
                    "name": "b"
                }
            ],
            "kwargs": {}
        },
        {
            "target": "linear",
            "op_code": "call_module",
            "name": "linear_1",
            "args": [
                {
                    "is_node": true,
                    "name": "add_1"
                }
            ],
            "kwargs": {}
        },
        {
            "shape": "[4]",
            "dtype": "torch.float32",
            "target": "e",
            "op_code": "get_attr",
            "name": "e",
            "args": [],
            "kwargs": {}
        },
        {
            "shape": "[4]",
            "dtype": "torch.float32",
            "target": "_operator.add",
            "op_code": "call_function",
            "name": "add_2",
            "args": [
                {
                    "is_node": true,
                    "name": "linear_1"
                },
                {
                    "is_node": true,
                    "name": "e"
                }
            ],
            "kwargs": {}
        },
        {
            "shape": "[4]",
            "dtype": "torch.float32",
            "target": "output",
            "op_code": "output",
            "name": "output",
            "args": [
                {
                    "is_node": true,
                    "name": "add_2"
                }
            ],
            "kwargs": {}
        }
    ]
}

Pull Request resolved: https://github.com/pytorch/pytorch/pull/47612

Reviewed By: scottxu0730

Differential Revision: D24836223

Pulled By: gcatron

fbshipit-source-id: d3da2b5f90d143beba3b7f1f67462fb7430df906
2020-11-10 11:54:02 -08:00
Nikita Shulga
6248e0621c Revert D24801481: [pytorch][PR] Add AcceleratedGraphModule and serialzie GraphModule to JSON
Test Plan: revert-hammer

Differential Revision:
D24801481 (9e0102c10f)

Original commit changeset: 6b3fe69b51f7

fbshipit-source-id: f8287ef88b302e0f08d58090dc61603a4ef5cb3c
2020-11-09 08:28:22 -08:00
Garret Catron
9e0102c10f Add AcceleratedGraphModule and serialzie GraphModule to JSON (#47233)
Summary:
Example:
```
class TestModule(torch.nn.Module):
            def __init__(self):
                super().__init__()
                self.linear = torch.nn.Linear(4, 4)
                self.e = torch.rand(4)

            def forward(self, a, b):
                add_1 = a + b
                linear = self.linear(add_1)
                add_2 = linear + self.e
                return add_2
```
JSON:
```
{
    "modules": {},
    "weights": {
        "linear.weight": {
            "dtype": "torch.float32",
            "is_quantized": false,
            "shape": "[4, 4]"
        },
        "linear.bias": {
            "dtype": "torch.float32",
            "is_quantized": false,
            "shape": "[4]"
        },
        "e": {
            "dtype": "torch.float32",
            "is_quantized": false,
            "shape": "[4]"
        }
    },
    "nodes": [
        {
            "shape": "[4]",
            "dtype": "torch.float32",
            "target": "a",
            "op_code": "placeholder",
            "name": "a",
            "args": [],
            "kwargs": {}
        },
        {
            "shape": "[4]",
            "dtype": "torch.float32",
            "target": "b",
            "op_code": "placeholder",
            "name": "b",
            "args": [],
            "kwargs": {}
        },
        {
            "shape": "[4]",
            "dtype": "torch.float32",
            "target": "_operator.add",
            "op_code": "call_function",
            "name": "add_1",
            "args": [
                {
                    "is_node": true,
                    "name": "a"
                },
                {
                    "is_node": true,
                    "name": "b"
                }
            ],
            "kwargs": {}
        },
        {
            "target": "linear",
            "op_code": "call_module",
            "name": "linear_1",
            "args": [
                {
                    "is_node": true,
                    "name": "add_1"
                }
            ],
            "kwargs": {}
        },
        {
            "shape": "[4]",
            "dtype": "torch.float32",
            "target": "e",
            "op_code": "get_attr",
            "name": "e",
            "args": [],
            "kwargs": {}
        },
        {
            "shape": "[4]",
            "dtype": "torch.float32",
            "target": "_operator.add",
            "op_code": "call_function",
            "name": "add_2",
            "args": [
                {
                    "is_node": true,
                    "name": "linear_1"
                },
                {
                    "is_node": true,
                    "name": "e"
                }
            ],
            "kwargs": {}
        },
        {
            "shape": "[4]",
            "dtype": "torch.float32",
            "target": "output",
            "op_code": "output",
            "name": "output",
            "args": [
                {
                    "is_node": true,
                    "name": "add_2"
                }
            ],
            "kwargs": {}
        }
    ]
}
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/47233

Reviewed By: jackm321, yinghai

Differential Revision: D24801481

Pulled By: gcatron

fbshipit-source-id: 6b3fe69b51f7ac57f445675acdac36b0e563f73d
2020-11-08 19:26:02 -08:00
Wang Xu
b4b0fa6371 add get_device_to_partitions_mapping (#47361)
Summary:
add get_device_to_partitions_mapping function in the Partitioner class to make size_based_partition more modular and organized. This function will also be used in the future cost_aware_partition

Pull Request resolved: https://github.com/pytorch/pytorch/pull/47361

Reviewed By: gcatron

Differential Revision: D24760911

Pulled By: scottxu0730

fbshipit-source-id: 8cdda51b9a1145f9d13ebabbb98b4d9df5ebb6cd
2020-11-05 16:33:02 -08:00
Wang Xu
5107a411cd add partition_by_partition_cost (#47280)
Summary:
This PR adds the support to calculate the cost of a partitioned graph partition by partition based on the node cost. In a partitioned graph, top partitions (partitions without parents) are collected as the starting points, then use DFS to find the critical path among all partitions in the graph

Pull Request resolved: https://github.com/pytorch/pytorch/pull/47280

Reviewed By: gcatron

Differential Revision: D24735932

Pulled By: scottxu0730

fbshipit-source-id: 96653a8208554d2c3624e6c8718628f7c13e320b
2020-11-04 18:21:18 -08:00
Ansley Ussery
dec1c36487 Create prototype for AST rewriter (#47216)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/47216

Test Plan: Imported from OSS

Reviewed By: glaringlee

Differential Revision: D24687539

Pulled By: ansley

fbshipit-source-id: 421108d066ff93ee18f4312ee67c287ca1cef881
2020-11-03 19:21:58 -08:00
Wang Xu
1fe273d798 add node by node cost function (#47009)
Summary:
This PR adds node-by-node cost function. Given a partition of nodes, get_latency_of_one_partition function will find the critical path in the partition and return its latency. A test unit is also provided. In the test unit, a graph module is partitioned into two partitions and the latency of each partition is tested.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/47009

Reviewed By: gcatron

Differential Revision: D24692542

Pulled By: scottxu0730

fbshipit-source-id: 64c20954d842507be0d1afa2516d88f705e11224
2020-11-02 21:15:43 -08:00
Natalia Gimelshein
317b78d56e Revert D24665950: Create prototype for AST rewriter
Test Plan: revert-hammer

Differential Revision:
D24665950 (54feb00bbd)

Original commit changeset: b72110436126

fbshipit-source-id: 961412df006acd33c91a745c809832d5c6494c76
2020-10-31 18:07:10 -07:00
Ansley Ussery
54feb00bbd Create prototype for AST rewriter (#46410)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/46410

Test Plan: Imported from OSS

Reviewed By: SplitInfinity

Differential Revision: D24665950

Pulled By: ansley

fbshipit-source-id: b72110436126a24ddc294b8ee7b3f691281c1f1b
2020-10-31 10:51:17 -07:00
Wang Xu
6c34aa720c add add_node function for partition to fix partition mem size calculation (#47083)
Summary:
Placeholders and constants in the partition are counted twice when combining two partitions. This PR fixes it by adding add_node function into Partition class. A unit test is also updated to test if the partition size is correct

Pull Request resolved: https://github.com/pytorch/pytorch/pull/47083

Reviewed By: gcatron

Differential Revision: D24634368

Pulled By: scottxu0730

fbshipit-source-id: ab408f29da4fbf729fd9741dcb3bdb3076dc30c4
2020-10-30 01:59:42 -07:00
Wang Xu
a86b3438eb add support for different memory sizes on size_based_partition (#46919)
Summary:
WIP: add support for different memory sizes on size_based_partition, so the size_based_partition could support different logical devices with different memory sizes. Compared to the original size_based_partition, the new one also supports partition to logical device mapping. Multiple partitions can be mapped into one device if the memory size is allowed. A test unit test_different_size_partition is also added.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/46919

Reviewed By: gcatron, VitalyFedyunin

Differential Revision: D24603511

Pulled By: scottxu0730

fbshipit-source-id: 1ba37338ae054ad846b425fbb7e631d3b6c500b6
2020-10-28 21:11:41 -07:00
Wang Xu
8640905088 add sparse_nn_partition (#46390)
Summary:
WIP: This PR adds sparse_nn_partition into Partitioner class. It includes logical device assignment for all dag nodes. The basic idea is to do size_based_partition separately for embedding nodes and non-embedding nodes. A test unit is also added in test_fx_experimental.py.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/46390

Reviewed By: gcatron

Differential Revision: D24555415

Pulled By: scottxu0730

fbshipit-source-id: 8772af946d5226883759a02a1c827cfdfce66097
2020-10-27 00:11:58 -07:00
Wang Xu
62d37b9f26 add size_based_partition final (#46282)
Summary:
Reopen the PR: https://github.com/pytorch/pytorch/pull/45837
This PR add a new feature for Partitioner() class called size_based_partition. Given a list of devices with the same memory size, this function could distribute graph nodes into different devices. To implement this feature, several help functions are created in Partitioner.py and GraphManipulation.py.
An unit test is also added in test/test_fx_experimental.py

Pull Request resolved: https://github.com/pytorch/pytorch/pull/46282

Reviewed By: gcatron

Differential Revision: D24288470

Pulled By: scottxu0730

fbshipit-source-id: e81b1e0c56e34f61e497d868882126216eba7538
2020-10-14 03:44:05 -07:00