Skip to content

Math

math

MathFunctions dataclass

Bases: InterpreterFunctions

Source code in xdsl/interpreters/math.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
@register_impls
class MathFunctions(InterpreterFunctions):
    @impl(math.ExpOp)
    def run_exp(
        self, interpreter: Interpreter, op: math.ExpOp, args: PythonValues
    ) -> PythonValues:
        (arg,) = args
        return (exp(arg),)

    @impl(math.SqrtOp)
    def run_sqrt(
        self, interpreter: Interpreter, op: math.SqrtOp, args: PythonValues
    ) -> PythonValues:
        (arg,) = args
        return (sqrt(arg),)

    @impl(math.LogOp)
    def run_log(
        self, interpreter: Interpreter, op: math.LogOp, args: PythonValues
    ) -> PythonValues:
        (arg,) = args
        from math import log

        return (log(arg),)

run_exp(interpreter: Interpreter, op: math.ExpOp, args: PythonValues) -> PythonValues

Source code in xdsl/interpreters/math.py
15
16
17
18
19
20
@impl(math.ExpOp)
def run_exp(
    self, interpreter: Interpreter, op: math.ExpOp, args: PythonValues
) -> PythonValues:
    (arg,) = args
    return (exp(arg),)

run_sqrt(interpreter: Interpreter, op: math.SqrtOp, args: PythonValues) -> PythonValues

Source code in xdsl/interpreters/math.py
22
23
24
25
26
27
@impl(math.SqrtOp)
def run_sqrt(
    self, interpreter: Interpreter, op: math.SqrtOp, args: PythonValues
) -> PythonValues:
    (arg,) = args
    return (sqrt(arg),)

run_log(interpreter: Interpreter, op: math.LogOp, args: PythonValues) -> PythonValues

Source code in xdsl/interpreters/math.py
29
30
31
32
33
34
35
36
@impl(math.LogOp)
def run_log(
    self, interpreter: Interpreter, op: math.LogOp, args: PythonValues
) -> PythonValues:
    (arg,) = args
    from math import log

    return (log(arg),)