Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Frontend] Compile IR from docstring. #1334

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

erick-xanadu
Copy link
Contributor

@erick-xanadu erick-xanadu commented Nov 27, 2024

Context:

Adds functionality to compile and execute code specified in a docstring for debugging purposes.

import pennylane as qml

from catalyst.debug.compiler_functions import docstringir


@docstringir
def foo(x: int) -> int:
    """
    module @foo {
      func.func public @jit_foo(%arg0: tensor<i64>) -> tensor<i64> attributes { llvm.emit_c_interface } {
        return %arg0 : tensor<i64>
      }
      module attributes {transform.with_named_sequence} {
        transform.named_sequence @__transform_main(%arg0: !transform.op<"builtin.module">) {
          transform.yield
        }
      }
      func.func @setup() {
        quantum.init
        return
      }
      func.func @teardown() {
        quantum.finalize
        return
      }
    }
    """


print(foo(1))
print(foo.mlir)

Description of the Change:

Benefits:

Possible Drawbacks:

Related GitHub Issues:

While this is functional, I think it would be best to clean up some other interfaces before merging this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant