コード例 #1
0
ファイル: test_anf.py プロジェクト: stjordanis/myia
def test_graph():
    """Construct a small graph.

    Note that this graph is strictly speaking nonsensical, because it doesn't
    use any actual primitive operations.
    """
    g = Graph()
    x = Parameter(g)
    assert x.value is PARAMETER
    one = Constant(1)
    add = Constant('add')
    return_ = Constant('return')
    value = Apply([add, x, one], g)
    return_ = Apply([return_, value], g)
    g.return_ = return_
    g.parameters.append(x)
コード例 #2
0
def test_graph():
    """Construct a small graph.

    Note that this graph is strictly speaking nonsensical, because it doesn't
    use any actual primitive operations.
    """
    g = Graph()
    x = Parameter(g)
    assert x.value is PARAMETER
    one = Constant(1)
    add = Constant("add")
    return_ = Constant("return")
    value = Apply([add, x, one], g)
    return_ = Apply([return_, value], g)
    g.return_ = return_
    g.parameters.append(x)
    assert g.abstract is None
    g.parameters[0].abstract = 123
    assert g.abstract is None
    g.parameters[0].abstract = None
    g.return_.abstract = 456
    assert g.abstract is None
    g.parameters[0].abstract = 123
    assert g.abstract == AbstractFunctionUnique([123], 456)