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

interpreter: add missing scf ops #3910

Open
compor opened this issue Feb 14, 2025 · 0 comments
Open

interpreter: add missing scf ops #3910

compor opened this issue Feb 14, 2025 · 0 comments
Labels
interpreter xDSL Interpreter

Comments

@compor
Copy link
Collaborator

compor commented Feb 14, 2025

Missing interpreter functions for scf operations (split off from #3784 CC @erick-xanadu):

@interpreter.register_impls
class ScfFunctionsExt(interpreters.scf.ScfFunctions):

    @interpreter.impl_terminator(scf.ConditionOp)
    def run_conditionop(self, interp: interpreter.Interpreter, op: scf.ConditionOp, args: interpreter.PythonValues) -> interpreter.PythonValues:
        return interpreter.ReturnedValues(args), ()

    @interpreter.impl(scf.WhileOp)
    def run_whileop(self, interp: interpreter.Interpreter, op: scf.WhileOp, args: interpreter.PythonValues) -> interpreter.PythonValues:
        results = args

        while True:
            before_region = op.before_region
            results = interp.run_ssacfg_region(before_region, (*results,), "while.before_region")
            if not results[0]:
                break

            results = results[1:]
            after_region = op.after_region
            results = interp.run_ssacfg_region(after_region, (*results,), "while.after_region")
        return results[1:]
@compor compor added the interpreter xDSL Interpreter label Feb 14, 2025
@compor compor changed the title interpreter: Add missing scf ops interpreter: add missing scf ops Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter xDSL Interpreter
Projects
None yet
Development

No branches or pull requests

1 participant