本文整理汇总了Python中theano.gof.cc.CLinker类的典型用法代码示例。如果您正苦于以下问题:Python CLinker类的具体用法?Python CLinker怎么用?Python CLinker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CLinker类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_clinker_single_node
def test_clinker_single_node():
if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.")
x, y, z = inputs()
node = add.make_node(x, y)
lnk = CLinker().accept(Env(node.inputs, node.outputs))
fn = lnk.make_function()
assert fn(2.0, 7.0) == 9
示例2: test_clinker_straightforward
def test_clinker_straightforward():
if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.")
x, y, z = inputs()
e = add(mul(add(x, y), div(x, y)), bad_sub(bad_sub(x, y), z))
lnk = CLinker().accept(Env([x, y, z], [e]))
fn = lnk.make_function()
assert fn(2.0, 2.0, 2.0) == 2.0
示例3: test_clinker_dups_inner
def test_clinker_dups_inner():
if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.")
# Testing that duplicates are allowed inside the graph
x, y, z = inputs()
e = add(mul(y, y), add(x, z))
lnk = CLinker().accept(Env([x, y, z], [e]))
fn = lnk.make_function()
assert fn(1.0, 2.0, 3.0) == 8.0
示例4: test_clinker_not_used_inputs
def test_clinker_not_used_inputs():
if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.")
# Testing that unused inputs are allowed.
x, y, z = inputs()
e = add(x, y)
lnk = CLinker().accept(Env([x, y, z], [e]))
fn = lnk.make_function()
assert fn(2.0, 1.5, 1.0) == 3.5
示例5: test_clinker_dups
def test_clinker_dups():
if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.")
# Testing that duplicate inputs are allowed.
x, y, z = inputs()
e = add(x, x)
lnk = CLinker().accept(Env([x, x], [e]))
fn = lnk.make_function()
assert fn(2.0, 2.0) == 4
示例6: test_clinker_literal_inlining
def test_clinker_literal_inlining():
if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.")
x, y, z = inputs()
z = Constant(tdouble, 4.12345678)
e = add(mul(add(x, y), div(x, y)), bad_sub(bad_sub(x, y), z))
lnk = CLinker().accept(Env([x, y], [e]))
fn = lnk.make_function()
assert abs(fn(2.0, 2.0) + 0.12345678) < 1e-9
code = lnk.code_gen()
#print "=== Code generated ==="
#print code
assert "4.12345678" in code # we expect the number to be inlined