Skip to content

Commit

Permalink
quantum -> gate
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarice committed Oct 11, 2024
1 parent d9ad7ab commit ad38d30
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 58 deletions.
8 changes: 4 additions & 4 deletions inconspiquous/dialects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def get_linalg():

return Linalg

def get_quantum():
from inconspiquous.dialects.quantum import Quantum
def get_gate():
from inconspiquous.dialects.gate import Gate

return Quantum
return Gate

def get_scf():
from xdsl.dialects.scf import Scf
Expand All @@ -61,8 +61,8 @@ def get_test():
"builtin": get_builtin,
"cf": get_cf,
"func": get_func,
"gate": get_gate,
"linalg": get_linalg,
"quantum": get_quantum,
"scf": get_scf,
"stim": get_stim,
"tensor": get_tensor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AngleAttr(ParametrizedAttribute):
[0, 2) and implicitly multiplying by pi
"""

name = "quantum.angle"
name = "gate.angle"
data: ParameterDef[FloatAttr[Float64Type]]

def __init__(self, f: float):
Expand Down Expand Up @@ -71,37 +71,37 @@ def __neg__(self) -> AngleAttr:

@irdl_attr_definition
class HadamardGate(SingleQubitGate):
name = "quantum.h"
name = "gate.h"


@irdl_attr_definition
class XGate(SingleQubitGate):
name = "quantum.x"
name = "gate.x"


@irdl_attr_definition
class YGate(SingleQubitGate):
name = "quantum.y"
name = "gate.y"


@irdl_attr_definition
class ZGate(SingleQubitGate):
name = "quantum.z"
name = "gate.z"


@irdl_attr_definition
class PhaseGate(SingleQubitGate):
name = "quantum.s"
name = "gate.s"


@irdl_attr_definition
class TGate(SingleQubitGate):
name = "quantum.t"
name = "gate.t"


@irdl_attr_definition
class RZGate(SingleQubitGate):
name = "quantum.rz"
name = "gate.rz"

angle: ParameterDef[AngleAttr]

Expand All @@ -121,24 +121,24 @@ def print_parameters(self, printer: Printer) -> None:

@irdl_attr_definition
class CNotGate(TwoQubitGate):
name = "quantum.cnot"
name = "gate.cnot"


@irdl_attr_definition
class CZGate(TwoQubitGate):
name = "quantum.cz"
name = "gate.cz"


@irdl_attr_definition
class ToffoliGate(GateAttr):
name = "quantum.toffoli"
name = "gate.toffoli"

def num_qubits(self) -> int:
return 3


Quantum = Dialect(
"quantum",
Gate = Dialect(
"gate",
[],
[
AngleAttr,
Expand Down
41 changes: 41 additions & 0 deletions tests/filecheck/dialects/gate.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// RUN: QUOPT_ROUNDTRIP

"test.op"() {"angle" = #gate.angle<0>} : () -> ()

// CHECK: "test.op"() {"angle" = #gate.angle<0>} : () -> ()

"test.op"() {"angle" = #gate.angle<pi>} : () -> ()

// CHECK-NEXT: "test.op"() {"angle" = #gate.angle<pi>} : () -> ()

"test.op"() {"angle" = #gate.angle<2pi>} : () -> ()

// CHECK-NEXT: "test.op"() {"angle" = #gate.angle<0>} : () -> ()

"test.op"() {"angle" = #gate.angle<0.5pi>} : () -> ()

// CHECK-NEXT: "test.op"() {"angle" = #gate.angle<0.5pi>} : () -> ()

"test.op"() {"angle" = #gate.angle<1.5pi>} : () -> ()

// CHECK-NEXT: "test.op"() {"angle" = #gate.angle<1.5pi>} : () -> ()

"test.op"() {"angle" = #gate.angle<2.5pi>} : () -> ()

// CHECK-NEXT: "test.op"() {"angle" = #gate.angle<0.5pi>} : () -> ()

"test.op"() {"angle" = #gate.angle<-0.5pi>} : () -> ()

// CHECK-NEXT: "test.op"() {"angle" = #gate.angle<1.5pi>} : () -> ()

"test.op"() {"angle" = #gate.angle<-pi>} : () -> ()

// CHECK-NEXT: "test.op"() {"angle" = #gate.angle<pi>} : () -> ()

"test.op"() {"gate" = #gate.h} : () -> ()

// CHECK-NEXT: "test.op"() {"gate" = #gate.h} : () -> ()

"test.op"() {"gate" = #gate.rz<pi>} : () -> ()

// CHECK-NEXT: "test.op"() {"gate" = #gate.rz<pi>} : () -> ()
41 changes: 0 additions & 41 deletions tests/filecheck/dialects/quantum.mlir

This file was deleted.

0 comments on commit ad38d30

Please sign in to comment.