@@ -204,7 +204,7 @@ impl QubitTracker {
204
204
}
205
205
206
206
/// Internal class that encapsulates immutable data required by the HighLevelSynthesis transpiler pass.
207
- #[ pyclass( module= "qiskit._accelerate.high_level_synthesis" ) ]
207
+ #[ pyclass( module = "qiskit._accelerate.high_level_synthesis" ) ]
208
208
#[ derive( Clone , Debug ) ]
209
209
pub struct HighLevelSynthesisData {
210
210
// The high-level-synthesis config that specifies the synthesis methods
@@ -344,15 +344,15 @@ impl HighLevelSynthesisData {
344
344
/// Check whether an operation is natively supported.
345
345
pub fn instruction_supported (
346
346
py : Python ,
347
- data : & HighLevelSynthesisData ,
347
+ data : & Bound < HighLevelSynthesisData > ,
348
348
name : & str ,
349
349
qubits : & [ Qubit ] ,
350
350
) -> bool {
351
- match & data. target {
351
+ match & data. borrow ( ) . target {
352
352
Some ( target) => {
353
353
let target = target. borrow ( py) ;
354
354
if target. num_qubits . is_some ( ) {
355
- if data. use_qubit_indices {
355
+ if data. borrow ( ) . use_qubit_indices {
356
356
let physical_qubits = qubits
357
357
. iter ( )
358
358
. map ( |q| PhysicalQubit ( q. index ( ) as u32 ) )
@@ -362,21 +362,21 @@ pub fn instruction_supported(
362
362
target. instruction_supported ( name, None )
363
363
}
364
364
} else {
365
- data. device_insts . contains ( name)
365
+ data. borrow ( ) . device_insts . contains ( name)
366
366
}
367
367
}
368
- None => data. device_insts . contains ( name) ,
368
+ None => data. borrow ( ) . device_insts . contains ( name) ,
369
369
}
370
370
}
371
371
372
372
/// Check whether an operation does not need to be synthesized.
373
373
pub fn definitely_skip_op (
374
374
py : Python ,
375
- data : & HighLevelSynthesisData ,
375
+ data : & Bound < HighLevelSynthesisData > ,
376
376
op : & PackedOperation ,
377
377
qubits : & [ Qubit ] ,
378
378
) -> bool {
379
- if qubits. len ( ) < data. min_qubits {
379
+ if qubits. len ( ) < data. borrow ( ) . min_qubits {
380
380
return true ;
381
381
}
382
382
@@ -395,11 +395,11 @@ pub fn definitely_skip_op(
395
395
396
396
// If there are avilable plugins for this operation, we should try them
397
397
// before checking the equivalence library.
398
- if data. hls_op_names . iter ( ) . any ( |s| s == op. name ( ) ) {
398
+ if data. borrow ( ) . hls_op_names . iter ( ) . any ( |s| s == op. name ( ) ) {
399
399
return false ;
400
400
}
401
401
402
- if let Some ( equiv_lib) = & data. equivalence_library {
402
+ if let Some ( equiv_lib) = & data. borrow ( ) . equivalence_library {
403
403
if equiv_lib. borrow ( py) . has_entry ( op) {
404
404
return true ;
405
405
}
@@ -424,7 +424,7 @@ fn run_on_circuitdata(
424
424
py : Python ,
425
425
input_circuit : & CircuitData ,
426
426
input_qubits : & [ usize ] ,
427
- data : & HighLevelSynthesisData ,
427
+ data : & Bound < HighLevelSynthesisData > ,
428
428
tracker : & mut QubitTracker ,
429
429
) -> PyResult < ( CircuitData , Vec < usize > ) > {
430
430
if input_circuit. num_qubits ( ) != input_qubits. len ( ) {
@@ -651,7 +651,7 @@ fn run_on_circuitdata(
651
651
/// each global qubit (whether it's clean, dirty, or cannot be used).
652
652
fn synthesize_operation (
653
653
py : Python ,
654
- data : & HighLevelSynthesisData ,
654
+ data : & Bound < HighLevelSynthesisData > ,
655
655
tracker : & mut QubitTracker ,
656
656
input_qubits : & [ usize ] ,
657
657
op : & PackedOperation ,
@@ -678,7 +678,7 @@ fn synthesize_operation(
678
678
// change, we return None.
679
679
680
680
// Try to synthesize using plugins.
681
- if data. hls_op_names . iter ( ) . any ( |s| s == op. name ( ) ) {
681
+ if data. borrow ( ) . hls_op_names . iter ( ) . any ( |s| s == op. name ( ) ) {
682
682
output_circuit_and_qubits = synthesize_op_using_plugins (
683
683
py,
684
684
data,
@@ -692,15 +692,15 @@ fn synthesize_operation(
692
692
693
693
// Check if present in the equivalent library.
694
694
if output_circuit_and_qubits. is_none ( ) {
695
- if let Some ( equiv_lib) = & data. equivalence_library {
695
+ if let Some ( equiv_lib) = & data. borrow ( ) . equivalence_library {
696
696
if equiv_lib. borrow ( py) . has_entry ( op) {
697
697
return Ok ( None ) ;
698
698
}
699
699
}
700
700
}
701
701
702
702
// Extract definition.
703
- if output_circuit_and_qubits. is_none ( ) && data. unroll_definitions {
703
+ if output_circuit_and_qubits. is_none ( ) && data. borrow ( ) . unroll_definitions {
704
704
let definition_circuit = op. definition ( params) ;
705
705
match definition_circuit {
706
706
Some ( definition_circuit) => {
@@ -753,7 +753,7 @@ fn synthesize_operation(
753
753
/// Currently, this function does not update the qubit tracker, which is handled upstream.
754
754
fn synthesize_op_using_plugins (
755
755
py : Python ,
756
- data : & HighLevelSynthesisData ,
756
+ data : & Bound < HighLevelSynthesisData > ,
757
757
tracker : & QubitTracker ,
758
758
input_qubits : & [ usize ] ,
759
759
op : & OperationRef ,
@@ -778,7 +778,7 @@ fn synthesize_op_using_plugins(
778
778
// ToDo: how can we avoid cloning data and tracker?
779
779
let res = HLS_SYNTHESIZE_OP_USING_PLUGINS
780
780
. get_bound ( py)
781
- . call1 ( ( op_py, input_qubits, data. clone ( ) , tracker. clone ( ) ) ) ?
781
+ . call1 ( ( op_py, input_qubits, data, tracker. clone ( ) ) ) ?
782
782
. extract :: < Option < ( QuantumCircuitData , Vec < usize > ) > > ( ) ?;
783
783
784
784
if let Some ( ( quantum_circuit_data, qubits) ) = res {
@@ -798,7 +798,7 @@ pub fn py_synthesize_operation(
798
798
py : Python ,
799
799
py_op : Bound < PyAny > ,
800
800
input_qubits : Vec < usize > ,
801
- data : & HighLevelSynthesisData ,
801
+ data : & Bound < HighLevelSynthesisData > ,
802
802
tracker : & mut QubitTracker ,
803
803
) -> PyResult < Option < ( CircuitData , Vec < usize > ) > > {
804
804
let op: OperationFromPython = py_op. extract ( ) ?;
@@ -823,7 +823,7 @@ pub fn py_synthesize_operation(
823
823
pub fn py_run_on_dag (
824
824
py : Python ,
825
825
dag : & DAGCircuit ,
826
- data : & HighLevelSynthesisData ,
826
+ data : & Bound < HighLevelSynthesisData > ,
827
827
qubits_initially_zero : bool ,
828
828
) -> PyResult < Option < DAGCircuit > > {
829
829
// Fast-path: check if HighLevelSynthesis can be skipped altogether. This is only
0 commit comments