提交 1455b49c authored 作者: khaotik's avatar khaotik

backward pickling compatibility

上级 78e20600
...@@ -462,6 +462,18 @@ class GpuCumOp(GpuKernelBase, Op): ...@@ -462,6 +462,18 @@ class GpuCumOp(GpuKernelBase, Op):
return super(GpuCumOp, self).c_support_code_struct(node, nodename) + code return super(GpuCumOp, self).c_support_code_struct(node, nodename) + code
# GpuCumsumOp exists only to serve backward compatibility.
# Once an object is created, it will be converted to CumOp object.
class GpuCumsumOp(GpuKernelBase, Op):
SUPPORTED_NDIMS = 3
__props__ = ("axis",)
def __new__(typ, *args, **kwargs):
obj = object.__new__(GpuCumOp, *args, **kwargs)
obj.mode = 'add'
return obj
@register_opt('fast_compile') @register_opt('fast_compile')
@op_lifter([CumOp]) @op_lifter([CumOp])
@register_opt2([CumOp], 'fast_compile') @register_opt2([CumOp], 'fast_compile')
......
...@@ -407,6 +407,26 @@ def cumprod(x, axis=None): ...@@ -407,6 +407,26 @@ def cumprod(x, axis=None):
return CumOp(axis=axis, mode='mul')(x) return CumOp(axis=axis, mode='mul')(x)
# CumsumOp and CumprodOp are for compatibility with old version,
# just in case unpickling a theano function with old Ops.
class CumsumOp(theano.Op):
__props__ = ("axis",)
def __new__(typ, *args, **kwargs):
obj = object.__new__(CumOp, *args, **kwargs)
obj.mode = 'add'
return obj
class CumprodOp(theano.Op):
__props__ = ("axis",)
def __new__(typ, *args, **kwargs):
obj = object.__new__(CumOp, *args, **kwargs)
obj.mode = 'mul'
return obj
class DiffOp(theano.Op): class DiffOp(theano.Op):
# See function diff for docstring # See function diff for docstring
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论