Skip to content

Commit

Permalink
fix: bad copy constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-camuto committed Oct 31, 2024
1 parent ff3c682 commit fce9673
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
18 changes: 8 additions & 10 deletions src/circuit/ops/layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4320,11 +4320,10 @@ pub fn floor<F: PrimeField + TensorType + PartialOrd + std::hash::Hash>(
) -> Result<ValTensor<F>, CircuitError> {
// decompose with base scale and then set the last element to zero
let decomposition = decompose(config, region, values, &(scale.0 as usize), &legs)?;
// set the last element to zero and then recompose
let zero = create_constant_tensor(F::ZERO, 1);
// set the last element to zero and then recompose, we don't actually need to assign here
// as this will automatically be assigned in the recompose function and uses the constant caching of RegionCtx
let zero = ValType::Constant(F::ZERO);

let assigned_zero = region.assign(&config.custom_gates.inputs[0], &zero)?;
let assigned_zero = assigned_zero.get_inner_tensor()?[0].clone();
let negative_one = create_constant_tensor(integer_rep_to_felt(-1), 1);
let assigned_negative_one = region.assign(&config.custom_gates.inputs[1], &negative_one)?;

Expand Down Expand Up @@ -4377,7 +4376,7 @@ pub fn floor<F: PrimeField + TensorType + PartialOrd + std::hash::Hash>(
incremented_elem.get_inner_tensor()?.clone()[0].clone();

// set the last elem to zero
inner_tensor[sliced_input.len() - 1] = assigned_zero.clone();
inner_tensor[sliced_input.len() - 1] = zero.clone();

Ok(inner_tensor.clone())
};
Expand Down Expand Up @@ -4434,11 +4433,10 @@ pub fn ceil<F: PrimeField + TensorType + PartialOrd + std::hash::Hash>(
) -> Result<ValTensor<F>, CircuitError> {
// decompose with base scale and then set the last element to zero
let decomposition = decompose(config, region, values, &(scale.0 as usize), &legs)?;
// set the last element to zero and then recompose
let zero = create_constant_tensor(F::ZERO, 1);
// set the last element to zero and then recompose, we don't actually need to assign here
// as this will automatically be assigned in the recompose function and uses the constant caching of RegionCtx
let zero = ValType::Constant(F::ZERO);

let assigned_zero = region.assign(&config.custom_gates.inputs[0], &zero)?;
let assigned_zero = assigned_zero.get_inner_tensor()?[0].clone();
let one = create_constant_tensor(integer_rep_to_felt(1), 1);
let assigned_one = region.assign(&config.custom_gates.inputs[1], &one)?;

Expand Down Expand Up @@ -4491,7 +4489,7 @@ pub fn ceil<F: PrimeField + TensorType + PartialOrd + std::hash::Hash>(
incremented_elem.get_inner_tensor()?.clone()[0].clone();

// set the last elem to zero
inner_tensor[sliced_input.len() - 1] = assigned_zero.clone();
inner_tensor[sliced_input.len() - 1] = zero.clone();

Ok(inner_tensor.clone())
};
Expand Down
7 changes: 4 additions & 3 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,9 +852,11 @@ mod native_tests {
fn kzg_prove_and_verify_tight_lookup_(test: &str) {
crate::native_tests::init_binary();
let test_dir = TempDir::new(test).unwrap();
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
let path = test_dir.into_path();
let path = path.to_str().unwrap();
crate::native_tests::mv_test_(path, test);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, false, "single", Commitments::KZG, 1);
test_dir.close().unwrap();
// test_dir.close().unwrap();
}

#(#[test_case(TESTS[N])])*
Expand Down Expand Up @@ -1632,7 +1634,6 @@ mod native_tests {

let status = Command::new(format!("{}/release/ezkl", *CARGO_TARGET_DIR))
.args(args)
.stdout(std::process::Stdio::null())
.status()
.expect("failed to execute process");
assert!(status.success());
Expand Down

0 comments on commit fce9673

Please sign in to comment.