コード例 #1
0
ファイル: gates.py プロジェクト: qiboteam/qibo
 def __init__(self):
     if K.is_custom and not K.executing_eagerly():  # pragma: no cover
         raise_error(
             NotImplementedError, "Custom operator gates should not "
             "be used in compiled mode.")
     super().__init__()
     self._native_op_matrix = None
     self._custom_op_matrix = None
コード例 #2
0
 def __init__(self):
     if K.name == "custom":
         if not K.executing_eagerly():
             raise_error(NotImplementedError,
                         "Custom operator gates should not be used in "
                         "compiled mode.")
         self.gate_op = K.op.apply_gate
     else:
         self.gate_op = None
     super().__init__()
コード例 #3
0
ファイル: cgates.py プロジェクト: NourO93/qibo
 def __init__(self):
     if not K.executing_eagerly():
         raise_error(
             NotImplementedError,
             "Custom operator gates should not be used in compiled "
             "mode.")
     super().__init__()
     if K.op:
         self.gate_op = K.op.apply_gate
     self.qubits_tensor = None
     self.qubits_tensor_dm = None
     self.target_qubits_dm = None
コード例 #4
0
ファイル: gates.py プロジェクト: mlazzarin/qibo
 def __init__(self):
     if K.op is not None:
         if not K.executing_eagerly():  # pragma: no cover
             raise_error(
                 NotImplementedError,
                 "Custom operator gates should not be used in "
                 "compiled mode.")
         self.gate_op = K.op.apply_gate
     else:
         self.gate_op = None
     super().__init__()
     self._native_op_matrix = None
     self._custom_op_matrix = None
コード例 #5
0
ファイル: test_backends_init.py プロジェクト: mlazzarin/qibo
def test_set_backend(backend_name):
    """Check ``set_backend`` for switching gate backends."""
    original_backend = backends.get_backend()
    backends.set_backend(backend_name)
    assert K.name == backend_name
    assert str(K) == backend_name
    assert repr(K) == backend_name
    assert K.executing_eagerly()
    h = gates.H(0)
    if backend_name == "qibotf" or backend_name == "qibojit":
        assert h.gate_op
    else:
        assert h.gate_op is None
    backends.set_backend(original_backend)
コード例 #6
0
ファイル: test_backends_init.py プロジェクト: qiboteam/qibo
def test_set_backend(backend_name):
    """Check ``set_backend`` for switching gate backends."""
    original_backend = backends.get_backend()
    backends.set_backend(backend_name)
    assert K.name == backend_name
    if K.platform is None:
        assert str(K) == backend_name
        assert repr(K) == backend_name
    else:
        platform = K.get_platform()
        assert str(K) == f"{backend_name} ({platform})"
        assert repr(K) == f"{backend_name} ({platform})"
    assert K.executing_eagerly()
    h = gates.H(0)
    backends.set_backend(original_backend)
コード例 #7
0
ファイル: test_backends_init.py プロジェクト: rickyHong/qibo
def test_set_backend(backend):
    """Check ``set_backend`` for switching gate backends."""
    original_backend = backends.get_backend()
    backends.set_backend(backend)
    if backend == "defaulteinsum":
        target_name = "tensorflow_defaulteinsum"
    elif backend == "matmuleinsum":
        target_name = "tensorflow_matmuleinsum"
    else:
        target_name = backend
    assert K.name == target_name
    assert str(K) == target_name
    assert repr(K) == target_name
    assert K.executing_eagerly()
    h = gates.H(0)
    if backend == "custom":
        assert K.custom_einsum is None
        assert h.gate_op
    else:
        assert h.gate_op is None
    backends.set_backend(original_backend)