示例#1
0
def _opt_fancy_sum(optimizer, node, equiv):
    x = equiv[X]
    shp = equiv[V].value
    ct = Constant(GraphCosmeticPrimitive(f'sum {"x".join(map(str, shp))}'))
    with About(node.debug, 'cosmetic'):
        return Apply([ct, x], node.graph)
示例#2
0
def _opt_fancy_distribute(optimizer, node, equiv):
    x = equiv[X]
    v = equiv[V]
    ct = Constant(GraphCosmeticPrimitive(f'shape→{v.value}', on_edge=True))
    with About(node.debug, 'cosmetic'):
        return Apply([ct, x], node.graph)
示例#3
0
def _opt_fancy_array_to_scalar(optimizer, node, equiv):
    x = equiv[X]
    ct = Constant(GraphCosmeticPrimitive(f'to_scalar', on_edge=True))
    with About(node.debug, 'cosmetic'):
        return Apply([ct, x], node.graph)
示例#4
0
def _opt_fancy_unsafe_static_cast(optimizer, node, equiv):
    x = equiv[X]
    ct = Constant(GraphCosmeticPrimitive(f'cast', on_edge=True))
    with About(node.debug, 'cosmetic'):
        return Apply([ct, x], node.graph)
示例#5
0
def _opt_fancy_make_tuple(optimizer, node, equiv):
    xs = equiv[Xs]
    ct = Constant(GraphCosmeticPrimitive('(...)'))
    with About(node.debug, 'cosmetic'):
        return Apply([ct, *xs], node.graph)
示例#6
0
文件: gprint.py 项目: tor4z/myia
def _opt_fancy_scalar_to_array(optimizer, node, equiv):
    x = equiv[X]
    ct = Constant(GraphCosmeticPrimitive(f"to_array", on_edge=True))
    with About(node.debug, "cosmetic"):
        return Apply([ct, x], node.graph)
示例#7
0
文件: gprint.py 项目: tor4z/myia
def _opt_fancy_tagged(optimizer, node, equiv):
    x = equiv[X]
    v = equiv[V]
    ct = Constant(GraphCosmeticPrimitive(f"@{v.value}", on_edge=True))
    with About(node.debug, "cosmetic"):
        return Apply([ct, x], node.graph)
示例#8
0
def test_dfs():
    in0 = Constant(0)
    in1 = Constant(1)
    value = Apply([in0, in1], Graph())
    assert next(dfs(value)) == value
    assert set(dfs(value)) == {value, in0, in1}