fix(gpu): build with hpu and zk features

This commit is contained in:
Nicolas Sarlin
2025-05-23 13:38:27 +02:00
committed by Nicolas Sarlin
parent 52bc778629
commit 14e1ee5bd3
2 changed files with 12 additions and 3 deletions

View File

@@ -315,7 +315,7 @@ clippy_hpu: install_rs_check_toolchain
.PHONY: clippy_gpu_hpu # Run clippy lints on tfhe with "gpu" and "hpu" enabled .PHONY: clippy_gpu_hpu # Run clippy lints on tfhe with "gpu" and "hpu" enabled
clippy_gpu_hpu: install_rs_check_toolchain clippy_gpu_hpu: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy \ RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy \
--features=boolean,shortint,integer,internal-keycache,gpu,hpu,pbs-stats,extended-types \ --features=boolean,shortint,integer,internal-keycache,gpu,hpu,pbs-stats,extended-types,zk-pok \
--all-targets \ --all-targets \
-p $(TFHE_SPEC) -- --no-deps -D warnings -p $(TFHE_SPEC) -- --no-deps -D warnings

View File

@@ -276,7 +276,8 @@ mod zk {
} }
} }
fn move_to_device(&mut self, device: crate::Device) { #[allow(clippy::unnecessary_wraps)] // Method can return an error if hpu is enabled
fn move_to_device(&mut self, device: crate::Device) -> Result<(), crate::Error> {
let new_value = match (&self, device) { let new_value = match (&self, device) {
(Self::Cpu(_), crate::Device::Cpu) => None, (Self::Cpu(_), crate::Device::Cpu) => None,
#[cfg(feature = "gpu")] #[cfg(feature = "gpu")]
@@ -303,11 +304,18 @@ mod zk {
}); });
Some(Self::Cuda(cuda_ct)) Some(Self::Cuda(cuda_ct))
} }
#[cfg(feature = "hpu")]
(_, crate::Device::Hpu) => {
return Err(crate::error!(
"Hpu does not support ProvenCompactCiphertextList"
))
}
}; };
if let Some(v) = new_value { if let Some(v) = new_value {
*self = v; *self = v;
} }
Ok(())
} }
} }
@@ -330,7 +338,8 @@ mod zk {
.map(Self::Cpu)?; .map(Self::Cpu)?;
if let Some(device) = device_of_internal_keys() { if let Some(device) = device_of_internal_keys() {
new.move_to_device(device); new.move_to_device(device)
.map_err(serde::de::Error::custom)?;
} }
Ok(new) Ok(new)