file_path
stringlengths
7
180
content
stringlengths
0
811k
repo
stringclasses
11 values
vta/python/vta/top/__init__.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/python/vta/top/bitpack.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/python/vta/top/graphpack.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/python/vta/top/op.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/python/vta/top/utils.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/python/vta/top/vta_conv2d.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/python/vta/top/vta_conv2d_transpose.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/python/vta/top/vta_dense.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/python/vta/top/vta_group_conv2d.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/python/vta/transform.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/runtime/runtime.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
https://github.com/zk-ml/tachikoma
vta/scripts/tune_conv2d.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/scripts/tune_conv2d_transpose.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/scripts/tune_dense.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/scripts/tune_group_conv2d.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/scripts/tune_resnet.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/tests/python/de10nano/test_program_rpc.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/tests/python/integration/test_benchmark_gemm.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/tests/python/integration/test_benchmark_topi_conv2d.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/tests/python/integration/test_benchmark_topi_conv2d_transpose.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/tests/python/integration/test_benchmark_topi_dense.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/tests/python/integration/test_benchmark_topi_group_conv2d.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/tests/python/pynq/test_program_rpc.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/tests/python/unittest/test_environment.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/tests/python/unittest/test_vta_insn.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/tutorials/autotvm/tune_alu_vta.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/tutorials/autotvm/tune_relay_vta.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/tutorials/frontend/deploy_classification.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/tutorials/frontend/deploy_detection.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/tutorials/matrix_multiply.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/tutorials/optimize/convolution_opt.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/tutorials/optimize/matrix_multiply_opt.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
vta/tutorials/vta_get_started.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
web/apps/node/example.js
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
https://github.com/zk-ml/tachikoma
web/apps/node/wasi_example.js
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
https://github.com/zk-ml/tachikoma
web/apps/node/wasi_rpc_server.js
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
https://github.com/zk-ml/tachikoma
web/emcc/decorate_as_wasi.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
web/emcc/preload.js
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
https://github.com/zk-ml/tachikoma
web/jest.config.js
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
https://github.com/zk-ml/tachikoma
web/rollup.config.js
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
https://github.com/zk-ml/tachikoma
web/tests/node/test_module_load.js
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
https://github.com/zk-ml/tachikoma
web/tests/node/test_ndarray.js
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
https://github.com/zk-ml/tachikoma
web/tests/node/test_packed_func.js
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
https://github.com/zk-ml/tachikoma
web/tests/python/prepare_test_libs.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
web/tests/python/webgpu_rpc_test.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
web/tests/python/websock_rpc_test.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
https://github.com/zk-ml/tachikoma
host/src/main.rs
use methods::{PREDICTION_ELF, PREDICTION_ID}; use risc0_zkvm::Prover; use risc0_zkvm::serde::{from_slice, to_vec}; use std::io; fn main() { // Make the prover. let mut prover = Prover::new(PREDICTION_ELF).expect("Prover should be constructed from valid ELF binary"); // TODO: Implement communicati...
https://github.com/only4sim/ZK-DTP
methods/build.rs
fn main() { risc0_build::embed_methods(); }
https://github.com/only4sim/ZK-DTP
methods/guest/src/bin/prediction.rs
// TODO: Rename this file to change the name of this method from METHOD_NAME #![no_main] // If you want to try std support, also update the guest Cargo.toml file #![no_std] // std support is experimental use risc0_zkvm::guest::env; risc0_zkvm::guest::entry!(main); pub fn main() { // TODO: Implement your guest c...
https://github.com/only4sim/ZK-DTP
methods/src/lib.rs
include!(concat!(env!("OUT_DIR"), "/methods.rs"));
https://github.com/only4sim/ZK-DTP
plot_iris_dataset.ipynb
{ "cells": [ { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "# The...
https://github.com/only4sim/ZK-DTP
plot_iris_dtc.ipynb
{"cells":[{"cell_type":"code","execution_count":44,"metadata":{"collapsed":false,"jupyter":{"outputs_hidden":false},"trusted":true},"outputs":[],"source":["%matplotlib inline"]},{"cell_type":"markdown","metadata":{},"source":["\n","# Plot the decision surface of decision trees trained on the iris dataset\n","\n","Plot ...
https://github.com/only4sim/ZK-DTP
backwards/backward.py
# # A script for generating a backprop computational graph from forward # import argparse import ast from typing import Literal, Union import msgpack import numpy as np class CircuitConfig(): def __init__(self, starting_index): self.next_index = starting_index self.outp_to_grad = {} self.l...
https://github.com/ddkang/zkml
examples/mnist/data_to_npy.py
import tensorflow as tf import numpy as np import msgpack from tensorflow import keras mnist = tf.keras.datasets.mnist (images_train, labels_train), (images_test, labels_test) = mnist.load_data() x = images_test[0] y = labels_test[0] print(y) x = x.flatten() / 255. x = x.astype(np.float32) print(x.dtype, x.shape) np...
https://github.com/ddkang/zkml
python/converter.py
import argparse import ast from typing import Literal, Union import tensorflow as tf import numpy as np import tflite import msgpack def get_shape(interpreter: tf.lite.Interpreter, tensor_idx): if tensor_idx == -1: return [] tensor = interpreter.get_tensor(tensor_idx) return list(tensor.shape) def handle_nu...
https://github.com/ddkang/zkml
python/input_converter.py
import argparse import ast import numpy as np import msgpack def main(): parser = argparse.ArgumentParser() parser.add_argument('--model_config', type=str, required=True) parser.add_argument('--inputs', type=str, required=True) parser.add_argument('--output', type=str, required=True) args = parser.parse_args...
https://github.com/ddkang/zkml
python/training_converter.py
# A converter for training data # Performs the conversion npy -> msgpack # TODO: Ensure that training works with models that take in multiple input shapes # # Shortcut: # `python3 python/training_converter.py --input_shapes 7,7,320 --input_idxes 1,0 --output training_data/inputs.msgpack --labels_output training_data/...
https://github.com/ddkang/zkml
src/bin/test_circuit.rs
use halo2_proofs::{dev::MockProver, halo2curves::bn256::Fr}; use zkml::{ model::ModelCircuit, utils::{ helpers::get_public_values, loader::{load_model_msgpack, ModelMsgpack}, }, }; fn main() { let config_fname = std::env::args().nth(1).expect("config file path"); let inp_fname = std::env::args().nth(...
https://github.com/ddkang/zkml
src/bin/time_circuit.rs
use halo2_proofs::halo2curves::{bn256::Fr, pasta::Fp}; use zkml::{ model::ModelCircuit, utils::{proving_ipa::time_circuit_ipa, proving_kzg::time_circuit_kzg}, }; fn main() { let config_fname = std::env::args().nth(1).expect("config file path"); let inp_fname = std::env::args().nth(2).expect("input file path");...
https://github.com/ddkang/zkml
src/bin/verify_circuit.rs
use halo2_proofs::halo2curves::bn256::Fr; use zkml::{ model::ModelCircuit, utils::{loader::load_config_msgpack, proving_kzg::verify_circuit_kzg}, }; fn main() { let config_fname = std::env::args().nth(1).expect("config file path"); let vkey_fname = std::env::args().nth(2).expect("verification key file path"); ...
https://github.com/ddkang/zkml
src/bin/verify_wav.rs
use std::fs::File; use halo2_proofs::{dev::MockProver, halo2curves::bn256::Fr}; use zkml::{ model::ModelCircuit, utils::{ helpers::get_public_values, loader::{load_config_msgpack, ModelMsgpack, TensorMsgpack}, }, }; fn main() { let config_fname = std::env::args().nth(1).expect("config file path"); l...
https://github.com/ddkang/zkml
src/commitments.rs
pub mod commit; pub mod packer; pub mod poseidon_commit;
https://github.com/ddkang/zkml
src/commitments/commit.rs
use std::{collections::HashMap, rc::Rc}; use halo2_proofs::{circuit::Layouter, halo2curves::ff::PrimeField, plonk::Error}; use crate::{gadgets::gadget::GadgetConfig, layers::layer::CellRc}; pub trait Commit<F: PrimeField> { fn commit( &self, layouter: impl Layouter<F>, gadget_config: Rc<GadgetConfig>, ...
https://github.com/ddkang/zkml
src/commitments/packer.rs
use std::{ cmp::{max, min}, collections::{BTreeMap, HashMap}, marker::PhantomData, rc::Rc, }; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Value}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error, Expression}, poly::Rotation, }; use ndarray::{Array, IxDyn}; use crate::{ gadgets:...
https://github.com/ddkang/zkml
src/commitments/poseidon_commit.rs
use std::{collections::HashMap, marker::PhantomData, rc::Rc}; use halo2_gadgets::poseidon::{ primitives::{generate_constants, Absorbing, ConstantLength, Domain, Mds, Spec}, PaddedWord, PoseidonSpongeInstructions, Pow5Chip, Pow5Config, Sponge, }; use halo2_proofs::{ circuit::Layouter, halo2curves::ff::{FromUnif...
https://github.com/ddkang/zkml
src/gadgets.rs
pub mod add_pairs; pub mod adder; pub mod bias_div_floor_relu6; pub mod bias_div_round_relu6; pub mod dot_prod; pub mod gadget; pub mod input_lookup; pub mod max; pub mod mul_pairs; pub mod sqrt_big; pub mod square; pub mod squared_diff; pub mod sub_pairs; pub mod update; pub mod var_div; pub mod var_div_big; pub mod v...
https://github.com/ddkang/zkml
src/gadgets/add_pairs.rs
use std::{marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error}, poly::Rotation, }; use super::gadget::{Gadget, GadgetConfig, GadgetType}; type AddPairsConfig = GadgetConfig; pub struct AddPairsChip<F: Prime...
https://github.com/ddkang/zkml
src/gadgets/adder.rs
use std::{marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region, Value}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error, Expression}, poly::Rotation, }; use super::gadget::{Gadget, GadgetConfig, GadgetType}; type AdderConfig = GadgetConfig; pub struct Adder...
https://github.com/ddkang/zkml
src/gadgets/bias_div_floor_relu6.rs
use std::{collections::HashMap, marker::PhantomData}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error, Expression}, poly::Rotation, }; use crate::gadgets::gadget::convert_to_u64; use super::gadget::{Gadget, GadgetConfig, GadgetType};...
https://github.com/ddkang/zkml
src/gadgets/bias_div_round_relu6.rs
use std::{collections::HashMap, marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region, Value}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error, Expression}, poly::Rotation, }; use crate::gadgets::gadget::convert_to_u64; use super::gadget::{Gadget, GadgetConfi...
https://github.com/ddkang/zkml
src/gadgets/dot_prod.rs
use std::{marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{Advice, Column, ConstraintSystem, Error, Expression}, poly::Rotation, }; use crate::gadgets::adder::AdderChip; use super::gadget::{Gadget, GadgetConfig, GadgetType}; ty...
https://github.com/ddkang/zkml
src/gadgets/gadget.rs
use std::{ collections::{BTreeSet, HashMap}, sync::Arc, }; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::group::ff::PrimeField, plonk::{Advice, Column, Error, Fixed, Selector, TableColumn}, }; use num_bigint::{BigUint, ToBigUint}; use num_traits::cast::ToPrimitive; #[derive(Clo...
https://github.com/ddkang/zkml
src/gadgets/input_lookup.rs
use std::{marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region, Value}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error}, }; use super::gadget::{Gadget, GadgetConfig, GadgetType}; pub struct InputLookupChip<F: PrimeField> { config: Rc<GadgetConfig>, _marke...
https://github.com/ddkang/zkml
src/gadgets/max.rs
use std::{marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error}, poly::Rotation, }; use crate::gadgets::gadget::convert_to_u64; use super::gadget::{Gadget, GadgetConfig, GadgetType}; pub struct MaxChip<F: Pr...
https://github.com/ddkang/zkml
src/gadgets/mul_pairs.rs
use std::{marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error}, poly::Rotation, }; use super::gadget::{Gadget, GadgetConfig, GadgetType}; type MulPairsConfig = GadgetConfig; pub struct MulPairsChip<F: Prime...
https://github.com/ddkang/zkml
src/gadgets/nonlinear.rs
pub mod exp; pub mod logistic; pub mod non_linearity; pub mod pow; pub mod relu; pub mod rsqrt; pub mod sqrt; pub mod tanh;
https://github.com/ddkang/zkml
src/gadgets/nonlinear/exp.rs
use std::{collections::HashMap, marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error}, }; use super::{ super::gadget::{Gadget, GadgetConfig, GadgetType}, non_linearity::NonLinearGadget, }; type ExpGadgetCon...
https://github.com/ddkang/zkml
src/gadgets/nonlinear/logistic.rs
use std::{collections::HashMap, marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error}, }; use super::{ super::gadget::{Gadget, GadgetConfig, GadgetType}, non_linearity::NonLinearGadget, }; pub struct Logist...
https://github.com/ddkang/zkml
src/gadgets/nonlinear/non_linearity.rs
use std::{collections::HashMap, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region, Value}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error, Expression, Selector}, poly::Rotation, }; use crate::gadgets::gadget::convert_to_u128; use super::super::gadget::Gadget; use super::supe...
https://github.com/ddkang/zkml
src/gadgets/nonlinear/pow.rs
use std::{collections::HashMap, marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error}, }; use super::{ super::gadget::{Gadget, GadgetConfig, GadgetType}, non_linearity::NonLinearGadget, }; // IMPORTANT: Pow...
https://github.com/ddkang/zkml
src/gadgets/nonlinear/relu.rs
use std::{collections::HashMap, marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error}, }; use super::{ super::gadget::{Gadget, GadgetConfig, GadgetType}, non_linearity::NonLinearGadget, }; pub struct ReluCh...
https://github.com/ddkang/zkml
src/gadgets/nonlinear/rsqrt.rs
use std::{collections::HashMap, marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error}, }; use super::{ super::gadget::{Gadget, GadgetConfig, GadgetType}, non_linearity::NonLinearGadget, }; pub struct RsqrtG...
https://github.com/ddkang/zkml
src/gadgets/nonlinear/sqrt.rs
use std::{collections::HashMap, marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error}, }; use super::{ super::gadget::{Gadget, GadgetConfig, GadgetType}, non_linearity::NonLinearGadget, }; pub struct SqrtGa...
https://github.com/ddkang/zkml
src/gadgets/nonlinear/tanh.rs
use std::{collections::HashMap, marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error}, }; use super::{ super::gadget::{Gadget, GadgetConfig, GadgetType}, non_linearity::NonLinearGadget, }; pub struct TanhGa...
https://github.com/ddkang/zkml
src/gadgets/sqrt_big.rs
use std::{marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error, Expression}, poly::Rotation, }; use crate::gadgets::gadget::convert_to_u64; use super::gadget::{Gadget, GadgetConfig, GadgetType}; type SqrtBig...
https://github.com/ddkang/zkml
src/gadgets/square.rs
use std::{marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error}, poly::Rotation, }; use super::gadget::{Gadget, GadgetConfig, GadgetType}; pub struct SquareGadgetChip<F: PrimeField> { config: Rc<GadgetConfig>, _mar...
https://github.com/ddkang/zkml
src/gadgets/squared_diff.rs
use std::{marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error}, poly::Rotation, }; use super::gadget::{Gadget, GadgetConfig, GadgetType}; type SquaredDiffConfig = GadgetConfig; pub struct SquaredDiffGadgetC...
https://github.com/ddkang/zkml
src/gadgets/sub_pairs.rs
use std::{marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error}, poly::Rotation, }; use super::gadget::{Gadget, GadgetConfig, GadgetType}; type SubPairsConfig = GadgetConfig; pub struct SubPairsChip<F: Prime...
https://github.com/ddkang/zkml
src/gadgets/update.rs
use std::marker::PhantomData; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error, Expression}, poly::Rotation, }; use crate::gadgets::gadget::{convert_to_u64, GadgetConfig}; use super::gadget::{Gadget, GadgetType}; type UpdateConfig = ...
https://github.com/ddkang/zkml
src/gadgets/var_div.rs
use std::{marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error, Expression}, poly::Rotation, }; use rounded_div::RoundedDiv; use super::gadget::{convert_to_u128, Gadget, GadgetConfig, GadgetType}; type VarDiv...
https://github.com/ddkang/zkml
src/gadgets/var_div_big.rs
use std::{marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error, Expression}, poly::Rotation, }; use rounded_div::RoundedDiv; use super::gadget::{convert_to_u128, Gadget, GadgetConfig, GadgetType}; pub struct ...
https://github.com/ddkang/zkml
src/gadgets/var_div_big3.rs
use std::{marker::PhantomData, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region}, halo2curves::ff::PrimeField, plonk::{ConstraintSystem, Error, Expression}, poly::Rotation, }; use rounded_div::RoundedDiv; use super::gadget::{convert_to_u128, Gadget, GadgetConfig, GadgetType}; pub struct ...
https://github.com/ddkang/zkml
src/layers.rs
// Generics pub mod averager; pub mod arithmetic; pub mod shape; // Concrete implementations pub mod avg_pool_2d; pub mod batch_mat_mul; pub mod conv2d; pub mod div_fixed; pub mod fully_connected; pub mod logistic; pub mod max_pool_2d; pub mod mean; pub mod noop; pub mod pow; pub mod rsqrt; pub mod softmax; pub mod s...
https://github.com/ddkang/zkml
src/layers/arithmetic.rs
use std::{collections::HashMap, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter}, halo2curves::ff::PrimeField, plonk::Error, }; use crate::{gadgets::gadget::GadgetConfig, utils::helpers::broadcast}; use super::layer::{AssignedTensor, CellRc}; pub mod add; pub mod div_var; pub mod mul; pub mod su...
https://github.com/ddkang/zkml
src/layers/arithmetic/add.rs
use std::{collections::HashMap, rc::Rc, vec}; use halo2_proofs::{ circuit::{AssignedCell, Layouter}, halo2curves::ff::PrimeField, plonk::Error, }; use ndarray::{Array, IxDyn}; use crate::{ gadgets::{ add_pairs::AddPairsChip, gadget::{Gadget, GadgetConfig, GadgetType}, nonlinear::relu::ReluChip, ...
https://github.com/ddkang/zkml
src/layers/arithmetic/div_var.rs
use std::{collections::HashMap, rc::Rc, vec}; use halo2_proofs::{ circuit::{AssignedCell, Layouter}, halo2curves::ff::PrimeField, plonk::Error, }; use ndarray::{Array, IxDyn}; use crate::{ gadgets::{ gadget::{Gadget, GadgetConfig, GadgetType}, mul_pairs::MulPairsChip, var_div::VarDivRoundChip, }...
https://github.com/ddkang/zkml
src/layers/arithmetic/mul.rs
use std::{collections::HashMap, rc::Rc, vec}; use halo2_proofs::{ circuit::{AssignedCell, Layouter}, halo2curves::ff::PrimeField, plonk::Error, }; use ndarray::{Array, IxDyn}; use crate::{ gadgets::{ gadget::{Gadget, GadgetConfig, GadgetType}, mul_pairs::MulPairsChip, var_div::VarDivRoundChip, }...
https://github.com/ddkang/zkml
src/layers/arithmetic/sub.rs
use std::{collections::HashMap, rc::Rc, vec}; use halo2_proofs::{ circuit::{AssignedCell, Layouter}, halo2curves::ff::PrimeField, plonk::Error, }; use ndarray::{Array, IxDyn}; use crate::{ gadgets::{ gadget::{Gadget, GadgetConfig, GadgetType}, sub_pairs::SubPairsChip, }, layers::layer::{AssignedTe...
https://github.com/ddkang/zkml
src/layers/averager.rs
use std::{collections::HashMap, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter}, halo2curves::ff::PrimeField, plonk::Error, }; use crate::gadgets::gadget::Gadget; use crate::gadgets::{adder::AdderChip, gadget::GadgetConfig, var_div::VarDivRoundChip}; use super::layer::{AssignedTensor, CellRc, La...
https://github.com/ddkang/zkml
src/layers/avg_pool_2d.rs
use std::{collections::HashMap, rc::Rc}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Value}, halo2curves::ff::PrimeField, plonk::Error, }; use ndarray::{Array, IxDyn}; use crate::{ gadgets::gadget::{GadgetConfig, GadgetType}, layers::max_pool_2d::MaxPool2DChip, }; use super::{ averager::Average...
https://github.com/ddkang/zkml