forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch import/export to python printing (pytorch#14400)
Summary: Stacked on pytorch#14378, only look at the last commit. This changes the way methods are defined in TorchScript archives to use PythonPrint rather than ONNX protobufs. It also updates torch.proto to directly document the tensor data structure actually being serialized. Notes: * because PythonPrint prints all the methods at once per module, this removes MethodDef in favor of a single torchscript_area and a separate caffe2_graphs entry. Note that NetDef's already have method names, so there is no need or a separate method name entry. * This switches cpp/pickle area to RecordRef (references to a file in the container format) since it is possible the data in these arenas may be large and not suited to json ouput. * Removes 'annotations' -- annotations should be re-added on the first commit that actually has a practical use for them. In the current state it is unlikely they are representing the right information. * Some expect files have changed because PythonPrint is preserving more debug name information for parameter names. * MethodEncoder (the ONNX output format) has been deleted. There is still some cleanup possible combining EncoderBase and GraphEncode now that there is only a single pathway using EncoderBase. * This incorporates the changes from pytorch#14397 to define TensorDef Pull Request resolved: pytorch#14400 Reviewed By: suo Differential Revision: D13231800 Pulled By: zdevito fbshipit-source-id: af5c1152d0bd6bca8b06c4703f59b161bb19f571
- Loading branch information
1 parent
2b7345b
commit fd31eae
Showing
31 changed files
with
365 additions
and
993 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
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
18 changes: 9 additions & 9 deletions
18
test/expect/TestJit.test_concat_fusion_invariant_cuda.expect
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,17 +1,17 @@ | ||
graph(%0 : Float(*, *) | ||
%1 : Float(*, *) | ||
%2 : Float(*, *)) { | ||
graph(%x : Float(*, *) | ||
%y : Float(*, *) | ||
%z : Float(*, *)) { | ||
%3 : int = prim::Constant[value=1]() | ||
%4 : Float(*, *) = prim::FusionGroup_0(%0, %1) | ||
%5 : Float(*, *) = aten::add(%4, %2, %3) | ||
%w : Float(*, *) = prim::FusionGroup_0(%x, %y) | ||
%5 : Float(*, *) = aten::add(%w, %z, %3) | ||
return (%5); | ||
} | ||
with prim::FusionGroup_0 = graph(%0 : Float(*, *) | ||
%1 : Float(*, *)) { | ||
%2 : int = prim::Constant[value=1]() | ||
%3 : Float(*, *) = aten::add(%0, %1, %2) | ||
%x1 : Float(*, *) = aten::add(%0, %1, %2) | ||
%4 : int = prim::Constant[value=1]() | ||
%5 : Float(*, *) = aten::sub(%0, %1, %4) | ||
%6 : Float(*, *) = prim::FusedConcat[dim=0](%3, %5) | ||
return (%6); | ||
%y1 : Float(*, *) = aten::sub(%0, %1, %4) | ||
%w : Float(*, *) = prim::FusedConcat[dim=0](%x1, %y1) | ||
return (%w); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
def graph(self, | ||
x: Tensor, | ||
y: Tensor) -> Tensor: | ||
return aten.add(aten.mul(x, 2), y, alpha=1) | ||
_0 = torch.add(torch.mul(x, 2), y, alpha=1) | ||
return _0 |
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
2 changes: 1 addition & 1 deletion
2
test/expect/TestJit.test_pretty_printer-empty_int_list_test.expect
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 @@ | ||
def graph(self, | ||
y: Tensor) -> int: | ||
x = annotate(List[int], []) | ||
return aten.select(x, 0) | ||
return torch.select(x, 0) |
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
10 changes: 5 additions & 5 deletions
10
test/expect/TestJit.test_pretty_printer-loop_use_test.expect
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,10 +1,10 @@ | ||
def graph(self, | ||
y_1: Tensor) -> Tuple[Tensor, Tensor]: | ||
x = aten.add(y_1, 1, 1) | ||
z_1 = aten.add(x, 5, 1) | ||
x = torch.add(y_1, 1, 1) | ||
z_1 = torch.add(x, 5, 1) | ||
y, z = y_1, z_1 | ||
_0 = bool(aten.lt(y_1, 8)) | ||
_0 = bool(torch.lt(y_1, 8)) | ||
while _0: | ||
y_2 = aten.add_(y, 1, 1) | ||
_0, y, z = bool(aten.lt(y_2, 8)), y_2, x | ||
y_2 = torch.add_(y, 1, 1) | ||
_0, y, z = bool(torch.lt(y_2, 8)), y_2, x | ||
return x, z |
Oops, something went wrong.