-
Notifications
You must be signed in to change notification settings - Fork 40
add: functional onnx converter #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| @@ -0,0 +1,45 @@ | |||
| use std::{collections::HashMap, rc::Rc, vec}; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this as a separate layer? Is it not fused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/utils/loader.rs
Outdated
| for tensor in inp { | ||
| model.tensors.push(tensor); | ||
| model.tensors.push(tensor.clone()); | ||
| // println!("tensor: {:?}", tensor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's tons of extraneous changes. Clean them up.
| @@ -0,0 +1,302 @@ | |||
| # Oggn | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turn this into the way that the other converter is written with a class and a main function
| struct.pack_into('q', shape, 0, -1) | ||
| init.raw_data = bytes(shape) | ||
|
|
||
| onnx.save(model, "/Users/siddharthaalluri/Desktop/sid-alluri/zkml/python/onnx_converter/new_mnist.onnx") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix this
| params = [kernel[0], kernel[1], stride[0], stride[1]] | ||
|
|
||
| elif node.op_type == "Relu": | ||
| layer_type = "ReLUONNX" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there a separate ReluONNX layer?
| output_dim = get_output_dim(node_id, model_graph) | ||
| params = [] | ||
|
|
||
| elif node.op_type == "Gemm": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work for all forms of Gemm?
| "layer_type": layer_type, | ||
| "params": params, ## Change params HELP HELP HELP HELP | ||
| "inp_shapes": inputs_dim, | ||
| "inp_idxes": inp_idxes, ### RANDOM COME BACK HERE HELP HELP HELP HELP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's going on here?
src/layers.rs
Outdated
| pub mod squared_diff; | ||
| pub mod tanh; | ||
| pub mod update; | ||
| pub mod relu; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the rust extension to sort imports.
src/layers/dag.rs
Outdated
| tanh::TanhChip, | ||
| update::UpdateChip, | ||
| update::UpdateChip, | ||
| relu::ReluLayerChip, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move ReLU to the non-linear diretory
src/layers/fully_connected.rs
Outdated
| ) -> Array<Value<F>, IxDyn> { | ||
| assert_eq!(input.ndim(), 2); | ||
| assert_eq!(weight.ndim(), 2); | ||
| println!("input shape: {:?}", input.shape()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extraneous
src/layers/layer.rs
Outdated
| Tanh, | ||
| Transpose, | ||
| Update, | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there an extra space?
src/layers/max_pool_2d.rs
Outdated
| let (sx, sy) = (sx as usize, sy as usize); | ||
|
|
||
| // Only support batch size 1 for now | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extraneous
src/utils/loader.rs
Outdated
|
|
||
| model | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extraneous
Converts an onnx model into the .msgpack. Current functionality: converts a simple mnist onnx model.
To run:
cargo build --release./target/release/time_circuit python/onnx_converter/first_transformed_onnx.msgpack examples/mnist/inp.msgpack kzg