-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e407c76
commit 3950f58
Showing
8 changed files
with
151 additions
and
1 deletion.
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
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,17 @@ | ||
pytorch2.3.0:� | ||
( | ||
onnx::Add_0 | ||
onnx::Add_12/Add"Add | ||
main_graphZ | ||
onnx::Add_0 | ||
Z | ||
onnx::Add_1 | ||
b | ||
2 | ||
B |
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,38 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# used to generate model: onnx-tests/tests/sum/sum.onnx | ||
|
||
import torch | ||
import torch.nn as nn | ||
|
||
class Model(nn.Module): | ||
def __init__(self): | ||
super(Model, self).__init__() | ||
|
||
def forward(self, x, y): | ||
return x + y | ||
|
||
def main(): | ||
# Set seed for reproducibility | ||
torch.manual_seed(42) | ||
torch.set_printoptions(precision=8) | ||
|
||
# Export to onnx | ||
model = Model() | ||
model.eval() | ||
device = torch.device("cpu") | ||
|
||
onnx_name = "sum.onnx" | ||
|
||
test_input1 = torch.randn(4, 4, device=device) | ||
test_input2 = torch.randn(4, 4, device=device) | ||
torch.onnx.export(model, (test_input1, test_input2), onnx_name, verbose=False, opset_version=16) | ||
|
||
print("Finished exporting model to {}".format(onnx_name)) | ||
|
||
print("Test input data: {} {}".format(test_input1, test_input2)) | ||
output = model.forward(test_input1, test_input2) | ||
print("Test output data: {}".format(output)) | ||
|
||
if __name__ == '__main__': | ||
main() |
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,23 @@ | ||
pytorch2.3.0:� | ||
( | ||
onnx::Add_0 | ||
onnx::Add_12/Add"Add | ||
main_graphZ% | ||
onnx::Add_0 | ||
Z% | ||
onnx::Add_1 | ||
b | ||
2 | ||
B |
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,38 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# used to generate model: onnx-tests/tests/sum/sum_int.onnx | ||
|
||
import torch | ||
import torch.nn as nn | ||
|
||
class Model(nn.Module): | ||
def __init__(self): | ||
super(Model, self).__init__() | ||
|
||
def forward(self, x, y): | ||
return x + y | ||
|
||
def main(): | ||
# Set seed for reproducibility | ||
torch.manual_seed(42) | ||
torch.set_printoptions(precision=8) | ||
|
||
# Export to onnx | ||
model = Model() | ||
model.eval() | ||
device = torch.device("cpu") | ||
|
||
onnx_name = "sum_int.onnx" | ||
|
||
test_input1 = torch.tensor([[[[1, 2, 3, 4]]]], device=device) | ||
test_input2 = torch.tensor([[[[1, 2, 3, 4]]]], device=device) | ||
torch.onnx.export(model, (test_input1, test_input2), onnx_name, verbose=False, opset_version=16) | ||
|
||
print("Finished exporting model to {}".format(onnx_name)) | ||
|
||
print("Test input data: {} {}".format(test_input1, test_input2)) | ||
output = model.forward(test_input1, test_input2) | ||
print("Test output data: {}".format(output)) | ||
|
||
if __name__ == '__main__': | ||
main() |
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