-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bounded lookup log argument (#864)
- Loading branch information
1 parent
0876faa
commit 00155e5
Showing
17 changed files
with
492 additions
and
19 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
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.log(x) | ||
|
||
return m | ||
|
||
|
||
circuit = MyModel() | ||
|
||
x = torch.empty(1, 8).uniform_(0, 3) | ||
|
||
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": [[1.9252371788024902, 1.8418371677398682, 0.8400403261184692, 2.083845853805542, 0.9760497808456421, 0.6940176486968994, 0.015579521656036377, 2.2689192295074463]]} |
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,14 @@ | ||
pytorch2.2.2:o | ||
inputoutput/Log"Log | ||
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
Oops, something went wrong.