提交 2947fd1b authored 作者: Frederic Bastien's avatar Frederic Bastien 提交者: sentient07

Docsting

Added new decorator to few more optimizers
上级 7ba1082f
...@@ -1776,10 +1776,15 @@ def local_useless_alloc(node): ...@@ -1776,10 +1776,15 @@ def local_useless_alloc(node):
@register_canonicalize @register_canonicalize
@gof.local_optimizer([T.alloc]) @gof.local_optimizer([T.alloc])
def local_canonicalize_alloc(node): def local_canonicalize_alloc(node):
""" """If the input type is the same as the output type (dtype and broadcast)
If the input type is the same as the output type (dtype and broadcast)
there is no change in the shape of the input. So this is just a simple copy there is no change in the shape of the input. So this is just a simple copy
of the input. This is not needed. of the input. This is not needed. (as local_useless_alloc)
Also, it will canonicalize alloc by creating Dimshuffle after the
alloc to introduce the dimensions of constant size 1.
See https://github.com/Theano/Theano/issues/4072 to know why this
is needed.
""" """
op = node.op op = node.op
...@@ -1799,6 +1804,7 @@ def local_canonicalize_alloc(node): ...@@ -1799,6 +1804,7 @@ def local_canonicalize_alloc(node):
for client, i in clients: for client, i in clients:
if client != "output" and isinstance(client.op, Alloc): if client != "output" and isinstance(client.op, Alloc):
return return
# Check if alloc adds a broadcastable dimension with shape 1. # Check if alloc adds a broadcastable dimension with shape 1.
output_shape = node.inputs[1:] output_shape = node.inputs[1:]
...@@ -2996,6 +3002,7 @@ def local_subtensor_merge(node): ...@@ -2996,6 +3002,7 @@ def local_subtensor_merge(node):
return [out] return [out]
@register_useless
@register_canonicalize @register_canonicalize
@register_specialize @register_specialize
@gof.local_optimizer([Subtensor]) @gof.local_optimizer([Subtensor])
...@@ -3639,6 +3646,7 @@ def local_join_1(node): ...@@ -3639,6 +3646,7 @@ def local_join_1(node):
# TODO: merge in local_useless_join # TODO: merge in local_useless_join
@register_useless
@register_specialize @register_specialize
@register_canonicalize @register_canonicalize
@gof.local_optimizer([T.Join]) @gof.local_optimizer([T.Join])
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论