mercredi 12 avril 2017

How does one create a function execution DAGs that is not evaluated immediately in Python?

I wanted to create a "symbolic" representation of function calls (in my mind right now the best way to represent this is with a Graph or a DAG or a Tree) i.e. set up an execution graph and then execute the graph later, with the possibility with slightly different inputs or the graph having a completely different state when executed (similarly how TensorFlow does it, with feeds and inputs to the graph).

So for example if I had:

graph = f( g('a','b', h('c','d') ), seed )

I would have the graph:

enter image description here

and the essentially have control of how I execute the graph:

graph.execute()

I feel this is some sort of design pattern since say TensorFlow, Mathematica and SymPy seem to all use (note it seems language independent). Though, I had a hard time finding the name of the design pattern so that I could implement it myself in Python with my own execution graph nodes and data types. Does anyone know how to do this or have a nice link to the name of the design pattern so that I can build this?

Its important for me that the graph creation is as simple as easy as TensorFlow, SymPy etc. In other words. I'd like that I can have multiple syntaxes to create the same graph. For example It shouldn't be to hard to do:

h = h('c','d')
g = g('a','b', h )
graph = f( g, seed )

if the user wanted to.

Aucun commentaire:

Enregistrer un commentaire