-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: more complete coverage tests (#748)
- Loading branch information
1 parent
2ccf056
commit 6819a3a
Showing
46 changed files
with
838 additions
and
9 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,40 @@ | ||
from torch import nn | ||
import torch | ||
import json | ||
|
||
class Model(nn.Module): | ||
def __init__(self): | ||
super(Model, self).__init__() | ||
self.layer = nn.LPPool2d(2, 1, (1, 1)) | ||
|
||
def forward(self, x): | ||
return self.layer(x)[0] | ||
|
||
|
||
circuit = Model() | ||
|
||
x = torch.empty(1, 3, 2, 2).uniform_(0, 1) | ||
|
||
out = circuit(x) | ||
|
||
print(out) | ||
|
||
torch.onnx.export(circuit, x, "network.onnx", | ||
export_params=True, # store the trained parameter weights inside the model file | ||
opset_version=17, # the ONNX version to export the model to | ||
do_constant_folding=True, # whether to execute constant folding for optimization | ||
input_names=['input'], # the model's input names | ||
output_names=['output'], # the model's output names | ||
dynamic_axes={'input': {0: 'batch_size'}, # variable length axes | ||
'output': {0: 'batch_size'}}) | ||
|
||
|
||
d1 = ((x).detach().numpy()).reshape([-1]).tolist() | ||
|
||
data = dict( | ||
input_data=[d1], | ||
) | ||
|
||
# Serialize data into file: | ||
json.dump(data, open("input.json", '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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"input_data": [[0.7549541592597961, 0.990360677242279, 0.9473411440849304, 0.3951031565666199, 0.8500555753707886, 0.9352139830589294, 0.11867779493331909, 0.9493132829666138, 0.6588345766067505, 0.1933223009109497, 0.12139874696731567, 0.8547163605690002]]} |
Binary file not shown.
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,42 @@ | ||
from torch import nn | ||
import torch | ||
import json | ||
import numpy as np | ||
|
||
|
||
class MyModel(nn.Module): | ||
def __init__(self): | ||
super(MyModel, self).__init__() | ||
|
||
def forward(self, x): | ||
m = nn.CELU()(x) | ||
|
||
return m | ||
|
||
|
||
circuit = MyModel() | ||
|
||
x = torch.empty(1, 8).uniform_(0, 1) | ||
|
||
out = circuit(x) | ||
|
||
print(out) | ||
|
||
torch.onnx.export(circuit, x, "network.onnx", | ||
export_params=True, # store the trained parameter weights inside the model file | ||
opset_version=17, # the ONNX version to export the model to | ||
do_constant_folding=True, # whether to execute constant folding for optimization | ||
input_names=['input'], # the model's input names | ||
output_names=['output'], # the model's output names | ||
dynamic_axes={'input': {0: 'batch_size'}, # variable length axes | ||
'output': {0: 'batch_size'}}) | ||
|
||
|
||
d1 = ((x).detach().numpy()).reshape([-1]).tolist() | ||
|
||
data = dict( | ||
input_data=[d1], | ||
) | ||
|
||
# Serialize data into file: | ||
json.dump(data, open("input.json", '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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"input_data": [[0.35387128591537476, 0.030473172664642334, 0.08707714080810547, 0.2429301142692566, 0.45228832960128784, 0.496021032333374, 0.13245105743408203, 0.8497090339660645]]} |
Binary file not shown.
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,41 @@ | ||
from torch import nn | ||
import torch | ||
import json | ||
import numpy as np | ||
|
||
|
||
class MyModel(nn.Module): | ||
def __init__(self): | ||
super(MyModel, self).__init__() | ||
|
||
def forward(self, x): | ||
m = torch.clamp(x, min=0.4, max=0.8) | ||
return m | ||
|
||
|
||
circuit = MyModel() | ||
|
||
x = torch.empty(1, 2, 2, 8).uniform_(0, 1) | ||
|
||
out = circuit(x) | ||
|
||
print(out) | ||
|
||
torch.onnx.export(circuit, x, "network.onnx", | ||
export_params=True, # store the trained parameter weights inside the model file | ||
opset_version=17, # the ONNX version to export the model to | ||
do_constant_folding=True, # whether to execute constant folding for optimization | ||
input_names=['input'], # the model's input names | ||
output_names=['output'], # the model's output names | ||
dynamic_axes={'input': {0: 'batch_size'}, # variable length axes | ||
'output': {0: 'batch_size'}}) | ||
|
||
|
||
d1 = ((x).detach().numpy()).reshape([-1]).tolist() | ||
|
||
data = dict( | ||
input_data=[d1], | ||
) | ||
|
||
# Serialize data into file: | ||
json.dump(data, open("input.json", '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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"input_data": [[0.03297048807144165, 0.46362626552581787, 0.6044231057167053, 0.4949902892112732, 0.48823297023773193, 0.6798646450042725, 0.6824942231178284, 0.03491640090942383, 0.19608813524246216, 0.24129939079284668, 0.9769315123558044, 0.6306831240653992, 0.7690497636795044, 0.252221941947937, 0.9167693853378296, 0.3882681131362915, 0.9307044148445129, 0.33559417724609375, 0.7815426588058472, 0.3435332179069519, 0.7871478796005249, 0.12240773439407349, 0.5295405983924866, 0.4874419569969177, 0.08262640237808228, 0.1124718189239502, 0.5834914445877075, 0.30927878618240356, 0.48899340629577637, 0.9376634955406189, 0.21893149614334106, 0.526070773601532]]} |
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,24 @@ | ||
pytorch2.2.1:� | ||
?/Constant_output_0 /Constant"Constant* | ||
value*J���>� | ||
C/Constant_1_output_0/Constant_1"Constant* | ||
value*J��L?� | ||
F | ||
input | ||
/Constant_output_0 | ||
/Constant_1_output_0output/Clip"Clip | ||
main_graphZ) | ||
input | ||
batch_size | ||
b* | ||
output | ||
batch_size | ||
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,41 @@ | ||
import random | ||
import math | ||
import numpy as np | ||
|
||
import torch | ||
from torch import nn | ||
import torch.nn.functional as F | ||
import json | ||
|
||
|
||
model = nn.GRU(3, 3) # Input dim is 3, output dim is 3 | ||
x = torch.randn(1, 3) # make a sequence of length 5 | ||
|
||
print(x) | ||
|
||
# Flips the neural net into inference mode | ||
model.eval() | ||
model.to('cpu') | ||
|
||
# Export the model | ||
torch.onnx.export(model, # model being run | ||
# model input (or a tuple for multiple inputs) | ||
x, | ||
# where to save the model (can be a file or file-like object) | ||
"network.onnx", | ||
export_params=True, # store the trained parameter weights inside the model file | ||
opset_version=10, # the ONNX version to export the model to | ||
do_constant_folding=True, # whether to execute constant folding for optimization | ||
input_names=['input'], # the model's input names | ||
output_names=['output'], # the model's output names | ||
dynamic_axes={'input': {0: 'batch_size'}, # variable length axes | ||
'output': {0: 'batch_size'}}) | ||
|
||
data_array = ((x).detach().numpy()).reshape([-1]).tolist() | ||
|
||
data_json = dict(input_data=[data_array]) | ||
|
||
print(data_json) | ||
|
||
# Serialize data into file: | ||
json.dump(data_json, open("input.json", '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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"input_data": [[0.4145222008228302, -0.4043896496295929, 0.7545749545097351]]} |
Binary file not shown.
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,42 @@ | ||
from torch import nn | ||
import torch | ||
import json | ||
import numpy as np | ||
|
||
|
||
class MyModel(nn.Module): | ||
def __init__(self): | ||
super(MyModel, self).__init__() | ||
|
||
def forward(self, x): | ||
m = torch.argmax(x) | ||
|
||
return m | ||
|
||
|
||
circuit = MyModel() | ||
|
||
x = torch.empty(1, 8).uniform_(0, 1) | ||
|
||
out = circuit(x) | ||
|
||
print(out) | ||
|
||
torch.onnx.export(circuit, x, "network.onnx", | ||
export_params=True, # store the trained parameter weights inside the model file | ||
opset_version=17, # the ONNX version to export the model to | ||
do_constant_folding=True, # whether to execute constant folding for optimization | ||
input_names=['input'], # the model's input names | ||
output_names=['output'], # the model's output names | ||
dynamic_axes={'input': {0: 'batch_size'}, # variable length axes | ||
'output': {0: 'batch_size'}}) | ||
|
||
|
||
d1 = ((x).detach().numpy()).reshape([-1]).tolist() | ||
|
||
data = dict( | ||
input_data=[d1], | ||
) | ||
|
||
# Serialize data into file: | ||
json.dump(data, open("input.json", '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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"input_data": [[0.5505883693695068, 0.0766521692276001, 0.12006187438964844, 0.9497959017753601, 0.9100563526153564, 0.968717098236084, 0.5978299379348755, 0.9419963359832764]]} |
Binary file not shown.
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 +1 @@ | ||
{"input_data": [[0.2971532940864563, 0.3465197682380676, 0.05381882190704346, 0.058654189109802246, 0.014198064804077148, 0.06088751554489136, 0.1723427176475525, 0.5115123987197876]]} | ||
{"input_data": [[0.8326942324638367, 0.2796096205711365, 0.600328266620636, 0.3701696991920471, 0.17832040786743164, 0.6247223019599915, 0.501872718334198, 0.6961578726768494]]} |
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 @@ | ||
pytorch2.1.0:� | ||
pytorch2.2.1:� | ||
; | ||
inputoutput/HardSigmoid"HardSigmoid* | ||
alpha��*>� | ||
|
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,41 @@ | ||
from torch import nn | ||
import torch | ||
import json | ||
import numpy as np | ||
|
||
|
||
class MyModel(nn.Module): | ||
def __init__(self): | ||
super(MyModel, self).__init__() | ||
|
||
def forward(self, x): | ||
m = nn.Hardswish()(x) | ||
return m | ||
|
||
|
||
circuit = MyModel() | ||
|
||
x = torch.empty(1, 8).uniform_(0, 1) | ||
|
||
out = circuit(x) | ||
|
||
print(out) | ||
|
||
torch.onnx.export(circuit, x, "network.onnx", | ||
export_params=True, # store the trained parameter weights inside the model file | ||
opset_version=17, # the ONNX version to export the model to | ||
do_constant_folding=True, # whether to execute constant folding for optimization | ||
input_names=['input'], # the model's input names | ||
output_names=['output'], # the model's output names | ||
dynamic_axes={'input': {0: 'batch_size'}, # variable length axes | ||
'output': {0: 'batch_size'}}) | ||
|
||
|
||
d1 = ((x).detach().numpy()).reshape([-1]).tolist() | ||
|
||
data = dict( | ||
input_data=[d1], | ||
) | ||
|
||
# Serialize data into file: | ||
json.dump(data, open("input.json", '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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"input_data": [[0.6996762752532959, 0.42992985248565674, 0.5102168321609497, 0.5540387630462646, 0.8489438891410828, 0.8533616065979004, 0.36736780405044556, 0.5859147310256958]]} |
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,15 @@ | ||
pytorch2.2.1:{ | ||
& | ||
inputoutput | ||
/HardSwish" HardSwish | ||
main_graphZ! | ||
input | ||
batch_size | ||
b" | ||
output | ||
batch_size | ||
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
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,42 @@ | ||
from torch import nn | ||
import torch | ||
import json | ||
import numpy as np | ||
|
||
|
||
class MyModel(nn.Module): | ||
def __init__(self): | ||
super(MyModel, self).__init__() | ||
|
||
def forward(self, x): | ||
m = torch.logsumexp(x, dim=1) | ||
|
||
return m | ||
|
||
|
||
circuit = MyModel() | ||
|
||
x = torch.empty(1, 2, 2, 8).uniform_(0, 1) | ||
|
||
out = circuit(x) | ||
|
||
print(out) | ||
|
||
torch.onnx.export(circuit, x, "network.onnx", | ||
export_params=True, # store the trained parameter weights inside the model file | ||
opset_version=17, # the ONNX version to export the model to | ||
do_constant_folding=True, # whether to execute constant folding for optimization | ||
input_names=['input'], # the model's input names | ||
output_names=['output'], # the model's output names | ||
dynamic_axes={'input': {0: 'batch_size'}, # variable length axes | ||
'output': {0: 'batch_size'}}) | ||
|
||
|
||
d1 = ((x).detach().numpy()).reshape([-1]).tolist() | ||
|
||
data = dict( | ||
input_data=[d1], | ||
) | ||
|
||
# Serialize data into file: | ||
json.dump(data, open("input.json", '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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"input_data": [[0.7973018884658813, 0.5245689153671265, 0.34149593114852905, 0.1455438733100891, 0.9482707381248474, 0.4221445322036743, 0.001363217830657959, 0.8736765384674072, 0.42954301834106445, 0.7199509739875793, 0.37641745805740356, 0.5920265316963196, 0.42270803451538086, 0.41761744022369385, 0.603948712348938, 0.7250819802284241, 0.047173500061035156, 0.5115441679954529, 0.3743387460708618, 0.16794061660766602, 0.5352339148521423, 0.037976861000061035, 0.65323406457901, 0.5585184097290039, 0.10559147596359253, 0.07827490568161011, 0.6717077493667603, 0.6480781435966492, 0.9780838489532471, 0.8353415131568909, 0.6491701006889343, 0.6573048233985901]]} |
Binary file not shown.
Oops, something went wrong.