Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tiny graph

image

安装

pip install -e .

快速入门

image

定义节点

class AddComp(Component):

    def run(self,input):
        self.context = {
            "input":input,
            "output":input + 1
        }
        return input + 1
  • 定义 Component 类
  • 需要实现一下 run 这个抽象方法

构建计算图

对一个简单图是包括节点和节点之间的边

  • 定义一个图
simple_graph = SimpleGraph("simple_chain")
  • 添加节点
add_one_comp = AddComp("add_1")
mul_two_comp = MulComp("mul_1")
  • 添加节点之间的边
simple_graph.add_connect(add_one_comp,mul_two_comp)
  • 为图指定起始节点和结束节点
simple_graph.start_comp_name = "add_1"
simple_graph.end_comp_name = "mul_1"

编译

  • 随后可以通过指定不同遍历引擎实现不同编译
simple_graph.compile("add_1")

运行

res = simple_graph.run(2)

文档说明

节点类型

image

  • common 为普通节点
  • aggregate 聚合节点
  • condition 条件节点

About

tiny graph control flow

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages