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.
Add tests for GraphConverterWithShape (#3951)
- Loading branch information
1 parent
403195f
commit bb39748
Showing
7 changed files
with
154 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import torch | ||
|
||
from nni.retiarii.converter.graph_gen import convert_to_graph, GraphConverterWithShape | ||
|
||
|
||
class ConvertMixin: | ||
@staticmethod | ||
def _convert_model(model, input): | ||
script_module = torch.jit.script(model) | ||
model_ir = convert_to_graph(script_module, model) | ||
return model_ir | ||
|
||
|
||
class ConvertWithShapeMixin: | ||
@staticmethod | ||
def _convert_model(model, input): | ||
script_module = torch.jit.script(model) | ||
model_ir = convert_to_graph(script_module, model, converter=GraphConverterWithShape(), example_inputs=input) | ||
return model_ir |
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
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
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
Oops, something went wrong.