This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Retiarii] pytorch code converter (#3052)
- Loading branch information
1 parent
002af91
commit 8af7314
Showing
27 changed files
with
1,612 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .execution import * | ||
from .graph import * | ||
from .mutator import * | ||
from .operation import * | ||
from .model_apis import nn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# PyTorch Graph Converter | ||
|
||
## Namespace for PyTorch Graph | ||
|
||
We should have a concrete rule for specifying nodes in graph with namespace. | ||
|
||
Each node has a name, either specified or generated. The nodes in the same hierarchy cannot have the same name. | ||
|
||
* The name of module node natively follows this rule, because we use variable name for instantiated modules like what PyTorch graph does. | ||
|
||
* For the nodes created in `forward` function, we use a global sequence number. | ||
|
||
### Namespace for mutated (new) nodes | ||
|
||
TBD | ||
|
||
## Graph Simplification | ||
|
||
TBD | ||
|
||
## Node Types | ||
|
||
We define concrete type string for each node type. | ||
|
||
## Module's Input Arguments | ||
|
||
We use wrapper to obtain the input arguments of modules. Users need to use our wrapped "nn" and wrapped "Module". | ||
|
||
## Control Flow | ||
|
||
### for loop | ||
|
||
Currently, we only support `ModuleList` (`ModuleDict`) based for loop, which is automatically unfolded by TorchScript. That is to say, we do not support loop in TorchScript for now. | ||
|
||
### if/else | ||
|
||
For now, we only deal with the case that the condition is constant or attribute. In this case, only one branch is kept during generating the graph. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .graph_gen import convert_to_graph | ||
from .visualize import visualize_model |
Oops, something went wrong.