提交 95c17c54 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Use make_new_inplace mechanism to fix optimization with cast

上级 8e17dcd6
...@@ -2003,6 +2003,18 @@ class Cast(UnaryScalarOp): ...@@ -2003,6 +2003,18 @@ class Cast(UnaryScalarOp):
def __str__(self): def __str__(self):
return '%s{%s}' % (self.__class__.__name__, self.o_type.dtype) return '%s{%s}' % (self.__class__.__name__, self.o_type.dtype)
def make_new_inplace(self, output_types_preference=None, name=None):
"""
This op.__init__ fct don't have the same parameter as other scalar op.
This breaks the insert_inplace_optimizer optimization.
This function is a fix to patch this, by ignoring the
output_types_preference passed by the optimization, and replacing it
by the current output type. This should only be triggered when
both input and output have the same dtype anyway.
"""
return self.__class__(self.o_type, name)
def impl(self, input): def impl(self, input):
return self.ctor(input) return self.ctor(input)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论