mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-09 14:47:56 -05:00
fix(hpu): scalar rot & shift were not doing anything and not tested in test/hpu.rs
This commit is contained in:
committed by
Pierre Gardrat
parent
f9c89212ea
commit
79f1d22573
@@ -44,10 +44,10 @@ crate::impl_fw!("Llt" [
|
||||
|
||||
// NB: fallback to ilp
|
||||
// TODO: Add dedicated llt implementation
|
||||
ROTS_R => fw_impl::ilp::iop_rotate_scalar_right;
|
||||
ROTS_L => fw_impl::ilp::iop_rotate_scalar_left;
|
||||
SHIFTS_R => fw_impl::ilp::iop_shift_scalar_right;
|
||||
SHIFTS_L => fw_impl::ilp::iop_shift_scalar_left;
|
||||
ROTS_R => fw_impl::llt::iop_rotate_scalar_right;
|
||||
ROTS_L => fw_impl::llt::iop_rotate_scalar_left;
|
||||
SHIFTS_R => fw_impl::llt::iop_shift_scalar_right;
|
||||
SHIFTS_L => fw_impl::llt::iop_shift_scalar_left;
|
||||
|
||||
// NB: fallback to ilp
|
||||
// TODO: Add dedicated llt implementation
|
||||
@@ -301,6 +301,70 @@ pub fn iop_rotate_left(prog: &mut Program) {
|
||||
iop_shiftrotx(prog, ShiftKind::RotLeft, dst, src, rot_amount).add_to_prog(prog);
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip(prog))]
|
||||
pub fn iop_shift_scalar_right(prog: &mut Program) {
|
||||
// Allocate metavariables:
|
||||
// Dest -> Operand
|
||||
let dst = VarCell::from_vec(prog.iop_template_var(OperandKind::Dst, 0));
|
||||
// Src -> Operand
|
||||
let src = VarCell::from_vec(prog.iop_template_var(OperandKind::Src, 0));
|
||||
// ShiftAmount -> Operand
|
||||
let amount = VarCell::from_vec(prog.iop_template_var(OperandKind::Imm, 0));
|
||||
|
||||
// Add Comment header
|
||||
prog.push_comment("SHIFT_R Operand::Dst Operand::Src Immediate::Src".to_string());
|
||||
// Deferred implementation to generic rotx function
|
||||
iop_shiftrotx(prog, ShiftKind::ShiftRight, dst, src, amount).add_to_prog(prog);
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip(prog))]
|
||||
pub fn iop_shift_scalar_left(prog: &mut Program) {
|
||||
// Allocate metavariables:
|
||||
// Dest -> Operand
|
||||
let dst = VarCell::from_vec(prog.iop_template_var(OperandKind::Dst, 0));
|
||||
// Src -> Operand
|
||||
let src = VarCell::from_vec(prog.iop_template_var(OperandKind::Src, 0));
|
||||
// ShiftAmount -> Operand
|
||||
let amount = VarCell::from_vec(prog.iop_template_var(OperandKind::Imm, 0));
|
||||
|
||||
// Add Comment header
|
||||
prog.push_comment("SHIFT_L Operand::Dst Operand::Src Immediate::Src".to_string());
|
||||
// Deferred implementation to generic rotx function
|
||||
iop_shiftrotx(prog, ShiftKind::ShiftLeft, dst, src, amount).add_to_prog(prog);
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip(prog))]
|
||||
pub fn iop_rotate_scalar_right(prog: &mut Program) {
|
||||
// Allocate metavariables:
|
||||
// Dest -> Operand
|
||||
let dst = VarCell::from_vec(prog.iop_template_var(OperandKind::Dst, 0));
|
||||
// Src -> Operand
|
||||
let src = VarCell::from_vec(prog.iop_template_var(OperandKind::Src, 0));
|
||||
// ShiftAmount -> Operand
|
||||
let rot_amount = VarCell::from_vec(prog.iop_template_var(OperandKind::Imm, 0));
|
||||
|
||||
// Add Comment header
|
||||
prog.push_comment("ROT_R Operand::Dst Operand::Src Immediate::Src".to_string());
|
||||
// Deferred implementation to generic rotx function
|
||||
iop_shiftrotx(prog, ShiftKind::RotRight, dst, src, rot_amount).add_to_prog(prog);
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip(prog))]
|
||||
pub fn iop_rotate_scalar_left(prog: &mut Program) {
|
||||
// Allocate metavariables:
|
||||
// Dest -> Operand
|
||||
let dst = VarCell::from_vec(prog.iop_template_var(OperandKind::Dst, 0));
|
||||
// Src -> Operand
|
||||
let src = VarCell::from_vec(prog.iop_template_var(OperandKind::Src, 0));
|
||||
// ShiftAmount -> Operand
|
||||
let rot_amount = VarCell::from_vec(prog.iop_template_var(OperandKind::Imm, 0));
|
||||
|
||||
// Add Comment header
|
||||
prog.push_comment("ROT_L Operand::Dst Operand::Src Operand::Immediate".to_string());
|
||||
// Deferred implementation to generic rotx function
|
||||
iop_shiftrotx(prog, ShiftKind::RotLeft, dst, src, rot_amount).add_to_prog(prog);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Helper Functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -399,19 +399,16 @@ mod hpu_test {
|
||||
"ovf_ssub",
|
||||
"ovf_muls"
|
||||
]);
|
||||
|
||||
// NB: Scalar Rot/Shift not supported yet
|
||||
// #[cfg(feature = "hpu")]
|
||||
// hpu_testbundle!("rots"::8 => [
|
||||
// "rots_r",
|
||||
// "rots_l"
|
||||
// ]);
|
||||
// #[cfg(feature = "hpu")]
|
||||
// hpu_testbundle!("shifts"::8 => [
|
||||
// "shifts_r",
|
||||
// "shifts_l"
|
||||
// ]);
|
||||
|
||||
#[cfg(feature = "hpu")]
|
||||
hpu_testbundle!("rots"::8 => [
|
||||
"rots_r",
|
||||
"rots_l"
|
||||
]);
|
||||
#[cfg(feature = "hpu")]
|
||||
hpu_testbundle!("shifts"::8 => [
|
||||
"shifts_r",
|
||||
"shifts_l"
|
||||
]);
|
||||
#[cfg(feature = "hpu")]
|
||||
hpu_testbundle!("alu"::8 => [
|
||||
"add",
|
||||
@@ -494,19 +491,16 @@ mod hpu_test {
|
||||
"ovf_ssub",
|
||||
"ovf_muls"
|
||||
]);
|
||||
|
||||
// NB: Scalar Rot/Shift not supported yet
|
||||
// #[cfg(feature = "hpu")]
|
||||
// hpu_testbundle!("rots"::16 => [
|
||||
// "rots_r",
|
||||
// "rots_l"
|
||||
// ]);
|
||||
// #[cfg(feature = "hpu")]
|
||||
// hpu_testbundle!("shifts"::16 => [
|
||||
// "shifts_r",
|
||||
// "shifts_l"
|
||||
// ]);
|
||||
|
||||
#[cfg(feature = "hpu")]
|
||||
hpu_testbundle!("rots"::16 => [
|
||||
"rots_r",
|
||||
"rots_l"
|
||||
]);
|
||||
#[cfg(feature = "hpu")]
|
||||
hpu_testbundle!("shifts"::16 => [
|
||||
"shifts_r",
|
||||
"shifts_l"
|
||||
]);
|
||||
#[cfg(feature = "hpu")]
|
||||
hpu_testbundle!("alu"::16 => [
|
||||
"add",
|
||||
@@ -589,19 +583,16 @@ mod hpu_test {
|
||||
"ovf_ssub",
|
||||
"ovf_muls"
|
||||
]);
|
||||
|
||||
// NB: Scalar Rot/Shift not supported yet
|
||||
// #[cfg(feature = "hpu")]
|
||||
// hpu_testbundle!("rots"::32 => [
|
||||
// "rots_r",
|
||||
// "rots_l"
|
||||
// ]);
|
||||
// #[cfg(feature = "hpu")]
|
||||
// hpu_testbundle!("shifts"::32 => [
|
||||
// "shifts_r",
|
||||
// "shifts_l"
|
||||
// ]);
|
||||
|
||||
#[cfg(feature = "hpu")]
|
||||
hpu_testbundle!("rots"::32 => [
|
||||
"rots_r",
|
||||
"rots_l"
|
||||
]);
|
||||
#[cfg(feature = "hpu")]
|
||||
hpu_testbundle!("shifts"::32 => [
|
||||
"shifts_r",
|
||||
"shifts_l"
|
||||
]);
|
||||
#[cfg(feature = "hpu")]
|
||||
hpu_testbundle!("alu"::32 => [
|
||||
"add",
|
||||
@@ -684,19 +675,16 @@ mod hpu_test {
|
||||
"ovf_ssub",
|
||||
"ovf_muls"
|
||||
]);
|
||||
|
||||
// NB: Scalar Rot/Shift not supported yet
|
||||
// #[cfg(feature = "hpu")]
|
||||
// hpu_testbundle!("rots"::64 => [
|
||||
// "rots_r",
|
||||
// "rots_l"
|
||||
// ]);
|
||||
// #[cfg(feature = "hpu")]
|
||||
// hpu_testbundle!("shifts"::64 => [
|
||||
// "shifts_r",
|
||||
// "shifts_l"
|
||||
// ]);
|
||||
|
||||
#[cfg(feature = "hpu")]
|
||||
hpu_testbundle!("rots"::64 => [
|
||||
"rots_r",
|
||||
"rots_l"
|
||||
]);
|
||||
#[cfg(feature = "hpu")]
|
||||
hpu_testbundle!("shifts"::64 => [
|
||||
"shifts_r",
|
||||
"shifts_l"
|
||||
]);
|
||||
#[cfg(feature = "hpu")]
|
||||
hpu_testbundle!("alu"::64 => [
|
||||
"add",
|
||||
@@ -779,19 +767,16 @@ mod hpu_test {
|
||||
"ovf_ssub",
|
||||
"ovf_muls"
|
||||
]);
|
||||
|
||||
// NB: Scalar Rot/Shift not supported yet
|
||||
// #[cfg(feature = "hpu")]
|
||||
// hpu_testbundle!("rots"::128 => [
|
||||
// "rots_r",
|
||||
// "rots_l"
|
||||
// ]);
|
||||
// #[cfg(feature = "hpu")]
|
||||
// hpu_testbundle!("shifts"::128 => [
|
||||
// "shifts_r",
|
||||
// "shifts_l"
|
||||
// ]);
|
||||
|
||||
#[cfg(feature = "hpu")]
|
||||
hpu_testbundle!("rots"::128 => [
|
||||
"rots_r",
|
||||
"rots_l"
|
||||
]);
|
||||
#[cfg(feature = "hpu")]
|
||||
hpu_testbundle!("shifts"::128 => [
|
||||
"shifts_r",
|
||||
"shifts_l"
|
||||
]);
|
||||
#[cfg(feature = "hpu")]
|
||||
hpu_testbundle!("alu"::128 => [
|
||||
"add",
|
||||
|
||||
Reference in New Issue
Block a user