From fce9673131af5a4e08d45760ebfca87d88ebebf2 Mon Sep 17 00:00:00 2001 From: dante <45801863+alexander-camuto@users.noreply.github.com> Date: Wed, 30 Oct 2024 21:32:06 -0400 Subject: [PATCH] fix: bad copy constraints --- src/circuit/ops/layouts.rs | 18 ++++++++---------- tests/integration_tests.rs | 7 ++++--- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/circuit/ops/layouts.rs b/src/circuit/ops/layouts.rs index 2e6227144..17847bea3 100644 --- a/src/circuit/ops/layouts.rs +++ b/src/circuit/ops/layouts.rs @@ -4320,11 +4320,10 @@ pub fn floor( ) -> Result, 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)?; @@ -4377,7 +4376,7 @@ pub fn floor( 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()) }; @@ -4434,11 +4433,10 @@ pub fn ceil( ) -> Result, 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)?; @@ -4491,7 +4489,7 @@ pub fn ceil( 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()) }; diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index ecfb9daab..820d686ad 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -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])])* @@ -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());