Compare commits

..

3 Commits

Author SHA1 Message Date
jason
202e630ccc minor changes 2025-02-05 10:10:13 -05:00
dante
81d085d14b Update public_commitments.md 2025-02-05 11:20:26 +00:00
Alexander Camuto
087936a02f docs: advanced security notices 2025-02-04 15:52:06 +00:00
7 changed files with 12 additions and 68 deletions

View File

@@ -1,7 +1,7 @@
import ezkl
project = 'ezkl'
release = '18.1.12'
release = '0.0.0'
version = release

View File

@@ -1,42 +0,0 @@
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):
return x // 3
circuit = MyModel()
x = torch.randint(0, 10, (1, 2, 2, 8))
out = circuit(x)
print(x)
print(out)
print(x/3)
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'))

View File

@@ -1 +0,0 @@
{"input_data": [[3, 4, 0, 9, 2, 6, 2, 5, 1, 5, 3, 5, 5, 7, 0, 2, 6, 1, 4, 4, 1, 9, 7, 7, 5, 8, 2, 0, 1, 5, 9, 8]]}

View File

@@ -157,9 +157,7 @@ pub(crate) fn div<F: PrimeField + TensorType + PartialOrd + std::hash::Hash>(
// implicitly check if the prover provided output is within range
let claimed_output = identity(config, region, &[claimed_output], true)?;
// check if x is too large only if the decomp would support overflow in the previous op
if F::from_u128(IntegerRep::MAX as u128)
< F::from_u128(region.base() as u128).pow([region.legs() as u64]) - F::ONE
{
if (IntegerRep::MAX).abs() < ((region.base() as i128).pow(region.legs() as u32)) - 1 {
// here we decompose and extract the sign of the input
let sign = sign(config, region, &[claimed_output.clone()])?;
@@ -256,9 +254,7 @@ pub(crate) fn recip<F: PrimeField + TensorType + PartialOrd + std::hash::Hash>(
)?;
// check if x is too large only if the decomp would support overflow in the previous op
if F::from_u128(IntegerRep::MAX as u128)
< F::from_u128(region.base() as u128).pow([region.legs() as u64]) - F::ONE
{
if (IntegerRep::MAX).abs() < ((region.base() as i128).pow(region.legs() as u32)) - 1 {
// here we decompose and extract the sign of the input
let sign = sign(config, region, &[masked_output.clone()])?;
let abs_value = pairwise(
@@ -2656,9 +2652,9 @@ pub fn mean_of_squares_axes<F: PrimeField + TensorType + PartialOrd + std::hash:
let squared = pow(config, region, values, 2)?;
let sum_squared = sum_axes(config, region, &[squared], axes)?;
let dividend: usize = values[0].len() / sum_squared.len();
let dividand: usize = values[0].len() / sum_squared.len();
let mean_squared = div(config, region, &[sum_squared], F::from(dividend as u64))?;
let mean_squared = div(config, region, &[sum_squared], F::from(dividand as u64))?;
Ok(mean_squared)
}

View File

@@ -274,10 +274,12 @@ pub fn new_op_from_onnx(
symbol_values: &SymbolValues,
run_args: &crate::RunArgs,
) -> Result<(SupportedOp, Vec<usize>), GraphError> {
use crate::circuit::InputType;
use std::f64::consts::E;
use tract_onnx::tract_core::ops::array::Trilu;
use crate::circuit::InputType;
let input_scales = inputs
.iter()
.flat_map(|x| x.out_scales())
@@ -1272,19 +1274,9 @@ pub fn new_op_from_onnx(
// get the non constant index
let denom = c.raw_values[0];
let op = SupportedOp::Hybrid(HybridOp::Div {
SupportedOp::Hybrid(HybridOp::Div {
denom: denom.into(),
});
// if the input is scale 0 we re up to the max scale
if input_scales[0] == 0 {
SupportedOp::Rescaled(Rescaled {
inner: Box::new(op),
scale: vec![(0, scale_to_multiplier(scales.get_max()) as u128)],
})
} else {
op
}
})
} else {
return Err(GraphError::MisformedParams(
"only support non zero divisors of size 1".to_string(),

View File

@@ -206,7 +206,7 @@ mod native_tests {
"1l_tiny_div",
];
const TESTS: [&str; 99] = [
const TESTS: [&str; 98] = [
"1l_mlp", //0
"1l_slice", //1
"1l_concat", //2
@@ -309,7 +309,6 @@ mod native_tests {
"log", // 95
"exp", // 96
"general_exp", // 97
"integer_div", // 98
];
const WASM_TESTS: [&str; 46] = [
@@ -548,7 +547,7 @@ mod native_tests {
}
});
seq!(N in 0..=98 {
seq!(N in 0..=97 {
#(#[test_case(TESTS[N])])*
#[ignore]