Skip to content

Commit fbb545b

Browse files
committed
wip
1 parent 1e4cd73 commit fbb545b

File tree

3 files changed

+611
-1
lines changed

3 files changed

+611
-1
lines changed

frontend/catalyst/compiler.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ def run_python_compiler(self, mlir_module):
488488
import xdsl
489489
from xdsl.context import Context
490490
from xdsl.dialects import arith, builtin, func, scf, tensor, transform
491+
from .python_compiler import quantum
491492
generic_assembly_format = mlir_module.operation.get_asm(binary=False, print_generic_op_form=True, assume_verified=True)
492493
ctx = Context(allow_unregistered=True)
493494
ctx.load_dialect(arith.Arith)
@@ -496,6 +497,7 @@ def run_python_compiler(self, mlir_module):
496497
ctx.load_dialect(scf.Scf)
497498
ctx.load_dialect(tensor.Tensor)
498499
ctx.load_dialect(transform.Transform)
500+
ctx.load_dialect(quantum.QuantumDialect)
499501
# TODO: In order of importance
500502
# TODO: Load quantum
501503
# TODO: Load gradient
@@ -504,7 +506,16 @@ def run_python_compiler(self, mlir_module):
504506
# but it is likely worse than an unregistered dialect.
505507
# TODO: Load Catalyst
506508
# TODO: Load ion/ppm/mbqc/zne...
507-
m = xdsl.parser.Parser(ctx, generic_assembly_format).parse_module()
509+
mlir = """
510+
func.func @foo(%arg0 : i64) -> () {
511+
%0 = quantum.alloc(4) : !quantum.reg
512+
%1 = quantum.alloc(%arg0) : !quantum.reg
513+
return
514+
}
515+
"""
516+
m = xdsl.parser.Parser(ctx, mlir).parse_module()
517+
breakpoint()
518+
print(m)
508519
# TODO: transform the program based on the transform dialect
509520

510521
@debug_logger

frontend/catalyst/python_compiler/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)