Ejemplo n.º 1
0
def do_plan(context, graph):
    """ Take the ATerm expression graph and do inner-most evaluation to
    generate a linear sequence of instructions from that together with
    the table of inputs and outputs, built kernels forms the execution
    plan.

    Example::

    ::
        a + b * c

    ::
        vars %a %b %c
        %0 = Elemwise[np.mul,nogil](%b, %c)
        %0 = Elemwise[np.add,nogil,inplace](%a, %0)
        ret %0

    """
    context = dict(context)

    aterm_graph = context['aterm_graph']

    ivisitor = InstructionGen(have_numbapro=have_numbapro)
    plan = ivisitor.visit(aterm_graph)

    context['instructions'] = ivisitor.result()
    print ivisitor.result()

    return context, plan
Ejemplo n.º 2
0
def do_plan(context, aterm_graph):
    """ Take the ATerm expression graph and do inner-most evaluation to
    generate a linear sequence of instructions from that together with
    the table of inputs and outputs, built kernels forms the execution
    plan.

    Example::

    ::
        a + b * c

    ::
        vars %a %b %c
        %0 = Elemwise[np.mul,nogil](%b, %c)
        %0 = Elemwise[np.add,nogil,inplace](%a, %0)
        ret %0

    """
    context = dict(context)

    ivisitor = InstructionGen(context['executors'],
                              have_numbapro=have_numbapro)
    plan = ivisitor.visit(aterm_graph)

    context['instructions'] = ivisitor.result()
    context['symbols'] = ivisitor.symbols

    return context, plan
Ejemplo n.º 3
0
def do_plan(context, graph):
    """ Take the ATerm expression graph and do inner-most evaluation to
    generate a linear sequence of instructions from that together with
    the table of inputs and outputs, built kernels forms the execution
    plan.

    Example::

    ::
        a + b * c

    ::
        vars %a %b %c
        %0 = Elemwise[np.mul,nogil](%b, %c)
        %0 = Elemwise[np.add,nogil,inplace](%a, %0)
        ret %0

    """
    context = dict(context)

    aterm_graph = context['aterm_graph']

    igen = InstructionGen()
    igen.visit(aterm_graph) # effectful
    plan = igen.plan()

    context['plan'] = plan
    return context, graph