From aaea07b252f3a668d2b321765770f09759365356 Mon Sep 17 00:00:00 2001 From: hachem Date: Sun, 6 Sep 2026 23:13:30 +0200 Subject: add: scalar kernel engine with fusion --- tester/main.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tester') diff --git a/tester/main.c b/tester/main.c index 194fc77..020b230 100644 --- a/tester/main.c +++ b/tester/main.c @@ -147,5 +147,24 @@ int main(void) } psi_free_quantum_circuit(&circuit); + + size_t kt[] = { 0 }; + struct PsiKernelBatch batch = psi_new_kernel_batch(1); + struct PsiQuantumGate hg = psi_hadamard_gate(); + psi_add_kernel(&batch, psi_new_kernel("H", psi_clone_matrix(hg.matrix), kt, 1)); + psi_add_kernel(&batch, psi_new_kernel("H", psi_clone_matrix(hg.matrix), kt, 1)); + psi_free_quantum_gate(&hg); + + size_t before = batch.count; + psi_optimize_kernel_batch(&batch); + + struct PsiVector state = psi_new_state_0(); + psi_execute_kernel_batch(batch, &state); + + printf("kernels = %zu -> %zu (fused), HH|0> = [%g, %g]\n", + before, batch.count, state.data[0].real, state.data[1].real); + + psi_free_vector(&state); + psi_free_kernel_batch(&batch); } -- cgit v1.3