mirror of
https://github.com/zkonduit/ezkl.git
synced 2026-01-10 06:48:01 -05:00
refactor: track onnx examples in main repo (#121)
This commit is contained in:
33
.github/workflows/rust.yml
vendored
33
.github/workflows/rust.yml
vendored
@@ -55,7 +55,6 @@ jobs:
|
||||
|
||||
library-tests:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions-rs/toolchain@v1
|
||||
@@ -69,11 +68,9 @@ jobs:
|
||||
run: cargo test --lib --verbose
|
||||
|
||||
mock-proving-tests:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-latest-32-cores
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
@@ -81,24 +78,21 @@ jobs:
|
||||
components: rustfmt, clippy
|
||||
|
||||
- name: Mock proving tests (public outputs)
|
||||
run: cargo test --release --verbose tests::mock_public_outputs_ -- --test-threads 16
|
||||
run: cargo test --release --verbose tests::mock_public_outputs_ -- --test-threads 32
|
||||
- name: Mock proving tests (public inputs)
|
||||
run: cargo test --release --verbose tests::mock_public_inputs_ -- --test-threads 16
|
||||
run: cargo test --release --verbose tests::mock_public_inputs_ -- --test-threads 32
|
||||
- name: Mock proving tests (public params)
|
||||
run: cargo test --release --verbose tests::mock_public_params_ -- --test-threads 16
|
||||
run: cargo test --release --verbose tests::mock_public_params_ -- --test-threads 32
|
||||
|
||||
prove-and-verify-evm-tests:
|
||||
runs-on: ubuntu-latest-16-cores
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
|
||||
- name: Install solc
|
||||
run: (hash svm 2>/dev/null || cargo install svm-rs) && svm install 0.8.17 && solc --version
|
||||
- name: Install Anvil
|
||||
@@ -110,14 +104,11 @@ jobs:
|
||||
runs-on: ubuntu-latest-16-cores
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
|
||||
- name: KZG prove and verify tests
|
||||
run: cargo test --release --verbose tests::kzg_prove_and_verify_ -- --test-threads 4
|
||||
|
||||
@@ -125,23 +116,18 @@ jobs:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
|
||||
- name: KZG prove and verify aggr tests
|
||||
run: cargo test --release --verbose tests_aggr::kzg_aggr_prove_and_verify_ -- --test-threads 4
|
||||
run: cargo test --release --verbose tests_aggr::kzg_aggr_prove_and_verify_
|
||||
|
||||
prove-and-verify-evm-aggr-tests:
|
||||
prove-and-verify-aggr-evm-tests:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
@@ -150,10 +136,10 @@ jobs:
|
||||
- name: Install solc
|
||||
run: (hash svm 2>/dev/null || cargo install svm-rs) && svm install 0.8.17 && solc --version
|
||||
- name: KZG prove and verify aggr tests
|
||||
run: cargo test --release --verbose tests_evm::kzg_evm_aggr_prove_and_verify_ -- --test-threads 4 --include-ignored
|
||||
run: cargo test --release --verbose tests_evm::kzg_evm_aggr_prove_and_verify_ -- --include-ignored
|
||||
|
||||
examples:
|
||||
runs-on: self-hosted
|
||||
runs-on: ubuntu-latest-32-cores
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions-rs/toolchain@v1
|
||||
@@ -171,13 +157,10 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
|
||||
- name: Mock proving tests (should fail)
|
||||
run: cargo test neg_tests::neg_examples_
|
||||
|
||||
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -1,4 +0,0 @@
|
||||
[submodule "examples/onnx"]
|
||||
path = examples/onnx
|
||||
url = https://github.com/zkonduit/onnx-examples
|
||||
branch = main
|
||||
30
README.md
30
README.md
@@ -46,8 +46,6 @@ Note that the library requires a nightly version of the rust toolchain. You can
|
||||
rustup override set nightly
|
||||
```
|
||||
|
||||
This repository includes onnx example files as a submodule for testing out the cli. Either pass the `--recurse-submodules` flag to the `clone` command or after cloning run `git submodule update --init --recursive`.
|
||||
|
||||
### docs 📖
|
||||
|
||||
Use `cargo doc --open` to compile and open the docs in your default browser.
|
||||
@@ -64,26 +62,26 @@ The `ezkl` cli provides a simple interface to load `.onnx` files, which represen
|
||||
|
||||
You can easily create an `.onnx` file using `pytorch`. For samples of Onnx files see [here](https://github.com/zkonduit/onnx-examples). For a tutorial on how to quickly generate Onnx files using python, check out [pyezkl](https://github.com/zkonduit/pyezkl).
|
||||
|
||||
These examples are also available as a submodule in `./examples/onnx`. To generate a proof on one of the examples, first build ezkl (`cargo build --release`) and add it to your favourite `PATH` variables, then generate a structured reference string (SRS):
|
||||
Sample onnx files are also available in `./examples/onnx`. To generate a proof on one of the examples, first build ezkl (`cargo build --release`) and add it to your favourite `PATH` variables, then generate a structured reference string (SRS):
|
||||
```bash
|
||||
ezkl -K=17 gen-srs --pfsys=kzg --params-path=kzg.params
|
||||
```
|
||||
|
||||
```bash
|
||||
ezkl --bits=16 -K=17 prove -D ./examples/onnx/examples/1l_relu/input.json -M ./examples/onnx/examples/1l_relu/network.onnx --proof-path 1l_relu.pf --vk-path 1l_relu.vk --params-path=kzg.params
|
||||
ezkl --bits=16 -K=17 prove -D ./examples/onnx/1l_relu/input.json -M ./examples/onnx/1l_relu/network.onnx --proof-path 1l_relu.pf --vk-path 1l_relu.vk --params-path=kzg.params
|
||||
```
|
||||
|
||||
This command generates a proof that the model was correctly run on private inputs (this is the default setting). It then outputs the resulting proof at the path specfifed by `--proof-path`, parameters that can be used for subsequent verification at `--params-path` and the verifier key at `--vk-path`.
|
||||
Luckily `ezkl` also provides command to verify the generated proofs:
|
||||
|
||||
```bash
|
||||
ezkl --bits=16 -K=17 verify -M ./examples/onnx/examples/1l_relu/network.onnx --proof-path 1l_relu.pf --vk-path 1l_relu.vk --params-path=kzg.params
|
||||
ezkl --bits=16 -K=17 verify -M ./examples/onnx/1l_relu/network.onnx --proof-path 1l_relu.pf --vk-path 1l_relu.vk --params-path=kzg.params
|
||||
```
|
||||
|
||||
To display a table of the loaded onnx nodes, their associated parameters, set `RUST_LOG=DEBUG` or run:
|
||||
|
||||
```bash
|
||||
cargo run --release --bin ezkl -- table -M ./examples/onnx/examples/1l_relu/network.onnx
|
||||
cargo run --release --bin ezkl -- table -M ./examples/onnx/1l_relu/network.onnx
|
||||
|
||||
```
|
||||
|
||||
@@ -93,11 +91,11 @@ Note that the above prove and verify stats can also be run with an EVM verifier.
|
||||
|
||||
```bash
|
||||
# gen proof
|
||||
ezkl --bits=16 -K=17 prove -D ./examples/onnx/examples/1l_relu/input.json -M ./examples/onnx/examples/1l_relu/network.onnx --proof-path 1l_relu.pf --vk-path 1l_relu.vk --params-path=kzg.params --transcript=evm
|
||||
ezkl --bits=16 -K=17 prove -D ./examples/onnx/1l_relu/input.json -M ./examples/onnx/1l_relu/network.onnx --proof-path 1l_relu.pf --vk-path 1l_relu.vk --params-path=kzg.params --transcript=evm
|
||||
```
|
||||
```bash
|
||||
# gen evm verifier
|
||||
ezkl -K=17 --bits=16 create-evm-verifier -D ./examples/onnx/examples/1l_relu/input.json -M ./examples/onnx/examples/1l_relu/network.onnx --pfsys=kzg --deployment-code-path 1l_relu.code --params-path=kzg.params --vk-path 1l_relu.vk --sol-code-path 1l_relu.sol
|
||||
ezkl -K=17 --bits=16 create-evm-verifier -D ./examples/onnx/1l_relu/input.json -M ./examples/onnx/1l_relu/network.onnx --pfsys=kzg --deployment-code-path 1l_relu.code --params-path=kzg.params --vk-path 1l_relu.vk --sol-code-path 1l_relu.sol
|
||||
```
|
||||
```bash
|
||||
# Verify (EVM)
|
||||
@@ -115,12 +113,12 @@ ezkl -K=20 gen-srs --pfsys=kzg --params-path=kzg.params
|
||||
|
||||
```bash
|
||||
# Single proof -> single proof we are going to feed into aggregation circuit. (Mock)-verifies + verifies natively as sanity check
|
||||
ezkl -K=17 --bits=16 prove --pfsys=kzg --transcript=poseidon --strategy=accum -D ./examples/onnx/examples/1l_relu/input.json -M ./examples/onnx/examples/1l_relu/network.onnx --proof-path 1l_relu.pf --params-path=kzg.params --vk-path=1l_relu.vk
|
||||
ezkl -K=17 --bits=16 prove --pfsys=kzg --transcript=poseidon --strategy=accum -D ./examples/onnx/1l_relu/input.json -M ./examples/onnx/1l_relu/network.onnx --proof-path 1l_relu.pf --params-path=kzg.params --vk-path=1l_relu.vk
|
||||
```
|
||||
|
||||
```bash
|
||||
# Aggregate -> generates aggregate proof and also (mock)-verifies + verifies natively as sanity check
|
||||
ezkl -K=17 --bits=16 aggregate --transcript=evm -M ./examples/onnx/examples/1l_relu/network.onnx --pfsys=kzg --aggregation-snarks=1l_relu.pf --aggregation-vk-paths 1l_relu.vk --vk-path aggr_1l_relu.vk --proof-path aggr_1l_relu.pf --params-path=kzg.params
|
||||
ezkl -K=17 --bits=16 aggregate --transcript=evm -M ./examples/onnx/1l_relu/network.onnx --pfsys=kzg --aggregation-snarks=1l_relu.pf --aggregation-vk-paths 1l_relu.vk --vk-path aggr_1l_relu.vk --proof-path aggr_1l_relu.pf --params-path=kzg.params
|
||||
```
|
||||
|
||||
```bash
|
||||
@@ -219,6 +217,18 @@ criterion_group! {
|
||||
}
|
||||
```
|
||||
|
||||
## onnx examples
|
||||
|
||||
This repository includes onnx example files as a submodule for testing out the cli.
|
||||
|
||||
If you want to add a model to `examples/onnx`, open a PR creating a new folder within `examples/onnx` with a descriptive model name. This folder should contain:
|
||||
- an `input.json` input file, with the fields expected by the [ezkl](https://github.com/zkonduit/ezkl) cli.
|
||||
- a `network.onnx` file representing the trained model
|
||||
- a `gen.py` file for generating the `.json` and `.onnx` files following the general structure of `examples/tutorial/tutorial.py`.
|
||||
|
||||
|
||||
TODO: add associated python files in the onnx model directories.
|
||||
|
||||
## library examples 🔍
|
||||
|
||||
Beyond the `.onnx` examples detailed above, we also include examples which directly use some of our rust API; allowing users to code up computational graphs and circuits from scratch in rust without having to go via python.
|
||||
|
||||
Submodule examples/onnx deleted from b1cee58c04
51
examples/onnx/1l_average/input.json
Normal file
51
examples/onnx/1l_average/input.json
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"input_shapes": [
|
||||
[
|
||||
1,
|
||||
5,
|
||||
5
|
||||
]
|
||||
],
|
||||
"input_data": [
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
]
|
||||
],
|
||||
"output_data": [
|
||||
[
|
||||
0.914,
|
||||
0.914,
|
||||
0.914,
|
||||
0.914,
|
||||
0.914,
|
||||
0.914,
|
||||
0.914,
|
||||
0.914,
|
||||
0.914
|
||||
]
|
||||
]
|
||||
}
|
||||
BIN
examples/onnx/1l_average/network.onnx
Normal file
BIN
examples/onnx/1l_average/network.onnx
Normal file
Binary file not shown.
16
examples/onnx/1l_conv/gen.py
Normal file
16
examples/onnx/1l_conv/gen.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from torch import nn
|
||||
from ezkl import export
|
||||
|
||||
class Model(nn.Module):
|
||||
def __init__(self):
|
||||
super(Model, self).__init__()
|
||||
self.layer = nn.Conv2d(3, 1, (1, 1), 1, 1)
|
||||
|
||||
def forward(self, x):
|
||||
return self.layer(x)
|
||||
|
||||
circuit = Model()
|
||||
export(circuit, input_shape = [3, 1, 1])
|
||||
|
||||
|
||||
|
||||
30
examples/onnx/1l_conv/input.json
Normal file
30
examples/onnx/1l_conv/input.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"input_shapes": [
|
||||
[
|
||||
3,
|
||||
1,
|
||||
1
|
||||
]
|
||||
],
|
||||
"input_data": [
|
||||
[
|
||||
0.011350071988999844,
|
||||
0.03404385969042778,
|
||||
0.04626564309000969
|
||||
]
|
||||
],
|
||||
"output_data": [
|
||||
[
|
||||
-0.36590576171875,
|
||||
-0.36590576171875,
|
||||
-0.36590576171875,
|
||||
-0.36590576171875,
|
||||
-0.3919677734375,
|
||||
-0.36590576171875,
|
||||
-0.36590576171875,
|
||||
-0.36590576171875,
|
||||
-0.36590576171875
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
27
examples/onnx/1l_conv/network.onnx
Normal file
27
examples/onnx/1l_conv/network.onnx
Normal file
@@ -0,0 +1,27 @@
|
||||
pytorch1.13.1:¿
|
||||
š
|
||||
input
|
||||
layer.weight
|
||||
|
||||
layer.biasoutput/layer/Conv"Conv*
|
||||
dilations@@ *
|
||||
group *
|
||||
kernel_shape@@ *
|
||||
pads@@@@ *
|
||||
strides@@ torch_jit*&Blayer.weightJ´‚¾(ȾF
|
||||
Õ¾*B
|
||||
layer.biasJPW»¾Z)
|
||||
input
|
||||
|
||||
|
||||
batch_size
|
||||
|
||||
|
||||
b*
|
||||
output
|
||||
|
||||
|
||||
batch_size
|
||||
|
||||
|
||||
B
|
||||
50
examples/onnx/1l_flatten/gen.py
Normal file
50
examples/onnx/1l_flatten/gen.py
Normal file
@@ -0,0 +1,50 @@
|
||||
import io
|
||||
import numpy as np
|
||||
from torch import nn
|
||||
import torch.onnx
|
||||
import torch.nn as nn
|
||||
import torch.nn.init as init
|
||||
import json
|
||||
|
||||
class Circuit(nn.Module):
|
||||
def __init__(self):
|
||||
super(Circuit, self).__init__()
|
||||
self.flatten = nn.Flatten()
|
||||
|
||||
def forward(self, x):
|
||||
return self.flatten(x)
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
torch_model = Circuit()
|
||||
# Input to the model
|
||||
shape = [3, 2, 3]
|
||||
x = 0.1*torch.rand(1,*shape, requires_grad=True)
|
||||
torch_out = torch_model(x)
|
||||
# Export the model
|
||||
torch.onnx.export(torch_model, # model being run
|
||||
x, # model input (or a tuple for multiple inputs)
|
||||
"network.onnx", # where to save the model (can be a file or file-like object)
|
||||
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'}})
|
||||
|
||||
d = ((x).detach().numpy()).reshape([-1]).tolist()
|
||||
|
||||
data = dict(input_shapes = [shape, shape, shape],
|
||||
input_data = [d],
|
||||
output_data = [((o).detach().numpy()).reshape([-1]).tolist() for o in torch_out])
|
||||
|
||||
# Serialize data into file:
|
||||
json.dump( data, open( "input.json", 'w' ) )
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
|
||||
63
examples/onnx/1l_flatten/input.json
Normal file
63
examples/onnx/1l_flatten/input.json
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"input_shapes": [
|
||||
[
|
||||
3,
|
||||
2,
|
||||
3
|
||||
],
|
||||
[
|
||||
3,
|
||||
2,
|
||||
3
|
||||
],
|
||||
[
|
||||
3,
|
||||
2,
|
||||
3
|
||||
]
|
||||
],
|
||||
"input_data": [
|
||||
[
|
||||
0.024982912465929985,
|
||||
0.09144836664199829,
|
||||
0.009130030870437622,
|
||||
0.010118866339325905,
|
||||
0.08052441477775574,
|
||||
0.005395460408180952,
|
||||
0.0011400461662560701,
|
||||
0.07372475415468216,
|
||||
0.023353761062026024,
|
||||
0.05521431565284729,
|
||||
0.09113214910030365,
|
||||
0.04682333394885063,
|
||||
0.007070374675095081,
|
||||
0.03275662660598755,
|
||||
0.013910329900681973,
|
||||
0.06051855906844139,
|
||||
0.05030276998877525,
|
||||
0.002268546959385276
|
||||
]
|
||||
],
|
||||
"output_data": [
|
||||
[
|
||||
0.024982912465929985,
|
||||
0.09144836664199829,
|
||||
0.009130030870437622,
|
||||
0.010118866339325905,
|
||||
0.08052441477775574,
|
||||
0.005395460408180952,
|
||||
0.0011400461662560701,
|
||||
0.07372475415468216,
|
||||
0.023353761062026024,
|
||||
0.05521431565284729,
|
||||
0.09113214910030365,
|
||||
0.04682333394885063,
|
||||
0.007070374675095081,
|
||||
0.03275662660598755,
|
||||
0.013910329900681973,
|
||||
0.06051855906844139,
|
||||
0.05030276998877525,
|
||||
0.002268546959385276
|
||||
]
|
||||
]
|
||||
}
|
||||
16
examples/onnx/1l_flatten/network.onnx
Normal file
16
examples/onnx/1l_flatten/network.onnx
Normal file
@@ -0,0 +1,16 @@
|
||||
pytorch1.12.1:Œ
|
||||
0
|
||||
inputoutput Flatten_0"Flatten*
|
||||
axis torch_jitZ)
|
||||
input
|
||||
|
||||
|
||||
batch_size
|
||||
|
||||
|
||||
b"
|
||||
output
|
||||
|
||||
|
||||
batch_size
|
||||
B
|
||||
16
examples/onnx/1l_leakyrelu/gen.py
Normal file
16
examples/onnx/1l_leakyrelu/gen.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from torch import nn
|
||||
from ezkl import export
|
||||
|
||||
class Model(nn.Module):
|
||||
def __init__(self):
|
||||
super(Model, self).__init__()
|
||||
self.layer = nn.LeakyReLU(negative_slope=0.05)
|
||||
|
||||
def forward(self, x):
|
||||
return self.layer(x)
|
||||
|
||||
circuit = Model()
|
||||
export(circuit, input_shape = [3])
|
||||
|
||||
|
||||
|
||||
21
examples/onnx/1l_leakyrelu/input.json
Normal file
21
examples/onnx/1l_leakyrelu/input.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"input_shapes": [
|
||||
[
|
||||
3
|
||||
]
|
||||
],
|
||||
"input_data": [
|
||||
[
|
||||
0.06149055436253548,
|
||||
0.04009602218866348,
|
||||
0.027487868443131447
|
||||
]
|
||||
],
|
||||
"output_data": [
|
||||
[
|
||||
0.06149055436253548,
|
||||
0.04009602218866348,
|
||||
0.027487868443131447
|
||||
]
|
||||
]
|
||||
}
|
||||
14
examples/onnx/1l_leakyrelu/network.onnx
Normal file
14
examples/onnx/1l_leakyrelu/network.onnx
Normal file
@@ -0,0 +1,14 @@
|
||||
pytorch1.12.1:Ś
|
||||
8
|
||||
inputoutputLeakyRelu_0" LeakyRelu*
|
||||
alphaÍĚL= torch_jitZ!
|
||||
input
|
||||
|
||||
|
||||
batch_size
|
||||
b"
|
||||
output
|
||||
|
||||
|
||||
batch_size
|
||||
B
|
||||
22
examples/onnx/1l_mlp/input.json
Normal file
22
examples/onnx/1l_mlp/input.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"input_shapes": [
|
||||
[
|
||||
3
|
||||
]
|
||||
],
|
||||
"input_data": [
|
||||
[
|
||||
1.54172945022583,
|
||||
0.5346152782440186,
|
||||
1.2172532081604004
|
||||
]
|
||||
],
|
||||
"output_data": [
|
||||
[
|
||||
0.28125,
|
||||
0.6484375,
|
||||
0.0,
|
||||
0.0
|
||||
]
|
||||
]
|
||||
}
|
||||
BIN
examples/onnx/1l_mlp/network.onnx
Normal file
BIN
examples/onnx/1l_mlp/network.onnx
Normal file
Binary file not shown.
16
examples/onnx/1l_prelu/gen.py
Normal file
16
examples/onnx/1l_prelu/gen.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from torch import nn
|
||||
from ezkl import export
|
||||
|
||||
class Model(nn.Module):
|
||||
def __init__(self):
|
||||
super(Model, self).__init__()
|
||||
self.layer = nn.PReLU(num_parameters=3, init=0.25)
|
||||
|
||||
def forward(self, x):
|
||||
return self.layer(x)
|
||||
|
||||
circuit = Model()
|
||||
export(circuit, input_shape = [3, 2, 2])
|
||||
|
||||
|
||||
|
||||
41
examples/onnx/1l_prelu/input.json
Normal file
41
examples/onnx/1l_prelu/input.json
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"input_shapes": [
|
||||
[
|
||||
3,
|
||||
2,
|
||||
2
|
||||
]
|
||||
],
|
||||
"input_data": [
|
||||
[
|
||||
0.024342495948076248,
|
||||
0.04569540172815323,
|
||||
0.07267124205827713,
|
||||
0.013060438446700573,
|
||||
0.09049484878778458,
|
||||
0.023895228281617165,
|
||||
0.06646782904863358,
|
||||
0.005524409003555775,
|
||||
0.08089068531990051,
|
||||
0.0037329555489122868,
|
||||
0.065357506275177,
|
||||
0.04939475655555725
|
||||
]
|
||||
],
|
||||
"output_data": [
|
||||
[
|
||||
0.024342495948076248,
|
||||
0.04569540172815323,
|
||||
0.07267124205827713,
|
||||
0.013060438446700573,
|
||||
0.09049484878778458,
|
||||
0.023895228281617165,
|
||||
0.06646782904863358,
|
||||
0.005524409003555775,
|
||||
0.08089068531990051,
|
||||
0.0037329555489122868,
|
||||
0.065357506275177,
|
||||
0.04939475655555725
|
||||
]
|
||||
]
|
||||
}
|
||||
BIN
examples/onnx/1l_prelu/network.onnx
Normal file
BIN
examples/onnx/1l_prelu/network.onnx
Normal file
Binary file not shown.
16
examples/onnx/1l_relu/gen.py
Normal file
16
examples/onnx/1l_relu/gen.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from torch import nn
|
||||
from ezkl import export
|
||||
|
||||
class MyModel(nn.Module):
|
||||
def __init__(self):
|
||||
super(MyModel, self).__init__()
|
||||
self.layer = nn.ReLU()
|
||||
|
||||
def forward(self, x):
|
||||
return self.layer(x)
|
||||
|
||||
circuit = MyModel()
|
||||
export(circuit, input_shape = [3])
|
||||
|
||||
|
||||
|
||||
21
examples/onnx/1l_relu/input.json
Normal file
21
examples/onnx/1l_relu/input.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"input_shapes": [
|
||||
[
|
||||
3
|
||||
]
|
||||
],
|
||||
"input_data": [
|
||||
[
|
||||
-0.40077725052833557,
|
||||
2.493845224380493,
|
||||
0.5796360969543457
|
||||
]
|
||||
],
|
||||
"output_data": [
|
||||
[
|
||||
0.0,
|
||||
2.493845224380493,
|
||||
0.5796360969543457
|
||||
]
|
||||
]
|
||||
}
|
||||
13
examples/onnx/1l_relu/network.onnx
Normal file
13
examples/onnx/1l_relu/network.onnx
Normal file
@@ -0,0 +1,13 @@
|
||||
pytorch1.12.1:q
|
||||
|
||||
inputoutputRelu_0"Relu torch_jitZ!
|
||||
input
|
||||
|
||||
|
||||
batch_size
|
||||
b"
|
||||
output
|
||||
|
||||
|
||||
batch_size
|
||||
B
|
||||
28
examples/onnx/1l_reshape/input.json
Normal file
28
examples/onnx/1l_reshape/input.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"input_shapes": [
|
||||
[
|
||||
3,
|
||||
2
|
||||
]
|
||||
],
|
||||
"input_data": [
|
||||
[
|
||||
0.9399577379226685,
|
||||
-0.1435815989971161,
|
||||
-1.6204580068588257,
|
||||
0.8732473850250244,
|
||||
-0.12983344495296478,
|
||||
-0.1989465206861496
|
||||
]
|
||||
],
|
||||
"output_data": [
|
||||
[
|
||||
0.9399577379226685,
|
||||
-0.1435815989971161,
|
||||
-1.6204580068588257,
|
||||
0.8732473850250244,
|
||||
-0.12983344495296478,
|
||||
-0.1989465206861496
|
||||
]
|
||||
]
|
||||
}
|
||||
BIN
examples/onnx/1l_reshape/network.onnx
Normal file
BIN
examples/onnx/1l_reshape/network.onnx
Normal file
Binary file not shown.
16
examples/onnx/1l_sigmoid/gen.py
Normal file
16
examples/onnx/1l_sigmoid/gen.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from torch import nn
|
||||
from ezkl import export
|
||||
|
||||
class MyModel(nn.Module):
|
||||
def __init__(self):
|
||||
super(MyModel, self).__init__()
|
||||
self.layer = nn.Sigmoid()
|
||||
|
||||
def forward(self, x):
|
||||
return self.layer(x)
|
||||
|
||||
circuit = MyModel()
|
||||
export(circuit, input_shape = [3])
|
||||
|
||||
|
||||
|
||||
21
examples/onnx/1l_sigmoid/input.json
Normal file
21
examples/onnx/1l_sigmoid/input.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"input_shapes": [
|
||||
[
|
||||
3
|
||||
]
|
||||
],
|
||||
"input_data": [
|
||||
[
|
||||
-0.008400974795222282,
|
||||
0.18489880859851837,
|
||||
-0.7444106340408325
|
||||
]
|
||||
],
|
||||
"output_data": [
|
||||
[
|
||||
0.4978998005390167,
|
||||
0.5460934638977051,
|
||||
0.3220404088497162
|
||||
]
|
||||
]
|
||||
}
|
||||
13
examples/onnx/1l_sigmoid/network.onnx
Normal file
13
examples/onnx/1l_sigmoid/network.onnx
Normal file
@@ -0,0 +1,13 @@
|
||||
pytorch1.12.1:w
|
||||
#
|
||||
inputoutput Sigmoid_0"Sigmoid torch_jitZ!
|
||||
input
|
||||
|
||||
|
||||
batch_size
|
||||
b"
|
||||
output
|
||||
|
||||
|
||||
batch_size
|
||||
B
|
||||
BIN
examples/onnx/2l_linear_conv/network.onnx
Normal file
BIN
examples/onnx/2l_linear_conv/network.onnx
Normal file
Binary file not shown.
BIN
examples/onnx/2l_relu_conv/network.onnx
Normal file
BIN
examples/onnx/2l_relu_conv/network.onnx
Normal file
Binary file not shown.
401
examples/onnx/2l_relu_sigmoid/input.json
Normal file
401
examples/onnx/2l_relu_sigmoid/input.json
Normal file
@@ -0,0 +1,401 @@
|
||||
{
|
||||
"input_shapes": [
|
||||
[
|
||||
3,
|
||||
8,
|
||||
8
|
||||
]
|
||||
],
|
||||
"input_data": [
|
||||
[
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0
|
||||
]
|
||||
],
|
||||
"output_data": [
|
||||
[
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973,
|
||||
0.7310585975646973
|
||||
]
|
||||
]
|
||||
}
|
||||
19
examples/onnx/2l_relu_sigmoid/network.onnx
Normal file
19
examples/onnx/2l_relu_sigmoid/network.onnx
Normal file
@@ -0,0 +1,19 @@
|
||||
pytorch1.12.1:š
|
||||
&
|
||||
inputonnx::Sigmoid_5Relu_0"Relu
|
||||
-
|
||||
onnx::Sigmoid_5output Sigmoid_1"Sigmoid torch_jitZ)
|
||||
input
|
||||
|
||||
|
||||
batch_size
|
||||
|
||||
|
||||
b*
|
||||
output
|
||||
|
||||
|
||||
batch_size
|
||||
|
||||
|
||||
B
|
||||
309
examples/onnx/2l_relu_sigmoid_conv/input.json
Normal file
309
examples/onnx/2l_relu_sigmoid_conv/input.json
Normal file
@@ -0,0 +1,309 @@
|
||||
{
|
||||
"input_shapes": [
|
||||
[
|
||||
3,
|
||||
8,
|
||||
8
|
||||
]
|
||||
],
|
||||
"input_data": [
|
||||
[
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125,
|
||||
0.0078125
|
||||
]
|
||||
],
|
||||
"output_data": [
|
||||
[
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5,
|
||||
0.5
|
||||
]
|
||||
]
|
||||
}
|
||||
BIN
examples/onnx/2l_relu_sigmoid_conv/network.onnx
Normal file
BIN
examples/onnx/2l_relu_sigmoid_conv/network.onnx
Normal file
Binary file not shown.
21
examples/onnx/2l_relu_sigmoid_small/input.json
Normal file
21
examples/onnx/2l_relu_sigmoid_small/input.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"input_shapes": [
|
||||
[
|
||||
3
|
||||
]
|
||||
],
|
||||
"input_data": [
|
||||
[
|
||||
-0.3827013373374939,
|
||||
1.3510069847106934,
|
||||
-0.08920183777809143
|
||||
]
|
||||
],
|
||||
"output_data": [
|
||||
[
|
||||
0.5,
|
||||
0.7942942380905151,
|
||||
0.5
|
||||
]
|
||||
]
|
||||
}
|
||||
15
examples/onnx/2l_relu_sigmoid_small/network.onnx
Normal file
15
examples/onnx/2l_relu_sigmoid_small/network.onnx
Normal file
@@ -0,0 +1,15 @@
|
||||
pytorch1.12.1:Š
|
||||
&
|
||||
inputonnx::Sigmoid_3Relu_0"Relu
|
||||
-
|
||||
onnx::Sigmoid_3output Sigmoid_1"Sigmoid torch_jitZ!
|
||||
input
|
||||
|
||||
|
||||
batch_size
|
||||
b"
|
||||
output
|
||||
|
||||
|
||||
batch_size
|
||||
B
|
||||
21
examples/onnx/2l_relu_small/input.json
Normal file
21
examples/onnx/2l_relu_small/input.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"input_shapes": [
|
||||
[
|
||||
3
|
||||
]
|
||||
],
|
||||
"input_data": [
|
||||
[
|
||||
3.394426107406616,
|
||||
1.1624923944473267,
|
||||
-0.5661267638206482
|
||||
]
|
||||
],
|
||||
"output_data": [
|
||||
[
|
||||
3.394426107406616,
|
||||
1.1624923944473267,
|
||||
0.0
|
||||
]
|
||||
]
|
||||
}
|
||||
15
examples/onnx/2l_relu_small/network.onnx
Normal file
15
examples/onnx/2l_relu_small/network.onnx
Normal file
@@ -0,0 +1,15 @@
|
||||
pytorch1.12.1:“
|
||||
|
||||
inputinput.1Relu_0"Relu
|
||||
|
||||
input.1outputRelu_1"Relu torch_jitZ!
|
||||
input
|
||||
|
||||
|
||||
batch_size
|
||||
b"
|
||||
output
|
||||
|
||||
|
||||
batch_size
|
||||
B
|
||||
BIN
examples/onnx/2l_sigmoid_conv/network.onnx
Normal file
BIN
examples/onnx/2l_sigmoid_conv/network.onnx
Normal file
Binary file not shown.
BIN
examples/onnx/3l_linear_mlp/network.onnx
Normal file
BIN
examples/onnx/3l_linear_mlp/network.onnx
Normal file
Binary file not shown.
104
examples/onnx/large_op_graph/input.json
Normal file
104
examples/onnx/large_op_graph/input.json
Normal file
@@ -0,0 +1,104 @@
|
||||
{
|
||||
"input_shapes": [
|
||||
[
|
||||
3,
|
||||
2,
|
||||
2
|
||||
]
|
||||
],
|
||||
"input_data": [
|
||||
[
|
||||
1.0463101863861084,
|
||||
1.5299336910247803,
|
||||
1.9941356182098389,
|
||||
1.513040542602539,
|
||||
1.4219237565994263,
|
||||
0.24078583717346191,
|
||||
0.050214409828186035,
|
||||
0.4934835433959961,
|
||||
0.8263685703277588,
|
||||
0.5834146738052368,
|
||||
0.8935405015945435,
|
||||
1.5646353960037231
|
||||
]
|
||||
],
|
||||
"output_data": [
|
||||
[
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.125,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.125,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.125,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.625,
|
||||
0.25,
|
||||
0.375,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.625,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.25,
|
||||
0.5,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.5,
|
||||
0.75,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.125,
|
||||
0.125,
|
||||
0.0,
|
||||
0.0,
|
||||
0.875,
|
||||
0.25,
|
||||
0.125,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
]
|
||||
]
|
||||
}
|
||||
BIN
examples/onnx/large_op_graph/network.onnx
Normal file
BIN
examples/onnx/large_op_graph/network.onnx
Normal file
Binary file not shown.
BIN
examples/onnx/mnist_net/network.onnx
Normal file
BIN
examples/onnx/mnist_net/network.onnx
Normal file
Binary file not shown.
@@ -220,9 +220,9 @@ fn neg_mock(example_name: String, counter_example: String) {
|
||||
"-K=17",
|
||||
"mock",
|
||||
"-D",
|
||||
format!("./examples/onnx/examples/{}/input.json", counter_example).as_str(),
|
||||
format!("./examples/onnx/{}/input.json", counter_example).as_str(),
|
||||
"-M",
|
||||
format!("./examples/onnx/examples/{}/network.onnx", example_name).as_str(),
|
||||
format!("./examples/onnx/{}/network.onnx", example_name).as_str(),
|
||||
// "-K",
|
||||
// "2", //causes failure
|
||||
])
|
||||
@@ -248,9 +248,9 @@ fn mock(example_name: String) {
|
||||
"-K=17",
|
||||
"mock",
|
||||
"-D",
|
||||
format!("./examples/onnx/examples/{}/input.json", example_name).as_str(),
|
||||
format!("./examples/onnx/{}/input.json", example_name).as_str(),
|
||||
"-M",
|
||||
format!("./examples/onnx/examples/{}/network.onnx", example_name).as_str(),
|
||||
format!("./examples/onnx/{}/network.onnx", example_name).as_str(),
|
||||
// "-K",
|
||||
// "2", //causes failure
|
||||
])
|
||||
@@ -268,9 +268,9 @@ fn mock_public_inputs(example_name: String) {
|
||||
"-K=17",
|
||||
"mock",
|
||||
"-D",
|
||||
format!("./examples/onnx/examples/{}/input.json", example_name).as_str(),
|
||||
format!("./examples/onnx/{}/input.json", example_name).as_str(),
|
||||
"-M",
|
||||
format!("./examples/onnx/examples/{}/network.onnx", example_name).as_str(),
|
||||
format!("./examples/onnx/{}/network.onnx", example_name).as_str(),
|
||||
// "-K",
|
||||
// "2", //causes failure
|
||||
])
|
||||
@@ -288,9 +288,9 @@ fn mock_public_params(example_name: String) {
|
||||
"-K=17",
|
||||
"mock",
|
||||
"-D",
|
||||
format!("./examples/onnx/examples/{}/input.json", example_name).as_str(),
|
||||
format!("./examples/onnx/{}/input.json", example_name).as_str(),
|
||||
"-M",
|
||||
format!("./examples/onnx/examples/{}/network.onnx", example_name).as_str(),
|
||||
format!("./examples/onnx/{}/network.onnx", example_name).as_str(),
|
||||
// "-K",
|
||||
// "2", //causes failure
|
||||
])
|
||||
@@ -308,9 +308,9 @@ fn kzg_aggr_prove_and_verify(example_name: String) {
|
||||
"prove",
|
||||
"--pfsys=kzg",
|
||||
"-D",
|
||||
format!("./examples/onnx/examples/{}/input.json", example_name).as_str(),
|
||||
format!("./examples/onnx/{}/input.json", example_name).as_str(),
|
||||
"-M",
|
||||
format!("./examples/onnx/examples/{}/network.onnx", example_name).as_str(),
|
||||
format!("./examples/onnx/{}/network.onnx", example_name).as_str(),
|
||||
"--proof-path",
|
||||
format!("kzg_{}.pf", example_name).as_str(),
|
||||
"--vk-path",
|
||||
@@ -329,7 +329,7 @@ fn kzg_aggr_prove_and_verify(example_name: String) {
|
||||
"aggregate",
|
||||
"--pfsys=kzg",
|
||||
"-M",
|
||||
format!("./examples/onnx/examples/{}/network.onnx", example_name).as_str(),
|
||||
format!("./examples/onnx/{}/network.onnx", example_name).as_str(),
|
||||
"--aggregation-snarks",
|
||||
format!("kzg_{}.pf", example_name).as_str(),
|
||||
"--aggregation-vk-paths",
|
||||
@@ -371,9 +371,9 @@ fn kzg_evm_aggr_prove_and_verify(example_name: String) {
|
||||
"prove",
|
||||
"--pfsys=kzg",
|
||||
"-D",
|
||||
format!("./examples/onnx/examples/{}/input.json", example_name).as_str(),
|
||||
format!("./examples/onnx/{}/input.json", example_name).as_str(),
|
||||
"-M",
|
||||
format!("./examples/onnx/examples/{}/network.onnx", example_name).as_str(),
|
||||
format!("./examples/onnx/{}/network.onnx", example_name).as_str(),
|
||||
"--proof-path",
|
||||
format!("kzg_{}.pf", example_name).as_str(),
|
||||
"--vk-path",
|
||||
@@ -392,7 +392,7 @@ fn kzg_evm_aggr_prove_and_verify(example_name: String) {
|
||||
"aggregate",
|
||||
"--pfsys=kzg",
|
||||
"-M",
|
||||
format!("./examples/onnx/examples/{}/network.onnx", example_name).as_str(),
|
||||
format!("./examples/onnx/{}/network.onnx", example_name).as_str(),
|
||||
"--aggregation-snarks",
|
||||
format!("kzg_{}.pf", example_name).as_str(),
|
||||
"--aggregation-vk-paths",
|
||||
@@ -447,9 +447,9 @@ fn kzg_prove_and_verify(example_name: String) {
|
||||
"prove",
|
||||
"--pfsys=kzg",
|
||||
"-D",
|
||||
format!("./examples/onnx/examples/{}/input.json", example_name).as_str(),
|
||||
format!("./examples/onnx/{}/input.json", example_name).as_str(),
|
||||
"-M",
|
||||
format!("./examples/onnx/examples/{}/network.onnx", example_name).as_str(),
|
||||
format!("./examples/onnx/{}/network.onnx", example_name).as_str(),
|
||||
"--proof-path",
|
||||
format!("kzg_{}.pf", example_name).as_str(),
|
||||
"--vk-path",
|
||||
@@ -468,7 +468,7 @@ fn kzg_prove_and_verify(example_name: String) {
|
||||
"verify",
|
||||
"--pfsys=kzg",
|
||||
"-M",
|
||||
format!("./examples/onnx/examples/{}/network.onnx", example_name).as_str(),
|
||||
format!("./examples/onnx/{}/network.onnx", example_name).as_str(),
|
||||
"--proof-path",
|
||||
format!("kzg_{}.pf", example_name).as_str(),
|
||||
"--vk-path",
|
||||
@@ -490,9 +490,9 @@ fn kzg_evm_prove_and_verify(example_name: String, with_solidity: bool) {
|
||||
"prove",
|
||||
"--pfsys=kzg",
|
||||
"-D",
|
||||
format!("./examples/onnx/examples/{}/input.json", example_name).as_str(),
|
||||
format!("./examples/onnx/{}/input.json", example_name).as_str(),
|
||||
"-M",
|
||||
format!("./examples/onnx/examples/{}/network.onnx", example_name).as_str(),
|
||||
format!("./examples/onnx/{}/network.onnx", example_name).as_str(),
|
||||
"--proof-path",
|
||||
format!("kzg_{}.pf", example_name).as_str(),
|
||||
"--vk-path",
|
||||
@@ -505,8 +505,8 @@ fn kzg_evm_prove_and_verify(example_name: String, with_solidity: bool) {
|
||||
.expect("failed to execute process");
|
||||
assert!(status.success());
|
||||
|
||||
let input_arg = format!("./examples/onnx/examples/{}/input.json", example_name);
|
||||
let network_arg = format!("./examples/onnx/examples/{}/network.onnx", example_name);
|
||||
let input_arg = format!("./examples/onnx/{}/input.json", example_name);
|
||||
let network_arg = format!("./examples/onnx/{}/network.onnx", example_name);
|
||||
let code_arg = format!("kzg_{}.code", example_name);
|
||||
let vk_arg = format!("kzg_{}.vk", example_name);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user